Creating a Complex Data Source to check the Interface Description and then the state of an interface to generate an alert.
The plan is on our switches we include "MO-CRIT" in the description if we want to generate an alert within LogicMonitor, it is fairly obvious to me that we need to create the datasource using Groovy which I have done, but when ever I run I get the following for the data source "Exception=No Such Property: output for class: Scriptnnn
I have set up the variable name IntName and have tried the system.instanceDescription and the auto.interface.alias nether seem to work
def IntName=taskProps.get('system.instanceDescription') (I have tried instanceProps.get)
Any suggestions.
SteveBamford
Posted 4 years ago·Last reply 4 years ago
2 comments
LM User
·4 years agoJust a recommendation, but why rebuild that datasource? I suggest modifying the discovery script to output an additional instance level property with value 0 or 1 depending on whether or not the description contains the "MO-CRIT" string. This would involve changing one line of code and adding one datapoint.
Using the SNMP_Network_Interfaces datasource, look at line 173 of the discovery script. This line outputs the list of instances:
Remember from AD that there are 5 terms here, divided by ##:
So in this case, we have ifIndex as the wildvalue, "ifEntry.description + [ID:ifIndex]"as the display name, a modified description as the description and we have a list of instance level properties.
Let's look at the instance level properties a little closer:
This is some advanced Groovy syntax, but it basically takes the contents of ifEntry, which is a Groovy Map (similar to Python dict). For one of the interfaces on one of my devices, ifEntry looks like this:
So, the AD script would output something like this for that interface (forgive the horizontal scrolling/carriage return, this is actually one line):
One thing we could do would be to add to this println statement in the AD script to evaluate the description and return a 0 or 1 if the description contains "MO-CRIT". This could be done like this:
This would set an instance level property called auto.interface.alert_on_desc with a value of either 0 or 1.
Then you could create a datapoint called alert_on_desc with ##auto.interface.alert_on_desc## as the infix expression. This will get a 0 or 1 into the datapoint, which could be used in any datapoints that alert to turn the alert on or off.