Time Based Event Processing

Started by Abraxas, May 17, 2021, 03:34:09 PM

Previous topic - Next topic

Abraxas

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

Victor Kirhenshtein

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

Abraxas

Awesome, thank you!
I will try this.