Where to store custom check programs

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
moose
Posts: 10
Joined: Wed Jun 05, 2013 5:44 pm

Where to store custom check programs

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Where to store custom check programs

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
moose
Posts: 10
Joined: Wed Jun 05, 2013 5:44 pm

Re: Where to store custom check programs

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Where to store custom check programs

Post by abrist »

Can you run the check from the cli?
http://assets.nagios.com/downloads/nagi ... ios_XI.pdf
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
moose
Posts: 10
Joined: Wed Jun 05, 2013 5:44 pm

Re: Where to store custom check programs

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Where to store custom check programs

Post by lmiltchev »

I'm glad your problem has been resolved.
Be sure to check out our Knowledgebase for helpful articles and solutions!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Where to store custom check programs

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked