Page 1 of 1

Monitor a service running on a port other than 80 in Nagios

Posted: Mon Jul 25, 2022 6:46 am
by BettyRNorahDeniels
How do we monitor a remote service running on a machine using Nagios. I have created a cfg file as follows:

define command {
command_name check_http
command_line /usr/lib64/nagios/plugins/check_http -H $HOSTADDRESS$ -p 8082
}
Now when I reload the configuration file, it throws following error:

Warning: Duplicate definition found for command 'check_http' (config file '/etc/nagios/servers/cfbase-prod.cfg', starting on line 19)
Error: Could not add object property in file '/etc/nagios/servers/cfbase-prod.cfg' on line 20.
Error processing object config omegle.2yu.co files!
I am not able to figure out omeglz echat what is the problem. Please help!

Re: Monitor a service running on a port other than 80 in Nag

Posted: Mon Jul 25, 2022 5:18 pm
by gormank
Warning: Duplicate definition found

You're redefining check_http so it gives an error. Use a new name.

Re: Monitor a service running on a port other than 80 in Nag

Posted: Mon Jul 25, 2022 5:25 pm
by gormank
Sorry,
I should have said create a service that uses the check_http command, not create a new command.

Re: Monitor a service running on a port other than 80 in Nag

Posted: Fri Jul 29, 2022 7:29 am
by JernalinSadhoo
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 echatspin echatrandom variable in a command.