This is a cache of https://support.nagios.com/kb/article/nagios-xi-how-to-test-check-commands-from-the-command-line-167.html. It is a snapshot of the page at 2025-05-14T00:09:05.400+0000.
Nagios <strong>xi</strong> - How To Test Check Commands From The Command-line
Home » Categories » Multiple Categories

Nagios xi - How To Test Check Commands From The Command-line

Overview

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:

  • PHP character escaping for special characters
  • It is executed as the apache user instead of the nagios user

Due to these limitation, testing some check commands really need to be done at the command line as the nagios user.

 

Determining Check Command

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

  • If these fields are empty, the command and values are being inherited by a template
  • Click the Manage Templates button and make note of the template being used
  • Now, in the left sidebar again, click Templates > Service templates, and find any that were listed on the previous step
  • Make 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:

  • I have a host called Server Room, with an IP address of 192.168.5.254 and it has a simple ping check
  • For Check command and Command view they're blank and for templates it has xiwizard_websensor_ping_service
  • The template for xiwizard_websensor_ping_service has a Check command of check_xi_service_ping and a Command view of:
    • $USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$,$ARG2$ -c $ARG3$,$ARG4$ $ARG5$
  • With the arguments:
    • $ARG1$ = 3000.0
    • $ARG2$ = 80%
    • $ARG3$ = 5000.0
    • $ARG4$ = 100%
    • $ARG5$ = -p 8

 

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 :

  • /usr/local/nagios/libexec/check_icmp -H 192.168.5.254 -w $ARG1$,$ARG2$ -c $ARG3$,$ARG4$ $ARG5$

 

All you need to do is match up the $variables$ with the values from the fields:

  • /usr/local/nagios/libexec/check_icmp -H 192.168.5.254 -w 3000.0,80% -c 5000.0,100% -p 8

 

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:

Type:

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.

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/



Special Offer For Knowledgebase Visitors! Get a huge discount on Nagios Log Server by clicking below.

Get 60% Off Nagios Log Server!

Did you know? Nagios provides complete monitoring of: Windows, Linux, UNIX, Servers, Websites, SNMP, DHCP, DNS, Email, Storage, Files, Apache, IIS, EC2, and more!

1.8 (5)
Article Rating (5 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
OpenSSL causes issue with check_nrpe plugin with NSClient++
Viewed 9396 times since Fri, Apr 30, 2021
Nagios xi - Nagios Rapid Deployment Options - NWC14
Viewed 4934 times since Tue, Feb 9, 2016
Parent/Child Host Relationships
Viewed 9058 times since Mon, Jun 28, 2021
Nagios xi - Configuration Applies, No Changes Take Place
Viewed 8683 times since Tue, Jan 27, 2015
Nagios xi - Modifying The Contents Of /usr/local/nagios/etc
Viewed 7249 times since Tue, Jan 26, 2016
Nagios xi - How To Achieve High Availability
Viewed 12050 times since Wed, Jan 27, 2016
Nagios xi - Reset Upgrade Status In Web Interface
Viewed 11692 times since Tue, May 7, 2019
Nagios xi - Hosts Pending/Gray
Viewed 12137 times since Tue, Jan 6, 2015
Nagios xi - Some BPI Checks Show "Unknown BPI Group Index" After Upgrade
Viewed 4585 times since Wed, Sep 18, 2019
Disabling Port 113 IDENT Requests
Viewed 6030 times since Tue, Mar 12, 2019