• 0

Monitor UCCX Backup Status thru SSH


Jason Fant
 Share

Question

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   

 

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0
  • Administrators
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.

 

Edited by Stuart Weenig
Added some missing parenthesis.
Link to comment
Share on other sites

  • 0

Thanks for the help!    I had to make some changes to the Discovery script as some of the lines returned are not unique.   So it was having overlapping INSTANCES.    To make them unique, I changed the print lines to include the actual name of the UCCX Server. 

That worked but now it's throwing an error on my collection script.    I attached the XML DS if you want to see what I've got. 

 

 

 

<?xml version="1.0" encoding="UTF-8" ?>
<feed  version="1.0" hasPendingRequests="false" >
  <company></company>
  <status>200</status>
  <errmsg>OK</errmsg>
  <interval>0</interval>
    <entry type="predatasource">
        <version>1604336087</version>
        <name>UCCX Backup StatusFANT-</name>
        <displayedas>UCCX Backup StatusFANT-</displayedas>
        <description></description>
        <collector>batchscript</collector>
        <hasMultiInstances>true</hasMultiInstances>
        <schedule>21600</schedule>
        <appliesTo>hasCategory(&#34;CiscoUCCX&#34;)</appliesTo>
        <wildcardauto>true</wildcardauto>
        <wildcardpersist>false</wildcardpersist>
        <wildcardlinuxscript>ad_script</wildcardlinuxscript>
        <wildcardlinuxcmdline>type=&#34;embeded&#34; </wildcardlinuxcmdline>
        <wildcardwinscript>ad_script</wildcardwinscript>
        <wildcardwincmdline>type=&#34;embeded&#34; </wildcardwincmdline>
        <wildcardgroovyscript>// 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(&#34;system.hostname&#34;);
userid = hostProps.get(&#34;ssh.user&#34;);
passwd = hostProps.get(&#34;ssh.pass&#34;);

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

// enter enable mode
ssh_connection.send(&#34;utils disaster_recovery status backup\n&#34;);
ssh_connection.expect(&#34;admin:&#34;);

// logout from the device
ssh_connection.send(&#34;exit\n&#34;);

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

// now lets process the output
output.eachLine{ line -&#62;
	// let&#39;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.
	def splitLine = line.tokenize(&#34; &#34;)
  
	if (splitLine[0] == &#34;UCCX&#34;){
		// for instance discovery:
		println(splitLine[2] + &#34;##&#34; + splitLine[2] + &#34; on &#34; + splitLine[1] + &#34;######&#34; + &#34;uccx_server=&#34; + splitLine[1])

	}
}

// we also need to have an instance to contain the global percent completed:
// in our discovery script, we&#39;ll add this:
println(&#34;overall##overall&#34;)

// return with a response code that indicates we ran successfully
return(0);</wildcardgroovyscript>
        <wildcardschedule>1440</wildcardschedule>
        <wildcarddisable>false</wildcarddisable>
        <wildcarddeleteinactive>true</wildcarddeleteinactive>
        <agdmethod>ilp</agdmethod>
        <agdparams>auto.uccx_server</agdparams>
        <group>UCCX - Contact Center eXpress</group>
        <tags></tags>
        <technology></technology>
        <adlist><![CDATA[{"agdmethod":"ilp","method":"ad_script","agdparams":"auto.uccx_server","id":0,"filters":[],"params":{"type":"embeded","groovyscript":"// import the logicmonitor expect helper class\r\nimport com.santaba.agent.groovyapi.expect.Expect;\r\n\r\n// get the hostname and credentials from the device property table\r\nhostname = hostProps.get(\"system.hostname\");\r\nuserid = hostProps.get(\"ssh.user\");\r\npasswd = hostProps.get(\"ssh.pass\");\r\n\r\n// open an ssh connection and wait for the prompt\r\nssh_connection = Expect.open(hostname, userid, passwd);\r\nssh_connection.expect(\"admin:\");\r\n\r\n// enter enable mode\r\nssh_connection.send(\"utils disaster_recovery status backup\\n\");\r\nssh_connection.expect(\"admin:\");\r\n\r\n// logout from the device\r\nssh_connection.send(\"exit\\n\");\r\n\r\n// collect the output, then close the ssh connection\r\noutput=ssh_connection.before();\r\nssh_connection.expectClose();\r\n\r\n// now lets process the output\r\noutput.eachLine{ line ->\r\n\t// let's turn this:\r\n\t// 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\r\n\t// into this:\r\n\t// [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]\r\n\t// This lets us address each bit individually.\r\n\tdef splitLine = line.tokenize(\" \")\r\n  \r\n\tif (splitLine[0] == \"UCCX\"){\r\n\t\t// for instance discovery:\r\n\t\tprintln(splitLine[2] + \"##\" + splitLine[2] + \" on \" + splitLine[1] + \"######\" + \"uccx_server=\" + splitLine[1])\r\n\r\n\t}\r\n}\r\n\r\n// we also need to have an instance to contain the global percent completed:\r\n// in our discovery script, we'll add this:\r\nprintln(\"overall##overall\")\r\n\r\n// return with a response code that indicates we ran successfully\r\nreturn(0);"}}]]></adlist>
        <schemaVersion>2</schemaVersion>
        <dataSourceType>1</dataSourceType>
        <attributes>
        <attribute>
            <name>scripttype</name>
            <value>embed</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>scriptgroovy</name>
            <value>// 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(&#34;system.hostname&#34;);
userid = hostProps.get(&#34;ssh.user&#34;);
passwd = hostProps.get(&#34;ssh.pass&#34;);

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

// enter enable mode
ssh_connection.send(&#34;utils disaster_recovery status backup\n&#34;);
ssh_connection.expect(&#34;admin:&#34;);

// logout from the device
ssh_connection.send(&#34;exit\n&#34;);

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

// now lets process the output
output.eachLine{ line -&#62;
	// let&#39;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.
	def splitLine = line.tokenize(&#34; &#34;)
    
    // in our collection script, we&#39;d add a line to our loop that checks for &#34;percentage complete&#34; like this:
    if (splitLine[0] == &#34;Percentage&#34;){ println(&#34;overall.status: &#34; + splitLine[2] }
  
	if (splitLine[0] == &#34;UCCX&#34;){
		// 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] + &#34;.status: &#34; + (splitLine[3] == &#34;SUCCESS&#34;)? 100 : 0)
		// the last bit checks that term 3 in our split output contains &#34;SUCCESS&#34;.
		// if it does, let&#39;s output 100, if not let&#39;s output 0
	}
}



// return with a response code that indicates we ran successfully
return(0);</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>windowsscript</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>linuxscript</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>windowscmdline</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>linuxcmdline</name>
            <value></value>
            <comment></comment>
        </attribute>
        </attributes>
        <datapoints>
        <datapoint>
            <name>OverallStatus</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>##WILDVALUE##.status</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr></alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <enableanomalyalertsuppression></enableanomalyalertsuppression>
            <adadvsettingenabled>false</adadvsettingenabled>
            <warnadadvsetting></warnadadvsetting>
            <erroradadvsetting></erroradadvsetting>
            <criticaladadvsetting></criticaladadvsetting>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>0</alertTransitionIval>
            <alertClearTransitionIval>0</alertClearTransitionIval>
        </datapoint>
        </datapoints>
        <graphs>
        </graphs>
        <overviewgraphs>
        </overviewgraphs>
        <scripts>
        </scripts>
    </entry>
</feed>

 

Screenshot 2020-11-02 115403.png

Screenshot 2020-11-02 115622.png

Link to comment
Share on other sites

  • 0
  • Administrators

The wildvalue you define as you output from your discovery script needs to match the wildvalue output from collection. For example, your AD script outputs this:

CDPAGT##CDPAGT on VOIP-UCCX-002######uccx_server=VOIP-UCCX-002

So, your collection script has to output something like this:

CDPAGT.status: 1

This is a problem because there are more than one CDPAGT's in your instance list. WILDVALUE also needs to be unique.

You modified the discovery script to make sure the lines are unique, which is great. However, you only modified the WILDALIAS, which is only part of what needs to be unique. The WILDVALUE also needs to be unique. You can do this by changing the println in each script:

println(splitLine[1] + "::" + splitLine[2] + "##" + splitLine[2] + " on " + splitLine[1] + "######" + "uccx_server=" + splitLine[1])

 

println(splitLine[1] + "::" + splitLine[2] + ".status: " + (splitLine[3] == "SUCCESS")? 100 : 0)

 

See how that creates a unique WILDVALUE and a unique WILDALIAS? Also see that the same WILDVALUE defined in discovery matches the output of collection?

Link to comment
Share on other sites

  • 0

Hey, do you think I can pick your brain some more?    Next thing I wanted to stab with this output is parsing the backup date and compare to see if it's older than 24 hours.    I tried to take the filename tar file and break it up and compare that against current time with the format of yyyyMMddHH.    However.....I'm gonna get a lot of false alarms when this runs and I think my logic might be off....how can I convert these time values into something where I can compare to confirm it's indeed been 24+hrs since last backup.   Also attached a screenshot of the script output. 

 

Here's my new Collector script:

// 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:");

// enter enable mode
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();

// now lets process the output
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.
	def splitLine = line.tokenize(" ")
    
    // in our collection script, we'd add a line to our loop that checks for "percentage complete" like this:
    // [Status:, SUCCESS, :Backup, Completed...]
    if (splitLine[0] == "Status:"){
        println("Overall.status:" + ((splitLine[1] == "SUCCESS")? 0:1))
        }
        
    if (splitLine[1] == "Filename:"){
        // take the tar file name and break it up so we can compare date with Current Time.
        // [2020, 11, 02, 02, 00, 01.tar]
        // We can then combine yyyyMMddHHmm and see if that's greater than current time for MMddHHmm
        // [2020110302 <= 20201103]
        def tarFileDate = splitLine[2].tokenize("-");
        def date=new Date().format('yyyyMMddHH');
        if ((tarFileDate[0] + tarFileDate[1] + tarFileDate[2] + tarFileDate[3]) < date){
            // TRUE
            println("currentdate.date: " + date);
        }else{
            // FALSE
            println("date.date: " + 0);
        }
    }
  
    if (splitLine[0] == "UCCX"){
	    // for data collection, we need to output WILDVALUE.status: 1
	    // splitLine[2] contains our WILDVALUE
	    // [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]
	    // (we defined wildvalue as the first term of the discovery output)
	    println(splitLine[1] + "::" + splitLine[2] + ".status: " + ((splitLine[3] == "SUCCESS")? 0:1))
	    // the last bit checks that term 3 in our split output contains "SUCCESS".
	    // if it does, let's output 0, if not let's output 1
    }
        
}



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

 

 

 

 

Screenshot 2020-11-03 102149.png

Link to comment
Share on other sites

  • 0

wait, nevermind!   I figured it out!   I can use the Date() and getTime() functions to convert the dates into seconds since 1970, and then I can compare times via a common denominator....seconds!    

 

def date=new Date().format('yyyyMMddHH')
Date filedate = new Date("2020/11/03, 02:02:01");


println "Hello World todates date is: " + date
println "file date is: " + filedate
println "the FileDate in seconds is: "+ filedate.getTime();

 

---GROOVY---

returns null
output:
Hello World todates date is: 2020110311
file date is: Tue Nov 03 02:02:01 EST 2020
the FileDate in seconds is: 1604386921000
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share