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...") |
|||
Line 1: | Line 1: | ||
{| style="border-spacing: 20px; border: 20px solid red;" | |||
| | |||
'''WARNING''': This page is no longer updated. Please visit '''[https://www.netxms.org/documentation/nxsl-latest/ NetXMS Scripting Language]''' for current version of the documentation. | |||
|} | |||
'''Requirements''' | '''Requirements''' | ||
Revision as of 15:51, 5 October 2020
WARNING: This page is no longer updated. Please visit NetXMS Scripting Language for current version of the documentation. |
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;