Our company is consolidating our monitoring solutions (WUG, Cacti, Zabbix) to Nagios. I have used Zabbix for years, and am trying to understand how to get Nagios to report on applications that I have written Nagios scripts for.

The scripts have been written on the client and been put in the "/usr/local/nagios/etc/libexec" directory. The script, a simple one just checking if an application process exists will return the "0", "1", "2", or "3" exit codes as required.

The file "/usr/local/nagios/etc/nrpe.cfg" has been edited on the Nagios client with the "command[command_name]=/path/to/command" stanza.

All the documentation I can find says to edit the "commands.cfg" file on the server host to point to the "command_name", however opening that file the top lines indicate that it is not to be edited as it will be overwritten and the file(s) should be put into a "static" directory or an "input" directory. I have tried to figure out how to "import" the command into Nagios CCM with little progress.

Can anyone shed some light on the correct procedure to do this, and if there is a simpler way to handle this as it seems that this is a lot of effort for a simple task.



Correct way is to edit a file called checkcommands.cfg, (create file if not available) located in the /etc folder within nagios folder.

  • Create your command with variables & point to actual script.


define command {
        command_name    check_http
        command_line    /usr/local/nagios/libexec/check_http $ARG1$

Also make sure you reference the check commands file in nagios.cfg


If you plan on using Nagios indefinitely, id suggest you install http://www.nagiosql.org. This create a web interface and holds all the configuration in a database, allowing you to easily add new services checks, create hosts etc.. from the interface without editing the nagios config files directly. It will save you hours.

  • Ankh2054,Thanks for the reply. However, the "commands.cfg" file located in the "etc" directory under nagios has this warning at the top of the file (This was stated above as well...) --- DO NOT EDIT THIS FILE BY HAND --- # Nagios CCM will overwrite all manual settings during the next update if you # would like to edit files manually, place them in the 'static' directory or # import your configs into the CCM by placing them in the 'import' directory. So the question becomes, since I can't edit the file by hand as almost everyone thinks I should be doing, how is it updated? – dernwine Apr 20 '15 at 15:47
  • You don't edit commands.cfg, you create a new file called checkcommands.cfg (which won't be overwritten) edit nagios.cfg and add a cfg_file line as above that points to that file. Nagios will then read that config file as any other config file and your commands will be available. – Ankh2054 Apr 20 '15 at 17:25
  • Dernwine, please let everyone know whether the above worked for you, so it can help other people in the future. – Ankh2054 Apr 22 '15 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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