Hi all,
is it possible send by email (when action is configured) the variable "alias"?
I have set the variable "UseInterfaceAliases" to value = 3 but the action email only sends the name interface.
Thanks
Hi,
you can do that using scripts - interface object has attribute "alias". To get interface object you can use function GetInterfaceObject (https://wiki.netxms.org/wiki/NXSL:GetInterfaceObject) if you know interface index or walk through all node interfaces using GetNodeInterfaces (https://wiki.netxms.org/wiki/NXSL:GetNodeInterfaces) function and iterate through it's results.
Best regards,
Victor
Hi,
I have tested the following script but I don't know if it's the best way to obtain the alias attribute:
sub main()
{
aliasNAME = "no info";
if ($event->parameters[1] != null)
{
id = $event->parameters[1];
interfaces = GetNodeInterfaces($node);
foreach(i : interfaces)
{
if (i->id == id)
{
aliasNAME = i->alias;
}
}
}
return aliasNAME;
}
That looks good.
As bonus info, you don't have to declare the main() function.
See this: https://wiki.netxms.org/wiki/UM:NetXMS_Scripting_Language_(NXSL)#Script_entry_point
For processing SYS_IF_DOWN/SYS_IF_UP events script could be easier, because you have interface index as fifth parameter:
iface = GetInterfaceObject($node, $event->parameters[5]);
return (iface != null) ? iface->alias : "no info";
Best regards,
Victor
thank you very much for your help!