NetXMS Support Forum

English Support => General Support => Topic started by: ntnam on August 20, 2019, 04:59:07 AM

Title: Add custom parameter to Event Template?
Post by: ntnam on August 20, 2019, 04:59:07 AM
Event SYS_IF_DOWN has default message Interface "%2" changed state to DOWN (IP Addr: %3/%4, IfIndex: %5)
How can i add %6 or %? with interface ifAlias?
Title: Re: Add custom parameter to Event Template?
Post by: Victor Kirhenshtein on August 20, 2019, 01:05:50 PM
Hi,

interface alias is not passed to SYS_IF_DOWN. You can create script in script library called GetInterfaceAlias with the following code:

return GetInterfaceObject($node, $event->parameters[5])->alias;


and then use macro %[GetInterfaceAlias] in message text.

Best regards,
Victor
Title: Re: Add custom parameter to Event Template?
Post by: ntnam on August 20, 2019, 02:06:26 PM
Yes. Thanks you very much.
Title: Re: Add custom parameter to Event Template?
Post by: ntnam on October 18, 2019, 07:08:27 AM
Event SYS_THRESHOLD_REACHED don't have parameter index of interface.
Can i store it from Threshold Script and get it in Event?
Can you show me another way to get it?
Title: Re: Add custom parameter to Event Template?
Post by: Victor Kirhenshtein on October 18, 2019, 05:48:00 PM
In version 3.0 you can set interface as related object for DCI and then access it via DCI object.

Best regards,
Victor
Title: Re: Add custom parameter to Event Template?
Post by: ntnam on October 22, 2019, 03:58:57 AM
I create the script GetInterfaceAlias
if ($dci==null)
  return "?";
else
  return GetInterfaceObject($node, $dci->instanceData)->alias;

and using macro in message %[GetInterfaceAlias] but this return "?"
my threshold script run correct
ifo = GetInterfaceObject($node, $dci->instanceData);
speed = ifo->speed;
if (speed!=null)
  if ($1/speed*100 > $2)
    return true;
return false;

I'am using NETXMS 3.0.2287.
Can you tell me my mistake.

Title: Re: Add custom parameter to Event Template?
Post by: Filipp Sudanov on October 25, 2019, 05:35:02 PM
Currently $dci is not supported when a script is called from event processing. For SYS_THRESHOLD_EVENTs DCI ID is passed as 5-th parameter of $event:

trace(1, "Script on SYS_THRESHOLD_EVENT: DCI ID: ".$event->parameters[5]+0);
trace(1, "Script on SYS_THRESHOLD_EVENT: DCI name: ".GetDCIObject($node,($event->parameters[5]))->name);
trace(1, "Script on SYS_THRESHOLD_EVENT: Interface name: ".GetDCIObject($node,($event->parameters[5]))->relatedObject->name);