NetXMS Support Forum

English Support => General Support => Topic started by: Sash on October 05, 2023, 03:31:53 PM

Title: Filtering Script on Event Processing Policy request value from other dci
Post by: Sash on October 05, 2023, 03:31:53 PM
Hi all,

I have a Event Processing Policy which send me an Alarm If a Networkinterface has more than 5 Errors / min. 
Now I want to filter that a Alarm is only generated when the Interface is not on halfduplex mode.

For both I have set a DCI.

Unfortunally I have no Idea how I can match the other DCI in the Filterscript...

Some Ideas?

Thanks a lot.

Title: Re: Filtering Script on Event Processing Policy request value from other dci
Post by: Filipp Sudanov on October 09, 2023, 11:38:03 AM

In event processing policy you can use a filter script like this:
ifName = $dci->instance;
if (ifName == null or ifName == "") return false;

dciDescription = "Port Speed auf " . ifName;
portSpeed = GetDCIValueByDescription($node, dciDescription);

if (portSpeed->contains("HD")) return false;

return true;


$dci->instance will work if your DCIs are created by instance discovery, otherwise you might need to get the interface name by parsing description.

Alternative approach could be to use script threshold on your network error DCIs - that script could also get value of port speed DCI and generate threshold violation event only when both conditions are met. This way you would have less events (which also consume resources as they are stored in the DB).

Feel free to ask if you need more script examples.


Title: Re: Filtering Script on Event Processing Policy request value from other dci
Post by: Sash on January 17, 2024, 12:25:34 PM
Hi Filipp,

sorry for the late response. Thanks for the example.

I use it now in Threshold Script.
The Script

1 dciDescription = "Port Speed auf 1/1/3";
2 portSpeed = GetDCIValueByDescription($node, dciDescription);
3
4 if (portSpeed->contains("HD")) return true;
5
6 return false;

is working - but everytime I restart the NetXMS Server I get an Error about the Script:

Script (DCI::xxx - xxx::10165::12568::ThresholdScript) execution error: Error 14 in line 4: Function or operation argument is not an object

Where´s my Misstake?

Thanks for your Help.




Title: Re: Filtering Script on Event Processing Policy request value from other dci
Post by: Filipp Sudanov on January 18, 2024, 07:26:02 AM
Yes, threshold script is a better place for this.

If you open hint in editor of threshold script, you'll see:
$1 current DCI value;
$2 threshold value;
$dci this DCI object;
$isCluster true if DCI is on cluster;
$node current node object (null if DCI is not on the node);
$object current object.

So you can use $1 instead of GetDCIValueByDescription($node, dciDescription);, this would give you current value of the DCI.

GetDCIValueByDescription() actually gets previously collected value, when server starts, values for frequently collected DCIs are not cached from database to memory, that's would explain script error.
Title: Re: Filtering Script on Event Processing Policy request value from other dci
Post by: Sash on January 31, 2024, 09:23:10 AM
Hi Filipp.

thanks for your reply.

$1 is current DCI value - this is matched to the "Eingehende Fehlerrate" DCI - but I need the value from the "Port Speed auf x/x/x"
So I can´t use $1 in this script.

DCI Template:
(about:invalid)
(about:invalid)

Data Collection in Node:
(about:invalid)
(about:invalid)


right?

Title: Re: Filtering Script on Event Processing Policy request value from other dci
Post by: Filipp Sudanov on February 01, 2024, 05:06:06 PM
Looks like some screenshots are missing.
But a question regarding your text - may be you can just use your threshold script right on "Port Speed auf x/x/x" DCI?