Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When defining and testing new services in nagios I have been restarting nagios, then clicking the service, and rescheduling a check for as soon as possible, then waiting until the check happens.

Is there a more efficient way to do this? I'd like to use the command line to run that particular check and get the output.

share|improve this question
add comment

4 Answers 4

up vote 9 down vote accepted

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.

share|improve this answer
    
awesome. this is more along the lines of what i meant. just because i had already looked in the commands.cfg file to figure out which commands were running, but i wanted to know what flags were being set. thanks! :) –  cwd Dec 12 '11 at 2:37
1  
I will also menton for new users that using tail -f will allow you to continue seeing updates to the file in real time, and control+c will cancel this. –  cwd Apr 21 '12 at 1:19
add comment

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: http://exchange.nagios.org/directory/Plugins, 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 viola!

share|improve this answer
    
+1 ...and if that seems like too much trouble you could always look at the Nagios config files to see what command and parameters need to be run. Even the location of the plugins directory is in there. –  John Gardeniers Dec 12 '11 at 1:20
    
And keep in mind that always do it with nagios user su - nagios -s /bin/bash. –  quanta Dec 12 '11 at 1:38
    
nice. and the - loads the environmental variables for that user? –  cwd Dec 12 '11 at 2:35
    
Yup, just like any other linux flag, the "-" with whatever flags you use will load the flag. (If I were running df -h on the linux CLI, I'm using the "h" flag - in the case of the df command, the h stands for "human readable".) So if you wanted to run the check_http check from the CLI, you would run ./check_http -I, where the I flag stands for the IP Address (nagiosplugins.org/man/check_http). nagiosplugins.org/man might be helpful, as well as the Plugins directory I linked to earlier. –  David W Dec 12 '11 at 22:49
add comment

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.

http://www.waggy.at/nagios/capture_plugin.htm

share|improve this answer
1  
I struggled to get this to work, not sure what i was doing wrong (noob) but the debug_level trick worked for me :) –  sbditto85 Nov 13 '12 at 17:41
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.