Nagios: Could not resolve hostname

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.
Locked
User avatar
setevoy
Posts: 13
Joined: Fri Jul 03, 2015 9:49 am
Location: Kiev, UA
Contact:

Nagios: Could not resolve hostname

Post 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
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios: Could not resolve hostname

Post 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.
User avatar
setevoy
Posts: 13
Joined: Fri Jul 03, 2015 9:49 am
Location: Kiev, UA
Contact:

Re: Nagios: Could not resolve hostname

Post 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.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios: Could not resolve hostname

Post 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?
Attachments
Clipboard01.jpg
User avatar
setevoy
Posts: 13
Joined: Fri Jul 03, 2015 9:49 am
Location: Kiev, UA
Contact:

Re: Nagios: Could not resolve hostname

Post by setevoy »

jdalrymple wrote: your issue - resolved? OK to lock the topic?
Yes, solved, thanks a lot. Topic can be closed.
Locked