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