Forum Discussion

Jason_Fant's avatar
5 years ago

Monitor UCCX Backup Status thru SSH

Hello,

I have a UCCX Cluster where I want to monitor the backup status.    I've wrote most of the code to SSH into the system and run the command to check the backup status.    The issue I'm having is being able to parse it and alarm on it correctly.     Can anyone help me on parsing out these three fields.....I assume it'd need to be a Key:Value pair but not sure how to do that.   And if I find "SUCCESS", how can I trigger a datapoint threshold?   I assume I have to convert the SUCCESS into a 1 or 0 and alarm on that INTEGER.

    def status = command_output.findAll(~/Status:\s(.*)/) { key, value -> value }
    def tar_file = command_output.findAll(~/Tar Filename:\s(.*)/) { key, value -> value }
    def percentage = command_output.findAll(~/Percentage Complete:\s(.*)/) { key, value -> value }

 

Here is my Groovy script:

import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;

// import the logicmonitor expect helper class
import com.santaba.agent.groovyapi.expect.Expect;

// get the hostname and credentials from the device property table
hostname = hostProps.get("system.hostname");
userid = hostProps.get("ssh.user");
passwd = hostProps.get("ssh.pass");

// open an ssh connection and wait for the prompt
ssh_connection = Expect.open(hostname, userid, passwd);
ssh_connection.expect("admin:");

// run command
ssh_connection.send("utils disaster_recovery status backup\n");
ssh_connection.expect("admin:");

// logout from the device
ssh_connection.send("exit\n");

// collect the output, then close the ssh connection
output=ssh_connection.before();
ssh_connection.expectClose();


// Everything here below is just testing/playing with the output...this could be all wrong/bad
//===============================================================================================
// strip the info we need value and print the config
def status = output.findAll(~/Status:\s(.*)/)
def tar_file = output.findAll(~/Tar Filename:\s(.*)/)

if ( status =~ "SUCCESS" )
{
    //Set code to 0 for success"
    def statuscode = 0
}else{
    //Set code to 1 for failure"
    def statuscode = 1
}

println output;

// return with a response code that indicates we ran successfully
return(0);

 

 

And here is what the Output looks like:

