Alarm notification call API
-
-
Add "server action" in EPP rule where you are creating alarm
-
-
Yes, right, these are the macros described here: https://netxms.org/documentation/adminguide/event-processing.html#macros-for-event-processing
There's no built-in macro for alarm ID, but there's %[script_name] which will call a script from script library. There'll be a few variables set in the script, specifically:
$object - always is set
$node - set if event is created on a node
$event - when script is called from EPP
$alarm - if at given moment of event processing by EPP rules an alarm is already created.$alarm variable has Alarm class described here: https://netxms.org/documentation/nxsl-latest/#class-alarm , so simple scriptreturn $alarm.id;should do the job. -
-
Well, while not being a LLM, I've hallucinated about $alarm :). It does not actually exist.
But in $event there's lastAlarmKey attribute, so we can use that to get alarm's ID:
a = FindAlarmByKey($event.lastAlarmKey); return a.id;Or course, alarm should have a key and this key should be unique.
At some point we will add lastAlarmID attribute to $event.
-
Hi Filipp,
thanks for the reply that also works for new Alarms but this issue I have is when the event is raised for terminating the alarm it doesn't work and raises the below
Error:
Minor vm-netxms-srev SYS_SCRIPT_ERROR Script (getAlarmID) execution error: Error 14 in line 3: Function or operation argument is not an object 07.10.2025 08:58:16Script:
//return $event.id;
a = FindAlarmByKey($event.lastAlarmKey);
return a.id; -
Well, yes, FindAlarmByKey() is not searching through already terminated alarms, only current ones. And even if everything happens within one EPP rule, alarm termination happens first and server action happens after that.
So the solution for now is to store the ID somehow before alarm termination. We can use filtering script in the EPP rule:
a = FindAlarmByKey($event.lastAlarmKey); $event.setNamedParameter("lastAlarmID", a.id); return true;return true; is needed since this is filtering script and EPP rule will be processed further only if this script returns true.
And in your script that is used by the %[script] macro:
return $event.getParameter("lastAlarmID");We are adding a new parameter to the event. This parameter will be accessible in any EPP rule that goes below the one where it's being added.
Ah, and actually you don't need the %[script] thing any more - you can just use %<lastAlarmID> macro - this should return value of event's parameter.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login