Page 1 of 1
Where to store custom check programs
Posted: Mon Jun 17, 2013 4:49 pm
by moose
Standard Nagios check programs are stored in /usr/local/nagios/libexec. Which folder do I use to store my custom check programs?
Defining my check program. Does it get defined it in /usr/local/nagios/etc/commands.cfg or do I define it in a new file /usr/local/nagios/etc/static/myKoolCommands.cfg?
I also have to notify Nagios of myKoolCommands.cfg. Do I insert cfg_file=/usr/local/nagios/etc/static/myKoolCommands.cfg into /usr/local/nagios/etc/nagios.cfg or some other file?
Restart Nagios with "service nagios restart"?
Is there anything else I have to do to get Nagios to recognize my program?
Thank you
Re: Where to store custom check programs
Posted: Mon Jun 17, 2013 4:55 pm
by abrist
moose wrote:Standard Nagios check programs are stored in /usr/local/nagios/libexec. Which folder do I use to store my custom check programs?
Wherever you want. I usually create a folder inside libexec for my custom check scripts.
moose wrote:Defining my check program. Does it get defined it in /usr/local/nagios/etc/commands.cfg or do I define it in a new file /usr/local/nagios/etc/static/myKoolCommands.cfg?
Either once again. Just remember that any new config you create has to be declared with and include statement in the nagios.cfg file.
moose wrote:I also have to notify Nagios of myKoolCommands.cfg. Do I insert cfg_file=/usr/local/nagios/etc/static/myKoolCommands.cfg into /usr/local/nagios/etc/nagios.cfg or some other file?
Exactly.
moose wrote:Restart Nagios with "service nagios restart"?
Yep.
moose wrote:Is there anything else I have to do to get Nagios to recognize my program?
As always, it depends on the plugin in question.
Re: Where to store custom check programs
Posted: Tue Jun 18, 2013 1:39 pm
by moose
Nagios does not offer my plugin in the CGI. CCM> Services> AddNew> CheckCommand combo box.
As a test I have duplicated and renamed one of the plugins that comes with Nagios check_mssql to become check_ts. Here's what I've done do far.
Made a sub-folder for the plugin /usr/local/nagios/libexec/ia
Copied /usr/local/nagios/libexec/check_mssql into /usr/local/nagios/libexec/ia/check_ts
Created a new command file /usr/local/nagios/etc/static/ia_commands.cfg
Code: Select all
# Contents of ia_commands.cfg
define command {
command_name check_ts
command_line $USER1$/ia/check_ts -H $HOSTADDRESS$ $ARG1$
}
File /usr/local/nagios/etc/nagios.cfg already has cfg_dir=/usr/local/nagios/etc/static which loads my ia_commands.cfg. No changes to nagios.cfg were made. I've also tried specifing ia_commands.cfg in nagios.cfg and got an error for duplicate definitions.
The pre-flight check found ia_commands.cfg and shows no warnings and no errors.
"service nagios restart" stopped and started without problems.
I reloaded the CGI page.
Is there some other setting I have to make?
Re: Where to store custom check programs
Posted: Tue Jun 18, 2013 2:17 pm
by abrist
Re: Where to store custom check programs
Posted: Tue Jun 18, 2013 3:21 pm
by moose
Thank you.
I followed the PDF and Nagios recognizes the plugin and it appears in the combo box. Adding the plugin manually was a waste of time. I'll just use the CGI from now on and be resigned to never knowing why the manual method didn't work.
... the plugin did run on the CLI because it was a standard plugin; just renamed.
Re: Where to store custom check programs
Posted: Tue Jun 18, 2013 3:32 pm
by lmiltchev
I'm glad your problem has been resolved.
Re: Where to store custom check programs
Posted: Tue Jun 18, 2013 3:33 pm
by abrist
With XI, it is best to stick to the web ui for most things. Not to say that the static directory doesn't have a place for some installs, but if you can use the ui, it is better as then you have the db backend and some advanced validation and logic for checking your configs.
Glad to hear you got it working. Locked.