understanding $ARG$ variables
Posted: Sat Aug 18, 2012 10:54 pm
As my journey continues, I want to check some apache stats on a different IP / port than the host. So I created a command for each webserver and things are working, but I want to keep things clean and want to understand how the variables are assigned. My example commands are;
# 'check apache' command ws1
define command{
command_name check_apache-ws1
command_line /usr/lib/nagios/plugins/check_apache2.sh -H 1.1.1.1 -P 81 -t 3 -b /usr/sbin -p /var/run
}
# 'check apache' command ws2
define command{
command_name check_apache-ws2
command_line /usr/lib/nagios/plugins/check_apache2.sh -H 1.1.1.1 -P 82 -t 3 -b /usr/sbin -p /var/run
}
Now I have 7 webservers, then some tomcat ones (which I bet will have more questions)
but rather than 7 of these, I look higher up at some default ones and see a sample like command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
So I would like to do the same. The IP used will be the same (not the one in the define host) and the port changes (not the one in the _tcpport in the host definition), so my question is how/where can I define a variable so I can have one command, then when I define the service, I can say use_hostgroup webservers and have that port auto inserted vs 7 commands for each server.
Tnx
# 'check apache' command ws1
define command{
command_name check_apache-ws1
command_line /usr/lib/nagios/plugins/check_apache2.sh -H 1.1.1.1 -P 81 -t 3 -b /usr/sbin -p /var/run
}
# 'check apache' command ws2
define command{
command_name check_apache-ws2
command_line /usr/lib/nagios/plugins/check_apache2.sh -H 1.1.1.1 -P 82 -t 3 -b /usr/sbin -p /var/run
}
Now I have 7 webservers, then some tomcat ones (which I bet will have more questions)
So I would like to do the same. The IP used will be the same (not the one in the define host) and the port changes (not the one in the _tcpport in the host definition), so my question is how/where can I define a variable so I can have one command, then when I define the service, I can say use_hostgroup webservers and have that port auto inserted vs 7 commands for each server.
Tnx