Page 1 of 1

Monitor host A from host B through Nagios XI command

Posted: Fri Apr 24, 2020 9:35 am
by errevi
Hello,

I would like to implement a check that can ping host B from host A (both are Windows Server) through a check command sent by Nagios XI.

I saw something about nsclient++, can you help me to figure out what should I do in order to have:
  • - command from Nagios XI e.g. check_hostB_through_hostA
    - hostA receive the command and execute a ping to hostB
    - the results are shown in Nagios XI interface
In this way I can see if host A is correctly pinging host B and eventually see ping latency between the two hosts.
Thanks
Nicolò

Re: Monitor host A from host B through Nagios XI command

Posted: Fri Apr 24, 2020 2:06 pm
by ssax
If you only really care about ping, setup NRPE in your nsclient.ini and enable CheckSystem/CheckNet on Host A:

Code: Select all

[/modules]
; Undocumented key
CheckExternalScripts = enabled

; Undocumented key
CheckHelpers = enabled

; CheckLogFile - File for checking log files and various other forms of updating text files
CheckLogFile = enabled

; Undocumented key
CheckEventLog = enabled

; Undocumented key
CheckNSCP = enabled

; Undocumented key
CheckDisk = enabled

; Undocumented key
CheckNet = enabled

; Undocumented key
CheckSystem = enabled

; Undocumented key
NSClientServer = enabled

; Undocumented key
NRPEServer = enabled

Code: Select all

[/settings/NRPE/server]

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = true

; ALLOW INSECURE CHIPHERS and ENCRYPTION - Only enable this if you are using legacy check_nrpe client.
insecure = true

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true

; EXTENDED RESPONSE - Send more then 1 return packet to allow response to go beyond payload size (requires modified client if legacy is true this defaults to false).
extended response = true

; PORT NUMBER - Port to use for NRPE.
port = 5666

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true
Then restart the NSClient++ service.

Now test from the XI system like this:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H HostA -c check_ping -a 'host=HostB'
You can also do more if you setup NSClient++ on HostB as well.

Re: Monitor host A from host B through Nagios XI command

Posted: Mon Apr 27, 2020 7:39 am
by errevi
Hi, many thanks for your answer, yes at the moment I only need a ping.
The other step I did in order to bypass all SSL handshake errors are:
-

Code: Select all

insecure = true
-

Code: Select all

;verify mode = peer-cert
Edited check_nrpe command in nagios to:

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -2 -t 30 -c $ARG1$ $ARG2$
Is evertything right with this changes ?
I mean it works, but I don't know if it's best practice.

In the end my command is:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H HOST-A_FQDN -2 -t 30 -c check_ping -a 'host=HOST-B_FQDN'
And this is the output:

Code: Select all

OK: All 1 hosts are ok|'HOST-A_FQDN_loss'=0;5;10 'HOST-B_FQDN_time'=0;60;100
I don't understand what's the "_loss" and the "_time" means , from GUI I only have this output (image below)

And I would like to have the response time in my output, is that possible ?

Re: Monitor host A from host B through Nagios XI command

Posted: Mon Apr 27, 2020 4:18 pm
by ssax
That looks fine.

loss is the percentage of packets lost.

time is the total time in seconds.

You can see the defaults this way:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H HOST-A_FQDN -2 -t 30 -c check_ping -a 'host=HOST-B_FQDN' show-default
See here as well:

https://docs.nsclient.org/reference/misc/CheckNet/

Re: Monitor host A from host B through Nagios XI command

Posted: Tue Apr 28, 2020 2:31 am
by errevi
Hi, thanks again, it works.
I changed the packet size and added

Code: Select all

$ARG3$
set it to "show-all" and I have all the info I need, output:
OK: 1/1 (<ip_address> Packet loss = 0%, RTA = 0ms)

Thanks
Regards

Re: Monitor host A from host B through Nagios XI command

Posted: Tue Apr 28, 2020 12:27 pm
by ssax
Awesome, glad you got it working! Are we okay to lock this up and mark it as resolved or do you have any related questions?

Re: Monitor host A from host B through Nagios XI command

Posted: Wed Apr 29, 2020 5:42 am
by errevi
Yes, I'm ok, you can close the topic.

Nic