NetXMS Support Forum

English Support => General Support => Topic started by: mikiplus on May 25, 2016, 02:55:17 PM

Title: UseInterfaceAliases
Post by: mikiplus on May 25, 2016, 02:55:17 PM
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
Title: Re: UseInterfaceAliases
Post by: Victor Kirhenshtein on May 27, 2016, 09:43:27 AM
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
Title: Re: UseInterfaceAliases
Post by: mikiplus on May 27, 2016, 05:12:16 PM
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;
}


Title: Re: UseInterfaceAliases
Post by: tomaskir on May 27, 2016, 06:12:13 PM
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
Title: Re: UseInterfaceAliases
Post by: Victor Kirhenshtein on May 27, 2016, 06:19:23 PM
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
Title: Re: UseInterfaceAliases
Post by: mikiplus on May 27, 2016, 06:32:27 PM
thank you very much for your help!