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.

%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?


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.


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’;


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?

Would be better a time-range for alert transports instead of alert tules.


ospfbgp, I’ve seen this answer of yours a few times searching for a solution to this kind off problem, however, seems like a tip for someone who already knows deeply how librenms works, knows php or what a macro is or where it goes, to the rest of us who just were asked to deploy it and set it up, not so much, it does sound like a good workaround (I think that since you first answer was around 2017, the ability to setup time frames for certain alerts should be already part of librenms, sadly it’s not, not yet) Would you be so kind as to elaborate a bit more on where to put that macro, and how to enable it, or whatever is needed to be able to make use of your solution?

Also, and this is a total abuse on my part, as a non native english speaker I’m getting trouble to understand what you mean by “rules for AH that delay for 11m” does that mean that any alerts that happened before that will wait to that time and send a bunch of mails all toghether?, and “Remember that you will need to double up your rules” why is that? I’ve read the documentation, and I don’t recall to anything about the need to double up rules, then again I have the memory of a mosquito, so there´s that…

Thank you very much in advance.

1 Like

Already from reading this topic. I gave up using macros in LibreNMS. Having trialled alerting systems (Signl4, PagerDuty, OpsGenie). I already find it easier to define logic for activating on the “on-call” person/staff using alerting rules in an alert manager. Instead of directly in LibreNMS itself. — Messing with Macros for this is just not my thing… :face_with_spiral_eyes: