Service Dependency Question

I have a number of things that I check on remotely on a system via ssh. When ssh fails, which it does occasionally, I would like to just be notified about ssh being down and not about all of the other services that depend on ssh for checks.

I am running Nagios 3.0.3 (recently upgraded from 2.9) on an OpenSuSE Linux computer. Here is a section of the config file that I had hoped would only page me if “SSH” or “Root Partition” had problems, but not page me about “Root Partition” if “SSH” is critical:

define service {
use local-service
service_description SSH
check_command check_ssh
event_handler notify-service-by-email
event_handler_enabled 1
host_name foobar
contact_groups admins
}

define service {
use local-service
service_description Root Partition
check_command check_remote_disk!20%!10%!/
event_handler notify-service-by-email
host_name foobar
contact_groups admins
}

define servicedependency{
host_name foobar
service_description SSH
dependent_host_name foobar
dependent_service_description Root Partition
execution_failure_criteria u,c
notification_failure_criteria u,c
}

This configuration, unfortunately doesn’t work.

Any help on this configuration problem would be greatly appreciated.

TIA

That happens because you have defined the commands notify-service-by-email as event_handlers. Event handlers are used, for example, as a quickfix of a problem with the service or a host. It is a command which is issued whenever a soft or a hard state change of a service or a host has occured. As you can see in documentation:
nagios.sourceforge.net/docs/3_0/ … dlers.html
So, every time either of your two services change it’s states, then a notification is issued as you have specified.

You don’t have to make notify-service-by-email commands as event_handlers.
Notification commands are defined in contacts.cfg, or wherever you define your contacts for Nagios. As you can see here:
nagios.sourceforge.net/docs/3_0/ … ml#contact

After you remove your event_hadlers from service definitions, your service dependency should work.

Albin,

Thanks very much. I really appreciate your advice and it led me to notice that my Nagios conifguration was a mess.

Thus, I started with a new installation, didn’t define “notify-service-by-email” as an event handler and I’m still having what seems to be the same problem.

Here’s a snippet of my new config file:

define service{
use local-service ; Name of service template to use
host_name foobar
service_description SSH
check_command check_ssh
notifications_enabled 1
}

define service{
use local-service ; Name of service template to use
host_name foobar
service_description Root Partition
check_command check_remote_disk!15%!10%!/
}

define servicedependency{
host_name foobar
service_description SSH
dependent_host_name foobar
dependent_service_description Root Partition, Current Users, Total Processes, Current Load, Mail Queue, Swap Usage
execution_failure_criteria u,c
notification_failure_criteria u,c
}

The dependent services, in this case, are all checked via ssh and if I disable ssh on the machine being monitored, I get an e-mail message for each service that can’t be checked.

When ssh isn’t running, the state of these processes is always “UNKNOWN”. Is there an easy way to disable notifications for certain services if their state becomes unknown.

Thanks very much.

It seems that changin the line:

host_notification_options d,u,r,f,s

in the notification section of templates.cfg

to:
host_notification_options d,r,f,s

Had the desired effect of only notifying me about the ssh service being down.

Thanks again, Albin.