LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   nagios, same command for multiple hosts (https://www.linuxquestions.org/questions/linux-software-2/nagios-same-command-for-multiple-hosts-566557/)

muha 07-04-2007 06:27 AM

nagios, same command for multiple hosts
 
Hi, I was wondering if it is possible in Nagios (monitoring software) to define a command to run for multiple hosts in one go.
The normal way is to write a stanza for each host. Since all my hosts and commands are the same I would like to define a group of hosts to which apply the same monitor-command. Is that possible? How?
If possible I would like to avoid plugins or extensions.

chrism01 07-04-2007 06:55 AM

I assume you mean you use the same cmds/checks for all hosts (you can't have all the 'same hosts' ;-) )
Anyway, create a stanza for each cmd for 1 host, then write a short script to cp the file for each extra host and substitute eg via sed, the name of each host, then concat the files together eg:
cat host1.cfg host2.cfg ... >> hosts.cfg

muha 07-04-2007 07:08 AM

Thanks for the try. But I found out it can be done with the hostgroup_name definition in nagios. Or you can use a comma-separated list of multiple hosts in host_name.

So /etc/nagios/services.cfg would look something like this:
Code:

define service{
    use    generic-service
    host_name      host1,host2
    service_description      ping
<SNIP>
    check_command      check_ping!100.0,20%!500.0,60%
    }

Or use the definition hostgroup_name instead of host_name:
Code:

define service{
    use    generic-service
    hostgroup_name      group1,group2
    service_description      ping
<SNIP>
    check_command      check_ping!100.0,20%!500.0,60%
    }

Then you also have to define hostgroups in /etc/nagios/hostgroups.cfg


All times are GMT -5. The time now is 07:45 AM.