Forum Discussion

Jason_Fant's avatar
4 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   

 

13 Replies