Page 1 of 1

check_http and hard coded port in commands.cfg

Posted: Fri Apr 24, 2015 8:14 am
by giovanna
Newbe warning: Just given ownership of Nagios and have no exposure, so I seek advice. (Core and after installed XI on CentOS 6.4 64 bit).
Someone before me have hard coded a port - that is now a problem.

I am only using /usr/local/nagios/etc/static (and in commands.cfg I got:
command_name check_endpoint
command_line $USER1$/check_http -H $ARG1$ -u $ARG2$ -p 443 –S

So, the port 443 is hardcoded and one of my end_point checks are using port 8888.

What is the quickets/eaasiest way for a work around? (I am going to have to clean upp all of Nagios laters as it is a right mess.)
Do I just create a separate .cfg file for this customer? Customer now live in /usr/local/nagios/etc/static/objects/customers.cfg Remove the customer from there
and in this specific customer's .cfg file call with:
command_line $USER1$/check_http -H $ARG1$ -u $ARG2$ -p $ARG3$ –S

As I am totally new to Nagios I am only guessing here. I don't know where the actual call is being made and what else to change. What else have I missed?

Cheers
/G

Re: check_http and hard coded port in commands.cfg

Posted: Fri Apr 24, 2015 10:50 am
by jolson
There are two parts to this - the service config file, and the new command definition you'll need to create.

I don't know the structure of your .cfg files, but it sounds like all of your commands are located in commands.cfg.

If that is the case, please add an entry similar to the following to commands.cfg:

Code: Select all

define command{
command_name check_endpoint_8888
command_line $USER1$/check_http -H $ARG1$ -u $ARG2$ -p 8888 –S
}
Or if you don't want to leave the port hardcoded:

Code: Select all

define command{
command_name check_endpoint_diff_port
command_line $USER1$/check_http -H $ARG1$ -u $ARG2$ -p $ARG3$ –S
}
You will need to create a new service for the new command. It sounds like your customer.cfg is located at /usr/local/nagios/etc/static/objects/customers.cfg

You can define a new service under that customer similar to the following service:

Code: Select all

define service{
        use                     generic-service                   #This is the template
        host_name               jolson                            #This is the host the service is attached to
        service_description     Uptime                        #This is essentially the service name
        check_command           check_endpoint_diff_port!<hostname>!<url>!<port>        #The service arguments
}
Replace <hostname>, <url>, and <port> as necessary. e.g. check_endpoint_diff_port!192.168.1.1!/index/something!8888

For more information on the variables above, see: http://nagios.sourceforge.net/docs/3_0/ ... ml#service