Page 1 of 1

Nagios: Could not resolve hostname

Posted: Tue Jul 21, 2015 5:34 am
by setevoy
Hi.

My setup:

hosts.cfg - contains definitions for each host under monitoring, e.g.:

Code: Select all

define host{
        use                     linux-server
        host_name               rdss-vpn
        display_name            VPN
        address                 54.***.***.176
        }
hosts_groups.cfg - define groups:

Code: Select all

define hostgroup{
        hostgroup_name   rdss-service-server
        alias            RDSS services
        members          [...],  rdss-vpn
        }
services.cfg:

Code: Select all

define service{
        use                             local-service
        hostgroup_name                  rdss-web-server, rdss-service-server
        service_description             Memory usage
        check_command                   check_linux_memory!50!80
        notifications_enabled           1
        }
And check_linux_memory in commands.cfg:

Code: Select all

define command{
        command_name    check_linux_memory
        command_line    $USER1$/check_nrpe -H $HOSTNAME$ -c check_linux_memory -a '-f -w $ARG1$ -c $ARG2$'
        }
Problem is with few new added hosts, like rdss-vpn - Nagios won't get it's IP from hosts (please note - I have few other servers (also in groups) in check_linux_memory - all works).

Instead - I have an error in nagios.log:
[1437473407] SERVICE ALERT: rdss-vpn;Memory usage;WARNING;HARD;4;(No output on stdout) stderr: Could not resolve hostname rdss-vpn: Name or service not known
Here is example of host, where check_linux_memory works:

Code: Select all

define host{
        use                     linux-server
        host_name               www.dev.domain.com
        display_name            DEV
        address                 54.***.***.136
        }
It's group:

Code: Select all

define hostgroup{
        hostgroup_name   rdss-web-server
        alias            RDSS web servers
        members          www.dev.domain.com, www.qa.domain.com, www.staging.domain.com
        }
Can't understand - why Nagios can't resolve IP for all hosts in rdss-service-server group? All other groups are similar, also uses `check_linux_memory`, and works.

Image

Re: Nagios: Could not resolve hostname

Posted: Tue Jul 21, 2015 9:24 am
by jdalrymple
I'm surprised anything works:
setevoy wrote:And check_linux_memory in commands.cfg:

Code: Select all

    define command{
            command_name    check_linux_memory
            command_line    $USER1$/check_nrpe -H $HOSTNAME$ -c check_linux_memory -a '-f -w $ARG1$ -c $ARG2$'
            }
$HOSTNAME$ is not what you want, (I don't think) - you want $HOSTADDRESS$. Nagios resolves $HOSTADDRESS$ on restart then passes only IPs to plugins. By using $HOSTNAME$ you're passing whatever you called the host (which could be totally arbitrary) to the plugin.

Re: Nagios: Could not resolve hostname

Posted: Wed Jul 22, 2015 4:57 am
by setevoy
jdalrymple wrote:
$HOSTNAME$ is not what you want, (I don't think) - you want $HOSTADDRESS$. Nagios resolves $HOSTADDRESS$ on restart then passes only IPs to plugins. By using $HOSTNAME$ you're passing whatever you called the host (which could be totally arbitrary) to the plugin.
Thanks, $HOSTADDRESS$ is what I need...

Btw - Nagios documentation isn't available anymore (this sourceforge.net website is temporarily offline.
We are working hard to restore its availability. ) - is there anywhere else same docs? It was very usefull.

Re: Nagios: Could not resolve hostname

Posted: Wed Jul 22, 2015 9:45 am
by jdalrymple
Sourceforge thing - sorry it's out of our control :(

Use Google's cached version of our pages - see attachment.

Re: your issue - resolved? OK to lock the topic?

Re: Nagios: Could not resolve hostname

Posted: Thu Jul 23, 2015 6:12 am
by setevoy
jdalrymple wrote: your issue - resolved? OK to lock the topic?
Yes, solved, thanks a lot. Topic can be closed.