This guide explains how to test check commands from command line in Nagios XI.
While there is the Test Check Command button in Core Configuration Manager (CCM), this does not always work as expected due to:
Due to these limitation, testing some check commands really need to be done at the command line as the nagios user.
You will need to go through a few steps to establish what exactly is being run. Grab some paper to note settings as you go.
Start by going to Configure > Core Config Manager.
Under Monitoring > Services in the left sidebar, find the service in question, and click the crossed tools Configure icon.
On the Common Settings tab, note what it says for Command view and the values of the eight ARG variables
At this point you should now know what check command is used along with the variable values.
Now, starting with what you had for Command view, replace $USER1$ with /usr/local/nagios/libexec and replace $HOSTADDRESS$ with the IP address of the host this service is associated with.
As an example:
Now, starting with what you had for Command view, replace $USER1$ with /usr/local/nagios/libexec and replace $HOSTADDRESS$ with the IP address of the host this service is associated with which is 192.168.5.254 :
All you need to do is match up the $variables$ with the values from the fields:
That's your full check command.
Now, log into your Nagios XI server as root, either on a direct terminal or through SSH. Enclose your command in single quotes, put su -c before it and nagios after it, and hit enter. It should look something like this:
su -c '/usr/local/nagios/libexec/check_icmp -H 192.168.5.254 -w 3000.0,80% -c 5000.0,100% -p 8' nagios
This is the output message from running the command:
OK - 192.168.5.254: rta 50.903ms, lost 0%|rta=50.903ms;3000.000;5000.000;0; pl=0%;80;100;;
Obviously that will be filled in with different details based on the check you're trying to run, but hopefully that demonstrates the progression of how to build the line.
If you experience any errors, the errors should help you fix your check command. Once you've got the check command working from the command line, go back into CCM and update the relevant fields to resolve the problem.
For any support related questions please visit the Nagios Support Forums at:
Article ID: 167
Created On: Tue, Jan 26, 2016 at 10:15 PM
Last Updated On: Wed, Feb 17, 2016 at 7:25 PM
Authored by: tlea
Online URL: https://support.nagios.com/kb/article/nagios-xi-how-to-test-check-commands-from-the-command-line-167.html