Advanced servicedependency configuration

Hi Forum,

I’m using Nagios 3.0.6 with nrpe.
I’m about to setup NRPE service dependencies and would like to know the best way to do this.

for a test i have configured the below and it works great, and ofcause i could just make these servicedependencies for every host.

NRPE dependencies

define servicedependency{
host_name host1

hostgroup_name hostgroup1

   service_description             NRPE
   dependent_host_name             host1

dependent_host_name $HOSTNAME$

   dependent_service_description   Current Users,Free Space,HW info,Health,High CPU Load,Log file,NFS client stats,NTP stratum,Pdflush Processes,RAID,Swap Space,Temps,Zombie Processes
   execution_failure_criteria      w,u,c,p
   notification_failure_criteria   w,u,c,p
   }

My only problem is that we have —A LOT— of hosts so this is not an option :slight_smile:
I am aware of the -u option to check_nrpe but a combination of only running some checks once every day and automated powermanagement makes this no option either.
It would be nice if i somehow could get the functionality of the commented lines:

hostgroup_name hostgroup1

dependent_host_name $HOSTNAME$

so for each host in hostgroup1 all the “dependent_service_descriptions” services are dependent on NRPE in this specific host.
so if “hostgroup1” contains host1 and host2, “Current Users” on host1 will be dependent on NRPE on host1 but not dependent on NRPE on host2…

Is there a way to do this or do i need to make a hack and put an entry in the wishlist ?

Thanks in advance
~maymann

Anyone :slight_smile: ?

Thanks in advance !

How many hosts roughly do you have?
Is it not an option cus its a pain to write the config?

If I understand what you are trying to do correctly, I also had this problem but to my knowledge (correct me if I’m wrong anyone) it can’t be done by defining the servicedependency the way you would like.

Heres how I suggest you do it:
I assume you have all of your hosts defined somewhere within nagios so grep those files to get a list of all your hosts and put it in a file.
Take the hosts list and put it into the hosts variable in a script something like this:
#! /bin/csh -f
#set variables
set hosts = "Host1 Host2 Host3"
set sdir = /usr/local/nagios/etc/objects
touch $sdir/dependencies.cfg
foreach host ($hosts)

Create file to add entires for all Hosts and Dependencies

    echo "#++++++++++++++++++++++++++++++++" >> $sdir/dependencies.cfg
    echo "# $host" >> $sdir/dependencies.cfg
    echo "#++++++++++++++++++++++++++++++++" >> $sdir/dependencies.cfg
    echo "define servicedependency{" >> $sdir/dependencies.cfg
    echo "host_name                         $host" >> $sdir/dependencies.cfg
    echo "service_description               NRPE" >> $sdir/dependencies.cfg
    echo "dependent_host_name               $host" >> $sdir/dependencies.cfg
    echo "dependent_service_description             Current Users,Free Space,HW info,Health,High CPU Load,Log file,NFS client stats,NTP stratum,Pdflush Processes,RAID,Swap Space,Temps,Zombie Processes" >> $sdir/dependencies.cfg
    echo "notification_failure_criteria     w,u,c,p" >> $sdir/dependencies.cfg
    echo "execution_failure_criteria                w,u,c,p" >> $sdir/dependencies.cfg
    echo "}" >> $sdir/dependencies.cfg
    echo " " >> $sdir/dependencies.cfg
    echo " " >> $sdir/dependencies.cfg

end

Dear Lonestar,

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.