Nagios: monitor http service on a different port

httpnagios

I want to monitor services over http running on multiple ports other than 80.
Services are running on port 8083, 8086 and some other ports. I created server.cfg file as follows:

define host {
        use                     linux-server
        host_name               cfbase-prod
        alias                   cfbase-prod
        address                 x.x.x.x
        contacts                admin
        }

define service {
        use                             generic-service
        host_name                       cfbase-prod
        service_description             HTTP
        check_command                   check_http
        contacts                        admin
        check_interval                  1
        }

But it is not working in my nagios console it still shows as the http on port 80, which is not the case. Can somebody please help.

Best Answer

You can specify the port number directly in the command but you will must create one command per tested port.

Or you can create a custom variable to store the port number , with your example:

define host {
        use                     linux-server
        host_name               cfbase-prod
        alias                   cfbase-prod
        address                 x.x.x.x
        contacts                admin
        }

define service {
        use                             generic-service
        host_name                       cfbase-prod
        service_description             HTTP
        check_command                   check_http
        contacts                        admin
        check_interval                  1
        _port_number                    8083
        }

And on your command you can inherite of this variable like this :

define command{
    command_name check_http 
    command_line $USER1$/check_http -I $HOSTADDRESS$ -p $_SERVICEport_number$ $ARG1$ 
}

You must prepend _service for a service or _host for a host to use your variable in a command. source :

https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/customobjectvars.html

Related Topic