Difference between revisions of "Script Example: Additional Information About Connected Node"
Jump to navigation
Jump to search
(Created page with "'''Requirements''' Add information about name, IP address, and MAC address about connected node to notification about switch port being down. '''Solution''' Use named even...") |
(No difference)
|
Revision as of 11:23, 14 June 2012
Requirements
Add information about name, IP address, and MAC address about connected node to notification about switch port being down.
Solution
Use named event attribute additionalInfo to pass information into e-mail body (using %<additionalInfo> macro). To populate this attribute the following script can be used:
// only for interface up and down events
if (($event->name != "SYS_IF_DOWN") && ($event->name != "SYS_IF_UP"))
return true;
// get interface object from interface index
iface = GetInterfaceObject($node, $5);
if (iface == null)
return true;
// get peer node (node connected to this interface) object
peer = iface->peerNode;
if (peer == null)
return true;
// get peer interface object (needed to obtain MAC address)
peerIface = iface->peerInterface;
if (peerIface != null)
{
macAddr = peerIface->macAddr;
}
else
{
macAddr = "<MAC unknown>";
}
// set event's named parameter
SetEventParameter($event, "additionalInfo",
"Peer: " . peer->name . " " . peer->ipAddr . " " . macAddr);
return true;