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...") |
m (Text replacement - "^" to "{{deprecated}}") |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{deprecated}} | |||
{| style="border-spacing: 20px; border: 20px solid red;" | |||
| | |||
'''WARNING''': This page is no longer updated. Please visit '''[https://www.netxms.org/documentation/nxsl-latest/#_examples_2 NetXMS Script examples]''' for current version of the documentation. | |||
|} | |||
'''Requirements''' | '''Requirements''' | ||
Latest revision as of 16:13, 13 September 2022
This Wiki is deprecated and we are are currrently migrating remaining pages into product documentation (Admin Guide, NXSL Guide) |
WARNING: This page is no longer updated. Please visit NetXMS Script examples 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;