Forum Discussion
Anonymous
5 years ago38 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.
Related Content
- 2 years ago
- 3 months ago