3

I was wondering if there's a possibility that Nagios could stop monitoring a host if it's OFF, and turn monitoring ON when it's ON?

The idea was to use my Nagios server that will monitor if a CLIENTserver is OFF through a script which uses an API, and if the CLIENTserver is off it'll auto-remove its monitoring on it, But if the server is ON it'll re-install the monitoring automatically into the templates,

The reason I need it is because there are hourly CLIENTservers that we need to monitor as well, and when the hourly servers are off it's SPAMMING US with alerts.

I know there are better ways for it; I welcome every solution.

user35042
  • 2,601
  • 10
  • 32
  • 57
dotzek
  • 31
  • 1
  • 1
    It's hard to tell remotely if a machine is off or if it is on but not responding for some other reason. And even if you could tell it isn't the right thing to be looking for in the monitoring. It's import to distinguish between the machine is off and the machine is supposed to be off. If there is a discrepancy between those two you want to be alerted. So I recommend you switch the focus to answering the question on whether the machine is supposed to be on or off at the current time. – kasperd Nov 12 '18 at 12:29
  • Hello kasperd, Thanks for the answer, regarding your question, Hourly servers are not managed, so if this servers are OFF it's not our responsibility. So this question is already figured out =). If anyone else can help with an answer it will be great, Thank you. – dotzek Nov 12 '18 at 13:22

2 Answers2

1

What I love about Nagios is the framework provides enough tools to solve complex monitoring problems. This is more of an approach on how to accomplish this, rather than a solution.

As @kasperd notes above, Nagios doesn't have a mechanism to determine whether a host is turned on/off vs. broken. If you can script a way to determine whether a host "should be on", then this approach will work.

Nagios supports the idea of host and/or service dependencies. The idea being that a host or service isn't considered down if one of the dependencies is down. Given that, you could:

  • Define the client host "A" you need to monitor

  • Define a "on/Off" host "B" that will be used to determine if the host is off

    • Develop a custom check script that can determine if the host is On/Off. Have it be critical if the host is off. normal if on.
  • Make Host "A" dependent on Host "B"

With this config, notification for Host A will only be processed if Host "B" is normal. See Host Dependency in the documentation. As an alternative, you could do this with a custom host check that determines both the "should be on" state and the actual state and returned the correct status.

uSlackr
  • 6,337
  • 21
  • 36
1

You can't easily monitor the host if it's going to be on/off at uncertain times, but you could still monitor the services on the host.

If you don't enable host notifications, you won't get notified when the host goes down/up, and the service notifications will be suppressed when the host is down. This means you'll get service notifications when the host is up, but nothing when the host is down. The web interface will look like a mess, but the notification logic would work.

Alternatively, you can use passive checks (instead of active checks), and just have the host submit service check results on some schedule (e.g., via cron).

To really achieve what you specifically asked about (auto-removing monitoring of a host when it's off) would require use of adaptive monitoring, which is a rather advanced topic.

Keith
  • 4,627
  • 14
  • 25