utils disaster_recovery status backup
Status: SUCCESS :Backup Completed...
Tar Filename: 2020-11-02-02-00-01.tar
Storage Location: NETWORK
Operation: backup
Percentage Complete: 100
UCCX   VOIP-UCCX-001   UCPREFS   SUCCESS   Mon Nov 02 02:00:01 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_ucprefs.log   
UCCX   VOIP-UCCX-001   PHX_RPT   SUCCESS   Mon Nov 02 02:00:07 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_phx_rpt.log   
UCCX   VOIP-UCCX-001   UCDB   SUCCESS   Mon Nov 02 02:00:08 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_ucdb.log   
UCCX   VOIP-UCCX-001   PHX_CONFIG   SUCCESS   Mon Nov 02 02:00:47 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_phx_config.log   
UCCX   VOIP-UCCX-001   TCT   SUCCESS   Mon Nov 02 02:00:47 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_tct.log   
UCCX   VOIP-UCCX-001   CDPAGT   SUCCESS   Mon Nov 02 02:00:48 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_cdpagt.log   
UCCX   VOIP-UCCX-001   SYSLOGAGT   SUCCESS   Mon Nov 02 02:00:48 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_syslogagt.log   
UCCX   VOIP-UCCX-001   PLATFORM   SUCCESS   Mon Nov 02 02:00:49 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_platform.log   
UCCX   VOIP-UCCX-001   CLM   SUCCESS   Mon Nov 02 02:00:51 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_clm.log   
UCCX   VOIP-UCCX-001   CCXCOMPONENT   SUCCESS   Mon Nov 02 02:00:51 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_ccxcomponent.log   
UCCX   VOIP-UCCX-001   REPORTER   SUCCESS   Mon Nov 02 02:01:25 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_reporter.log   
UCCX   VOIP-UCCX-001   CUIC_CONFIG   SUCCESS   Mon Nov 02 02:01:26 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_cuic_config.log   
UCCX   VOIP-UCCX-001   IDS_CONFIG   SUCCESS   Mon Nov 02 02:01:26 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_ids_config.log   
UCCX   VOIP-UCCX-002   SYSLOGAGT   SUCCESS   Mon Nov 02 02:01:27 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_syslogagt.log   
UCCX   VOIP-UCCX-002   CDPAGT   SUCCESS   Mon Nov 02 02:01:28 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_cdpagt.log   
UCCX   VOIP-UCCX-002   TCT   SUCCESS   Mon Nov 02 02:01:28 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_tct.log   
UCCX   VOIP-UCCX-002   PHX_CONFIG   SUCCESS   Mon Nov 02 02:01:29 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_phx_config.log   
UCCX   VOIP-UCCX-002   CCXCOMPONENT   SUCCESS   Mon Nov 02 02:01:29 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_ccxcomponent.log   
UCCX   VOIP-UCCX-002   PLATFORM   SUCCESS   Mon Nov 02 02:01:45 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_platform.log   
UCCX   VOIP-UCCX-002   PHX_RPT   SUCCESS   Mon Nov 02 02:01:46 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_phx_rpt.log   
UCCX   VOIP-UCCX-002   CLM   SUCCESS   Mon Nov 02 02:01:47 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_clm.log   
UCCX   VOIP-UCCX-002   REPORTER   SUCCESS   Mon Nov 02 02:01:47 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_reporter.log   
UCCX   VOIP-UCCX-002   CUIC_CONFIG   SUCCESS   Mon Nov 02 02:01:48 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_cuic_config.log   
UCCX   VOIP-UCCX-002   IDS_CONFIG   SUCCESS   Mon Nov 02 02:01:49 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-002_uccx_ids_config.log   

 

  • Anonymous's avatar
    Anonymous

    You'd setup a datapoint using the output and post-processor would be key/value pairs. The key would be:

    ##WILDVALUE##.status

    Set a threshold for < 100 and you should be good to go. 

  • Anonymous's avatar
    Anonymous

    Btw, this assumes BATCHSCRIPT is the collection method. This type of output won't work with SCRIPT.

  • Anonymous's avatar
    Anonymous
    38 minutes ago, Jason Fant said:

    import com.santaba.agent.groovyapi.snmp.Snmp;
    import com.santaba.agent.groovyapi.http.*;
    import com.santaba.agent.groovyapi.jmx.*;
    import org.xbill.DNS.*;

    You don't need this bit since you're not using any of those libraries. Minuscule performance drain.

    Do you have a discovery script and a collection script or is this one script as far as you got? If it is, you'll need to make two copies of your script. One that will output the instances (discovery) and one that will output the data (collection). 

    For both, you'll want to loop through and inspect each line of the output. You'll do this like this:

    output.eachLine{ line ->
    	// let's turn this:
    	// UCCX   VOIP-UCCX-001   UCPREFS   SUCCESS   Mon Nov 02 02:00:01 EST 2020   activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_ucprefs.log
    	// into this:
    	// [UCCX, VOIP-UCCX-001, UCPREFS, SUCCESS, Mon, Nov, 02, 02:00:01, EST, 2020, activelog/platform/drf/log/2020-11-02-02-00-01_b_voip-uccx-001_uccx_ucprefs.log]
    	// This lets us address each bit individually.
    	splitLine = line.tokenize(" ")
      
    	if (splitLine[0] == "UCCX"){
    		// for instance discovery:
    		println(splitLine[2] + "##" + splitLine[2] + "######" + "uccx_server=" + splitLine[1])
    
    		// for data collection, we need to output WILDVALUE.status: 1
    		// splitLine[2] contains our WILDVALUE
    		// (we defined wildvalue as the first term of the discovery output)
    		println(splitLine[2] + ".status: " + (splitLine[3] == "SUCCESS")? 100 : 0)
    		// the last bit checks that term 3 in our split output contains "SUCCESS".
    		// if it does, let's output 100, if not let's output 0
    	}
    }
    
    // we also need to have an instance to contain the global percent completed:
    // in our discovery script, we'll add this:
    println("overall##overall")
    
    // in our collection script, we'd add a line to our loop that checks for "percentage complete" like this:
    if (splitLine[0] == "Percentage"){ println("overall.status: " + splitLine[2] }
    // this can be added right before our "if (splitline[0] == "UCCX"){" line in the loop.