How to get the IP where come the nrpe_check

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
steph007
Posts: 177
Joined: Mon Jul 24, 2017 12:00 pm

How to get the IP where come the nrpe_check

Post 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
Last edited by steph007 on Wed Sep 26, 2018 9:31 am, edited 1 time in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to get the IP where come the nope_check

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
steph007
Posts: 177
Joined: Mon Jul 24, 2017 12:00 pm

Re: How to get the IP where come the nrpe_check

Post 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.
Last edited by steph007 on Wed Sep 26, 2018 9:32 am, edited 1 time in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to get the IP where come the nope_check

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
steph007
Posts: 177
Joined: Mon Jul 24, 2017 12:00 pm

Re: How to get the IP where come the nrpe_check

Post 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
steph007
Posts: 177
Joined: Mon Jul 24, 2017 12:00 pm

Re: How to get the IP where come the nrpe_check

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to get the IP where come the nrpe_check

Post 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'
Be sure to check out our Knowledgebase for helpful articles and solutions!
steph007
Posts: 177
Joined: Mon Jul 24, 2017 12:00 pm

Re: How to get the IP where come the nrpe_check

Post by steph007 »

I was afraid of that kind of answer.
My nrpe is configure to not using argument
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to get the IP where come the nrpe_check

Post 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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
steph007
Posts: 177
Joined: Mon Jul 24, 2017 12:00 pm

Re: How to get the IP where come the nrpe_check

Post by steph007 »

Thank you!
Locked