Device in Maintenance, but Devices API Call Shows Device "Down"

  1. I scheduled several devices to be in “Maintenance” using the Scheduled Maintenance feature.
  2. Devices are “Healthy” prior to maintenance window.
  3. Maintenance window starts and the devices are shutdown (or whatever).
  4. Using the LibreNMS API to query for Device Status.
    4a. curl -H “X-Auth-Token: keyhttp://librenms.some.place.com/api/v0/devices?type=down
    4b. Device status is shown as being “DOWN” because of ICMP.
    4c. No rules have run because the device is in a scheduled maintenance window.

My question(s) is/are this:
Why is the device status being changed by the ICMP check when the device is in a scheduled maintenance window? I.e. Shouldn’t the check be disabled when the device in in the scheduled maintenance window? Or did I miss something in the interface that when I schedule maintenance, I need to check another box that also disables the ICMP check?

Any insight would be great.
Thanks!

Maintenance windows only affect alerts they do not change data or polling.

Okay, then is there a better method via the API to determine what devices are in a down status that are not in a maintenance window or in a muted state?

So far, the closest I’ve gotten is to use the /devices?type=down flag, but the device.status gets changed by the ICMP check that still runs even though the rules are suppressed.

You probably need to get the maintenances window via an API and check that.

Not sure if that is available, so you might need to put in a feature request or code it yourself.

Yeah, there isn’t any API documentation for the Maintenance Window API.

In the meantime, how feasible does this approach sound (not sure if its even possible), but could the “includes/polling/functions.inc.php” file be modified to add a Maintenance Window check? I “think” I’ve run across the SQL code in the forums that can query the Maintenance table. So the check could be rewritten so that it doesn’t update the device.state…?

Here’s the link to the github page for the ICMP check:
https://gitlab.ctwug.za.net/librenms/librenms/commit/820afa6dbb28a48eadc19ac698f30a807a89fa97

I will also take your advise and will post a feature request shortly.

Thanks.

imho we shouldn’t disable polling for devices that are in maintenance windows as they could be up and the snmp/icmp check at poll time is trivial to perform.

I understand your perspective, but since the device.status is being changed by the ICMP test, the value of the device API call is almost worthless because it technically isn’t accurate anymore. In other words, the device is being worked on (so it could be either up or down), which is also a “planned for condition” by the very nature of Scheduled Maintenance. But since the ICMP test is changing the device to “down” we’re getting a false positive for device.status. I.e. we only want to return results for devices that are NOT in Scheduled Maintenance and are in a “down” status.

Is there maybe another way to retrieve device information for “down” devices that are not in maintenance mode? (Relatedly, I just posted in the feature request forum. Maybe prematurely?)

The best way to do this is return another boolean to say if it’s in maintenance or not via the API.

Um, that sounds like an excellent idea, but maintenance isn’t documented in the API manual, nor is how to return another Boolean. You wouldn’t happen to have any hints or examples handy, would you? I can probably puzzle it out, but I’m not sure where to start…

It will need some thought really as that will add a large number of additional queries to get that data. I’m not sure how best to approach it at the moment.