Time of Day Alerts

Well Hello, I’m trying to set alerts to specifically alert only during specific times of day, based on the location name. I have been successfully getting my other alerts to work, but just cannot find anything around for based on a certain time.

Example:
%macros.device_down=“1” &&%devices.status_reason = “icmp”% &&devices.location= “bfe” (only send alerts between 8am and 5pm)

I was thinking it would look something like this (%system.time>=8 &&%system.time<=17)

I don’t think that is possible right now.

Did you take a look to the Scheduled Maintenance? Perhaps it can help. It’s under Alerts menu.

I am looking for the same thing, Can I just set alert rules and only activate at certain time of the day?

Thanks.

Should be possible via custom SQL statement alert, making use of SYSDATE etc…

An easier way would be to utliize smart transport features such as OpsGenie, which can offer time based alerts on top of LibreNMS.

2 Likes

You could define a macro that checks if the time is during desired hours.

You can build macros and add them to your config.php. Here is a sample that I just tested for business hours and after hours. You then want to add this to your alert_rules. Remember that you will need to double up your rules. You will need to create rules for Business hours(BH) and After hours(AH). I created rules for AH that delay for 11m so if something just pops then I do not get and email. During BH I have it setup for delay of 6m on alert rules.

Business hours(BH) Mon-Fri (7 am - 5:59 pm)
After hours(AH) Mon-Fri (6 pm - 6:59 am), Sat/Sun(all day)

$config[‘alert’][‘macros’][‘rule’][‘business_hours’] = ‘(HOUR(now()) >= 7 AND HOUR(now()) <= 17) AND WEEKDAY(now()) <= 4’;
$config[‘alert’][‘macros’][‘rule’][‘after_hours’] = ‘(HOUR(now()) <= 6 OR HOUR(now()) >= 18) OR WEEKDAY(now()) >= 5’;

3 Likes

There’s one glitch with these macros: If the BH alert is triggered and you acknowledge that alert, you’ll get another one when the AH rule matches.

I was able to address this using some of the available timestamps instead of now():

  • Device Down: devices.last_polled
  • Service Down: services.service_changed

Unfortunately I haven’t found a timestamp related to disk usage warnings. Does someone have a solution for that?