Conditional services


#1

Hey guys,

I’m setting up Nagios to monitor a bunch of services on approx 750 servers and have run into a small problem I’d like to gracefully fix.

All our servers run a backup tool which backups everything to a third party backup solution and these guys have a few proceses running such as a backup scheduler etc.

Unfortunately, they decided, somewhere along the way to change the process name. So we have the issue that our oldest servers have process
backupmanager1
and the newer servers run the updated client
backupmanager2

There is essentially nothing different between the clients or their functionality so upgrading the old servers is not necessary and frankly too much of a hassle.

I was wondering if there is a way to define conditional services in Nagios, say something like this:
A service which does nothing, only being dependant on two other services and if tiether of those two services are functioning the master service flags as OK
something like this:

define service{
use generic-service
service_description backup
depends_on backup1, backup2
host_name something
}

define service{
use generic-service
service_description backup1
host_name inherit
check_command check_nrpe!check_backup1
}

define service{
use generic-service
service_description backup2
host_name inherit
check_command check_nrpe!check_backup2
}

The idea would be that service backup would flag as OK if either backup1 or backup2 return OK.

Now I know services can have dependencies but that would only mean the the depending services won’t bother to check if the service they depend on is in critical state, which is not what I want here.

Does anyone know if and how this can be acheived?


#2

Hi!

excellent question, and quite a weird way to do that:)
anyway, from my experience, you can’t rely on nagios dependencies (too many things can go wrong with these :)).

So, here is an alternative: can’t you modify your script behind “check_backup” so that the result depends on what the scripts finds.

ex: let’s say you’re calling check_process
instead, write a little script that would call check_process and look for the process “backupmanager1”; if it finds it, great => exit 0
if it doesn’t find it, call again check_process, but with “backupmanager2” as its argument…

that’s what I would do :slight_smile: (or, depending on the ratio of old servers and new servers, you can first search for “backupmanager2”)

hope this helps a bit :slight_smile:


#3

Yes I had thought of that, the problem is that then the script gets a lot more complicated as I need to check for more possible combinations of things going wrong.

I really do think that conditional services would be a good feature for nagio sthough.

Picture that you two samba shares accessed through DFS. When one link goes down, you do want to get a message telling you: ay, link down but you don’t neccesarily want the service DFS flagged as down since it is still operational.

You’d basicaly need a service that can be composed by different other services, almost like servicegroups but not quite that.

Anyhow, thanks for the response, I’ll just have to expand my script a bit.


#4

hi!

quite funny you should mention this example, as that’s typically what we are doing:
we wrote a script that checks a link, then tests the other.

From the results, we do:
if 1 link is down => exit WARNING
if 2 are down => exit CRITICAL
(if 0 are down => exit OK)

but still, I keep on forgetting that we have some constraints (like creating a minimum of tests).
Anyway, as conditional tests do not exist in nagios (as far as I know anyway), there are not many solutions :))


#5

Dear Loose,

I’m afraid that Service Dependencies won’t work as expected. Take a look at:

viewtopic.php?f=59&t=5104&p=16828&hilit=dependencies#p16828

Hope it helps.