NetXMS Support Forum

English Support => General Support => Topic started by: Abraxas on May 17, 2021, 03:34:09 PM

Title: Time Based Event Processing
Post by: Abraxas on May 17, 2021, 03:34:09 PM
Hi,

Is there a way to configure an event processing to behave differently based on the time?
Besides the normal alarms we have, I was trying to setup new ones that should trigger only during the night for example, when there is nobody to check email/sms messages. So basically I wanted to add a new event processing policy, for a particular event, but it should only trigger if the event is raised between 00 and 8 am for example.
I hope this can be done through the filtering script, but I was not able to find how to do that.

Thank you,
Alex
Title: Re: Time Based Event Processing
Post by: Victor Kirhenshtein on May 17, 2021, 04:11:30 PM
Hi,

yes, this can be done with filtering script. You can get "time" object with gmtime or localtime functions and then check it's properties. To match events only between 00:00 and 08:00 you can use the following script:


t = localtime($event->timestamp);
return t->hour >= 0 and t->hour < 8;


This will not include 8:00, if you need it you should add additional condition that checks for 8:00 exact time.

Best regards,
Victor
Title: Re: Time Based Event Processing
Post by: Abraxas on May 17, 2021, 09:37:54 PM
Awesome, thank you!
I will try this.