News:

We really need your input in this questionnaire

Main Menu

interface id on state change

Started by MarcusH, September 16, 2016, 01:00:13 PM

Previous topic - Next topic

MarcusH

Hi,

I am monitoring all the ports on our switches to see if and when hardware is added or removed via the state change of the interface.
These are named after the portnumber so the alarm state for example "Interface "33" unexpectedly changed state..."

What is the best and most correct way to add alias to ports since i want to add room/local network alias to the interface port so i know where or who it is.
Change object name does not work since it updates when polling back to port number, change port name on the switch does not work it wont send that when snmp is polling.
Now i am looking into the custom attribute to set that and if you can use data from these in the alarm message, still trying to find info about how custom attributes are used though.

Any pointers would be appreciated.

Victor Kirhenshtein

Hi,

You can use custom attribute or comment field on interface. The only trick here is that event source is a node, not an interface. To access custom attribute (or comment) of an interface for interface event you can use the following script:


iface = GetInterfaceObject($node, $5);
return iface->comments;
// For custom attribute replace with
// return GetCustomAttribute(iface, "attribute_name");


You can create such script in script library and then use %[script_name] macro in your messages.

Best regards,
Victor

MarcusH

Many thanks for help with the script, i have tested it and i got it to work as intended and it is triggered as planed but $5 does not return anything so it fails.
If i change $5 to 1 manually as it is the iface i test on it works and the custom attribute is shown in the alert message.

MarcusH

#3
Been trying to figure this out but every information i find states that parameters are passed as macro %5 or variable $5 in script.

macro %5 works in message but variable $5 is empty when calling script via macro in message is this bugged in any way, or might i be missing something crucial here?

Running version 2.0.5

Edit:
Found solution, change $5 to $event->parameters[5]