multiple host with different arguments on one service

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
ron123456
Posts: 4
Joined: Wed Feb 04, 2015 7:06 am

multiple host with different arguments on one service

Post by ron123456 »

Hi All,

i have a question maybe you can help me with

i have for example :

2 hosts (host1,host2)
1 group (group1 - host1 and host2 are in the group)
1 service (serivce1 - is in the group1)

i want to use different args on different host in the service

lets say :
alert me when cpu is over 80 in host1
alert me when cpu is over 90 in host2
BUT on the same service1

Is it possible to do it without exclude one host and create a new service with the same command ( in a real world example it is very hard to maintain ) ?
If so what can i do ?

Thanks .

Example conf files:

Code: Select all

define host{
        use                generic-device
        host_name          host1
        address            127.0.0.1
        display_name       Servers
        hostgroups         group1
} 

define host{
        use                generic-device
        host_name          host2
        address            127.0.0.2
        display_name       Servers
        hostgroups         group1
}

define hostgroup{
        hostgroup_name  group1
        alias           group1
}

define service{
        use                     generic-service
		hostgroup_name	        group1        
        service_description     serivce1
        check_command           check_something!80!90
}
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: multiple host with different arguments on one service

Post by rkennedy »

You could use custom variables defined on each host, and then call to those variables in your check_command or command definition. See this link - https://assets.nagios.com/downloads/nag ... tvars.html

Code: Select all

define host {
    host_name       linuxserver
    _mac_address    00:06:5B:A6:AD:AA   ; <-- Custom MAC_ADDRESS variable
    _rack_number    R32                 ; <-- Custom RACK_NUMBER variable
    ...
}
For the _rack_number variable, you can use $_HOSTRACK_NUMBER$ as a substitute.
Former Nagios Employee
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: multiple host with different arguments on one service

Post by lmiltchev »

ron123456,
We are going to be deleting your other "multiple host with different arguments on one service" post from Wed Dec 07, 2016 10:16 am, as it is a duplicate.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked