Page 1 of 2
How to get the IP where come the nrpe_check
Posted: Tue Sep 25, 2018 7:35 pm
by steph007
Hi,
I have 2 IP on server.
From Nagios XI, I configure the check_nrpe to run the same service on the 2 IP of my remote server
On the remonte server, how can I get from the launched script which IP was used by check_nrpe?
Depending of which IP my script will do different check.
this is the test I would like to have in Nagios XI
check_nrpe -H 192.168.1.1 -c test
check_nrpe -H 192.168.1.2 -c test
And test on the remote server should be doing a different action if it's coming for 192.168.1.1 or for 192.168.1.2
Re: How to get the IP where come the nope_check
Posted: Wed Sep 26, 2018 8:53 am
by lmiltchev
You cannot have two different commands with the same name (test), defined on the remote box in the nrpe.cfg file... This is not going to work. You will need to define two separate commands, e.g. "test1" and "test2". Then, you can run:
Code: Select all
check_nrpe -H 192.168.1.1 -c test1
check_nrpe -H 192.168.1.2 -c test2
from your Nagios XI server.
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 9:03 am
by steph007
I will have only one commande defined into nrpe.cfg.
But because my server is listening on 2 IP, nrpe_check can contact the server with each IP to execute the service.
Re: How to get the IP where come the nope_check
Posted: Wed Sep 26, 2018 9:22 am
by lmiltchev
But because my server is listening on 2 IP, nrpe_check can contact the server with each IP to execute the service.
It would help to know how the "test" command is defined on the remote machine.
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 9:29 am
by steph007
command[test]=/usr/local/NagiosIBM/plugins/test.pl
nrpe is listening on 2 IP and can be contacting by check_nrpe on both IP
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 9:45 am
by steph007
To give more detail:
From Nagios XI server:
root@plgesmon02[/usr]# ./local/nagios/libexec/check_nrpe -H 10.217.77.34 -p 1766 -c test
OK
root@plgesmon02[/usr]# ./local/nagios/libexec/check_nrpe -H 10.217.77.33 -p 1766 -c test
OK
10.217.77.33 and 10.217.77.34 are both IP of my Host caapedb301.
When test.pl is launched on caapedb301, I would like to determine if it hit by 10.217.77.33 or 10.217.77.34
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 9:54 am
by lmiltchev
I can't think of any way to pass the IP, used by NRPE to your script, other than passing it as an argument.
You command could be defined as such:
Code: Select all
command[test]=/usr/local/NagiosIBM/plugins/test.pl $ARG1$
From the Nagios XI server, you could run:
Code: Select all
./check_nrpe -H 192.168.1.1 -c test -a '192.168.1.1'
./check_nrpe -H 192.168.1.2 -c test -a '192.168.1.2'
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 10:43 am
by steph007
I was afraid of that kind of answer.
My nrpe is configure to not using argument
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 11:07 am
by lmiltchev
I discussed the challenge with our developers, and I was told that using an argument would be the only way to do that. We can leave the topic open for the time being, just in case someone from the Nagios community comes up with a more creative solution. After a while, topic will "auto-close" though. Thanks!
Re: How to get the IP where come the nrpe_check
Posted: Wed Sep 26, 2018 11:27 am
by steph007
Thank you!