UseInterfaceAliases

Started by mikiplus, May 25, 2016, 02:55:17 PM

Previous topic - Next topic

mikiplus

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

Victor Kirhenshtein

Hi,

you can do that using scripts - interface object has attribute "alias". To get interface object you can use function GetInterfaceObject if you know interface index or walk through all node interfaces using GetNodeInterfaces function and iterate through it's results.

Best regards,
Victor

mikiplus

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;
}



tomaskir

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

Victor Kirhenshtein

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

mikiplus

thank you very much for your help!