Host polling - exclusion window

Started by millerpaint, June 13, 2012, 04:11:41 AM

Previous topic - Next topic

millerpaint

Greetings,

Is there a way to exclude a window of time during which hosts on specific subnets will not be polled?  For instance, I would like to not poll hosts between 6pm-7pm PST, because this is a time when many host machines are automatically restarted.


-Kevin


Victor Kirhenshtein

Hi!

You cannot exclude hosts from the poll. However, you can ignore down events in specific time interval by using appropriate filter script in event processing policy.

Best regards,
Victor

millerpaint

Hi Victor,

My goal is to not get any node down alerts between 6pm and 10pm.  I have this filtering script in my event policy - this is my first script, so please bear with me :-)

sub main()
{
   now = localtime();
   return (now->hour <= 18 || now->hour >= 22);
}

It is not working (I receive alerts during the time window).  Also, after I get this working, I will need to specify another time window for the weekends (Saturday and Sunday).


Any advice is appreciated!

-Kevin

Victor Kirhenshtein

Hi!

Actually, this script will filter out time from 19:00 to 22:00, not from 18:00 - because even for 18:59 condition now->hour <= 18 will be true. You either should lost 1 minute, and use now->hour <= 17, or use condition like

(now->hour < 18 || now->hour >= 22 || (now->hour == 18 && now->min == 0))

If you need to add Saturday and Sunday, you can use script like this:


now = localtime();
if (now->wday == 0)
   return /* sunday-specific check */
if (now->wday == 6)
   return /* saturday-specific check */
return (now->hour < 18 || now->hour >= 22 || (now->hour == 18 && now->min == 0));


Best regards,
Victor

millerpaint

Ah, of course.  I did not take into account the 59 minutes, and 59 seconds!  I will also look at the Saturday and Sunday code example you provided.


Thank you!

-Kevin