How can I manually run a nagios check from the command line?

Solution 1:

Sometimes I find it tricky figuring out exactly what a plugin is doing. To figure this out I set nagios into debug mode with the configuration like this. debug_level=2048 With nagios in debug mode I simply tail the debug_log file debug_file=/var/log/nagios3/nagios.debug. Force a check and you will see exactly how the command is being run. I wouldn't leave this setting on normally though, it is very verbose and fills your log file at a rapid rate.

Solution 2:

It's pretty simple. Just cd (or not) into the plugins directory (this directory location varies, depending on how you've installed it, but check /usr/local/nagios, or /usr/lib/nagios).

Find the plugin you want to run (if you're not sure, compare what you see in your plugins directory on your Linux box with the plugins located here:, or try running "./plugin-name -h" to get the help info about the plugin).

The method for using any of these "plugins" from the command line is the same as any other Linux script: Just run "./plugin-name" with the appropriate flags you want to check, and voila!

Solution 3:

I take a slightly more brute-force direction than @Zoredache, I login to the nagios server and do "while true; do ps awwlx | grep NAGIOS_CHECK_NAME; done", while I force a re-check of the service, where NAGIOS_CHECK_NAME is either part of the check name or the IP of the server I am looking for. Usually within a few seconds the full check command pops up and I then kill the while loop and run the check command.

Yeah, it's totally brute-force, but <shrug> it works for me.

Solution 4:

You might also want to give the 'capture' plugin a try. It essentially does the same thing as a debug level of 2048, but can be used on a per-plugin basis. This yields less output to dig through.

Solution 5:

Go to your plugin directory - in my example it is


Type you plugin name - in my example it is


now run the full command - (plugin name) -H (hostname) -p (port number)

/usr/lib64/nagios/plugins/check_tcp -H myservername -p 8080


TCP OK - 0.004 second response time on port 8080|time=0.004146s;;;0.000000;10.000000

However in this example port number is optional

another example -

in your config file which is look something like below (myserver.cfg) and you want to run check_cpu from command line

define service{
  use                             generic-service
  host_name                       myserver
  servicegroups                   windows
  service_description             CPU
  contact_groups                  sysadmin_email_only
  notification_options            w,c,r
  check_command                   check_nrpe!check_cpu

to check instantly (without GUI green or red)

Try this - (plugin full path) - H (servername) -c (checkname)

/usr/lib64/nagios/plugins/check_nrpe -H spc7atc01 -c check_cpu

output -

OK CPU Load ok.|'5'=4;80;90; '10'=3;80;90; '15'=3;80;90;

Thats it