Page 1 of 1

Dynamic hostname in check (and not %HOSTNAME%)

Posted: Thu Dec 06, 2018 7:40 am
by ritalinux
All our servers have two network interfaces, one for management and one for applications. Nagios runs over the management interface and its full hostname is <servername>.mgt.domain.name which in DNS points to its management interface. <servername>.domain.name points to the application network interface.

I want to check the expiry date of the SSL certificate of the Apache web application.

Unfortunately $HOSTNAME$ has the value of <servername>.mgt.domain.name and to run my check I need <servername>.domain.name. I cannot really change this in my organization.

I nagios I can do this command on the nagios server, using ncpa and check_http to check the remote server:

Code: Select all

./check_ncpa.py -t secrettoken -H server1.mgt.domain.name -P 5693 -M 'plugins/check_http' -a '-I server1.domain.name -ssl -p443 -sni -C 60' 
While this works great, this would require to create a check for each server I want to monitor with its name hard coded. I'm trying to create something like this:

Code: Select all

./check_ncpa.py -t secrettoken -H server1.mgt.domain.name -P 5693 -M 'plugins/check_http' -a '-I $(hostname -s).domain.name -ssl -p443 -sni -C 60' 
This does not work. I hope you get my point, I need to dynamically fill in the host name, does anybody know of a way? I don't mind writing my own plugin, but I still do not see how to solve this issue.

Re: Dynamic hostname in check (and not %HOSTNAME%)

Posted: Thu Dec 06, 2018 3:21 pm
by cdienger
An option would be to populate another field - like $HOSTNOTES$ OR $HOSTNOTESURL$ for example - on the host to hold the application interface's name and then configure the service to use this new field. These can be populated under the "Misc Settings" tab of the host's config.