Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We're using nagios to watch our servers health. Now we have a task to add server which will be up only for certain time. And during that time we have to ensure that all services are up and running. Unfortunately we don't know when will be the host down. So we need some automatic way to achieve this.

  1. Is there a way (configuration directive) to not report if host goes down. I mean even in nagios clients like nagstamon. I don't like the idea of black icon in systray all day.
  2. Is there a way to not report any of services running on a host, while the host is down?
  3. While achieving points 1. and 2. is there a way to monitor all host services when and only when the host is up?
share|improve this question
Why on earth are you monitoring a server that is down at completely random times? –  VxJasonxV Dec 18 '10 at 19:52
Batch e-mail sending, on-demand web server which covers request spikes, backup server (there is known startup time, but unknown shutdown time). And many other cases. We need to be sure, that the mail daemon, apache, or rsync service is doing its job. –  Michal Bryxí Dec 18 '10 at 21:55
But you can't know if the lack of host is due to it being down deliberately or otherwise, so why would you ever want to monitor it? –  womble Aug 24 '11 at 9:02

5 Answers 5

up vote 3 down vote accepted

Let me take the points in the wrong order.

2) NAGIOS should already do this; if a host is down, service alerts will not be sent.

1) I was thinking you could do this with flexible downtime: this is downtime of a given window duration which doesn't start at a known time; instead, the window starts automatically when the host goes down.

But then it occurred to me: all you really need to do is send no alerts when the host is down. If you manage that, then

  • When the host is down, service alerts will not be sent. You don't care that the host is down, because as you say, you don't know when it'll come and go, so the absence of a host alert is immaterial. The HOST DOWN will still be logged, allowing you to retrospectively see what has gone on, but alerts will not be sent.

  • When the host is up, service alerts will be sent anyway.

That's what you want, isn't it? If so, you need to add to the host definition

notification_options   n

I think that's also dealt with problem 3, as that's what happens normally. I can't speak for non-core clients like nagstamon. In my experience, these are usually screen-scrapers, and their decisions about what to notify aren't based on NAGIOS' notification logic. If your client honours NAGIOS' built-in rules, it should be fine; otherwise, you'll have to work with that particular tool to add a similar logic.

share|improve this answer
This seems right. With this option set, there are no notifications from nagios. But I had to change settings in nagstamon and enable Acknowledged hosts & services and Services on down hosts. Still it is pity that nagios can't be forced to just ignore those down hosts. –  Michal Bryxí Dec 18 '10 at 22:16
I will wait few days for better solution and possibly mark your answer as the right one. –  Michal Bryxí Dec 18 '10 at 22:16

You can define custom time periods using the timeperiod definition in your timeperiods.cfg. Here is an example

# Here is a slightly friendlier period during work hours
define timeperiod{
    timeperiod_name workhours
    alias           Standard Work Hours
    monday          09:00-17:00
    tuesday         09:00-17:00
    wednesday       09:00-17:00
    thursday        09:00-17:00
    friday          09:00-17:00

Then use this for the check_period value in your host and service definitions.

share|improve this answer
Seems I will have to rephrase my question. The time when the host will be up/down is absolutely random. And we will have more of them soon. So I need automatic solution for this. –  Michal Bryxí Dec 18 '10 at 19:38
For that you would want to look at using external commands to enable/disable checks for the host and service. See the documentation here nagios.sourceforge.net/docs/3_0/extcommands.html and old.nagios.org/developerinfo/externalcommands/commandlist.php. Another solution would be to use passive checks submitted by the host itself rather then active checks from the nagios monitor. –  slillibri Dec 18 '10 at 20:01
You should submit your ideas for passive check results as another answer. That's seriously a wonderful idea. –  VxJasonxV Dec 18 '10 at 20:08

This answer will not cover third-party monitoring addins like nagstamon or the firefox nagios plugin, because it will vary wildly.

A few ways that I can think of off the top of my head:

  • Disable host checks for the server. However, this will leave the host in a permanent state of "UP", and services will begin to alert.
  • Constantly set floating downtime. Floating downtime starts the next time the host is seen "DOWN" and runs for the duration you specify. You could perhaps do this with a cronjob issuing the "SCHEDULE_HOST_DOWNTIME" for 2 floating hours every two hours. ( See NAGIOS Developer - External Commands ).
  • Schedule downtime for the host and all services (see above link).

  • What you could also do is put service dependencies to use. If you check the host via PING, then add a PING service, and a service_dependency for all other services on that host to depend on PING, and then shut the ping notifications off. This will look something like;

define servicedependency {
dependent_host_name flaky_biscuit
dependent_service_description service1, service2, service3, service4, service5 host_name flaky_biscuit
service_description PING
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c

What this means in essence is that when PING is in warning, unknown or critical, PING will notify, none of the dependent services will. (And again, shut notifications off for PING!) Also, when PING is in warning, unknown, or critical state, the dependent services will not even execute.

I can't speak for NagStaMon, but the Firefox NAGIOS plugin has preferences that essentially says "ignore acknowledged services", meaning that if you acknowledge or schedule a service in downtime, have notifications off, or any other modification to a service, it will not render as "warning/critical" in the status bar even if it's in that state. I don't know what NagStaMon does or doesn't have in this manner.

share|improve this answer
Ugh. I can't get that configuration block to format :/. Also, slillibri's recommendation for passive checking is actually a seriously great idea. I can't believe I didn't think about that. –  VxJasonxV Dec 18 '10 at 20:08

Here is my idea for using passive checks for this, but I need to state an assumptions first. That you don't want to monitor host uptime at all. Just that when the host is up, that the appropriate services are running.

On your random uptime hosts, you can run something like the following shell script https://gist.github.com/746998. This example would monitor SMTP but it's fairly simple. You will need to have this run as a user that can ssh into your nagios host using a keypair, and securing that is left as an exercise to the reader (or post a new question). I haven't tested this but it should work. The Passive check documentation ( http://nagios.sourceforge.net/docs/3_0/passivechecks.html ) should be helpful.

This won't automate provisioning the hosts on your Nagios server, but you can use something like puppet for that.

share|improve this answer

For alerting you should check out Nagios BPI (Business Process Intelegence) Nagios Enterprises just released this new addon. go to Nagios dot come, and check out there roadmap.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.