Forum Discussion
5 years ago
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("CiscoUCCX")</appliesTo> <wildcardauto>true</wildcardauto> <wildcardpersist>false</wildcardpersist> <wildcardlinuxscript>ad_script</wildcardlinuxscript> <wildcardlinuxcmdline>type="embeded" </wildcardlinuxcmdline> <wildcardwinscript>ad_script</wildcardwinscript> <wildcardwincmdline>type="embeded" </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("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(" ") if (splitLine[0] == "UCCX"){ // for instance discovery: println(splitLine[2] + "##" + splitLine[2] + " on " + splitLine[1] + "######" + "uccx_server=" + splitLine[1]) } } // we also need to have an instance to contain the global percent completed: // in our discovery script, we'll add this: println("overall##overall") // 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("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: if (splitLine[0] == "Percentage"){ println("overall.status: " + splitLine[2] } if (splitLine[0] == "UCCX"){ // 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 } } // 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>
Related Content
- 2 years ago
- 3 months ago