Time range for alert transport

$config[‘alert’][‘macros’][‘rule’][‘business_hours’] = ‘(HOUR(now()) >= 8 AND HOUR(now()) <= 16) AND WEEKDAY(now()) <= 4’;

Alert Rule (Screenshot) looks good.

For my intention i would concentrate myself to business_day macro
have you tried:
((HOUR(now()) >= 8 AND HOUR(now()) <= 16) AND WEEKDAY(now()) <= 4)
instead of
(HOUR(now()) >= 8 AND HOUR(now()) <= 16) AND WEEKDAY(now()) <= 4?

Macro for my intention also looks fine, nethertheless i think macro would be the problem.
Have you tried to reduce it’s complexity for debugging and test it?

I don’t think that I have problem with the macro. My problem is that I get fake recovery notification at 17:00, and I get device down notification at 8:00
The recovery notifaction is fake because the device is still DOWN but it is outside working hours… How can I avoid to ACK the alert every morning? Is the only option for that the “scheduled maintenance”?

change max Alerts to 1

-1 means “do every check interval”

on changing it to 1 you’ll be informed only once

Then I’ll be informed only once every day at 8:00 and I will get recovery message at 17:00

nope,
for the port which was going down the alert only will be sent once if max alert is set to 1.
If it goes up …

OH YEAH !!! :smiley: :man_facepalming:

the cause is the business_day macro … so it matches, then it doesn’t match, then it matches again …

it’s like port is down macro against a flapping port, it matches, it matches not, then it matches again …

so it’s every neẃ start of a matching business_day a new alert, even if the ports stays down over days

i think your wish “i want to be informed only in business hours” is a little more complicated and cannot be solved via macros as i see at moment

mmh alerting only in specified time windows has to be a written and included as Feature Request

1 Like

As you can see we are talking in a Feature request ticket :slight_smile:
I would recommend to be configurable per alert transport

Don’t know who has time/is motivated to implement this feature.
If you’d like to implement this it would be very appreciated :slight_smile:

Unfortunately I’m not a developer.

Work in progress https://github.com/librenms/librenms/pull/11622

1 Like

@1soproni, please test the feature!

To apply new feature patch

./scripts/github-apply 11622
php artisan migrate

To revert:

php artisan migrate:rollback --step=4
./scripts/github-remove -d

Hi,

thx for the patch and for your effort.
I tried to set it, but I cannot set greater “start hour” (and minutes (should be renamed to start time)) than the actual time(neither with the arrows, nor with the selector)


The “end hour” (end time) cannot be set to lower than the actual time.
E.g.: The time is 7:00 now. I cannot set the start hour to 8:00
Hmmm, okay I leave the text above here because that was the status. But I tried to set lower start time than the actual, went lower than midnight and finally I could set it to any time. After that works well the start and also the time settings.

I think the “Only on weekday:” text is also pointless. (But English is not my native language) You should change it e.g. to “Only on theese day(s)” or “Only on weekday” should be a button which marks the weekdays (Mo-Fr) but it depends on country… BTW: clicking on the text of “Only on weekday” ticks Monday

I’m trying to save the transport. Ticked “All devices except in list” and did not select any device from the list. In this scenario should not it include all the devices?

Hi,

thank you for the review.

I have changed the following:

  • change label to start time, only on day…
  • Ticked “All devices except in list” and did not select any device => resulted in selecting all devices. Added a control so that it will be impossible to save this.

Top apply the last version of the patch:

echo y | ./scripts/github-remove -d; ./scripts/github-apply 11622

I don’t know why you are not able to select time. Could you open developper console (Ctrl+shift+i on browser) and send me the screenshot of console on the error.

Coud you send me a ./validate.php ?

`$ ./validate.php

Component Version
LibreNMS 1.65
DB Schema 2020_06_30_170000_create_transport_location_map_table (174)
PHP 7.3.14-1~deb10u1
Python 3.7.3
MySQL 10.3.22-MariaDB-0+deb10u1
RRDTool 1.7.1
SNMP NET-SNMP 5.7.3
====================================

[OK] Composer Version: 1.10.8
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[WARN] Your local git contains modified files, this could prevent automatic updates.
[FIX]:
You can fix this with ./scripts/github-remove
Modified Files:
LibreNMS/Alert/AlertUtil.php
LibreNMS/Alert/RunAlerts.php
includes/html/forms/alert-transports.inc.php
includes/html/forms/show-alert-transport.inc.php
includes/html/modal/alert_schedule.inc.php
includes/html/modal/edit_alert_transport.inc.php
misc/db_schema.yaml`

2020-07-03 10_57_42-LibreNMS

Time selection is now fixed.

To apply the last version of the patch:

echo y | ./scripts/github-remove -d; ./scripts/github-apply 11622

Could you also test the feature ? i.e. no alert transport outside timerange and alert OK during timerange

@1soproni please test the feature

Hi @louis!

I’m on it. Please give me some days as I’m a little busy

Hello @1soproni any news on the test ?

Remark:

Start timerange hour should be stricly inferior to end timerange

Well, what about the night shifts?

I don’t know the reason yet but I don’t get any alert at all.
I can see the device marked with red among the devices, I can also see in the alert history but that’s it. Invesigation ongoing.