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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Post Reply
BettyRNorahDeniels
Posts: 11
Joined: Tue Feb 15, 2022 7:13 am

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

Post 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!
Last edited by BettyRNorahDeniels on Mon Aug 29, 2022 6:59 am, edited 1 time in total.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

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

Post by gormank »

Warning: Duplicate definition found

You're redefining check_http so it gives an error. Use a new name.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

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

Post by gormank »

Sorry,
I should have said create a service that uses the check_http command, not create a new command.
JernalinSadhoo
Posts: 5
Joined: Sat May 21, 2022 7:53 am

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

Post 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.
Post Reply