Cannot show status with IFDOWN

Issue #192 closed
Alain Mouette created an issue

After I issue "ifdown eth0", the command "monit status" responds with Cannot translate 'localhost' to IP address

This seems like what is documentes here: http://serverfault.com/questions/498500/why-does-the-host-command-not-resolve-entries-in-etc-hosts and can only be fixed inside monit.

Tested on Monit 5.13 too

thanks,

Comments (9)

  1. Tildeslash repo owner

    If you monitor the network interface by IP address and the IP address is dropped (interface down), then monit cannot find it as it doesn't exist and reports an error.

    The error is not "Cannot translate address to IP address" but "Cannot translate address to name", where the name is interface name (not IP address). The message is probably confusing, we have changed it to "Cannot translate address to interface" to clarify it.

  2. Alain Mouette reporter

    Hi, You have made a wonderfull program and I am gratefull for that, but I also deserve a little respect. The message that I reported is correct an precise. The exact same thing happens with the command "host localhost"

    The problem is well document and happens because of the function that you are calling to get the IP only uses DNS which is not available if eth0 os down. If you just switch to gethostbyname() the problem is fixed.

    Have you tried to reproduce the reported error? I can provide a VirtualBox appliance if you prefer

    Thanks for the fasr reply Alain

  3. Tildeslash repo owner

    Alain, it was nothing personal - i'm sorry i misunderstood the report and though it was related to network check ... there the IP address is translated to (interface) name and if the address cannot be found on any interface, the mentioned error message is logged, whereas i found it confusing and though you just transcripted the message to IP address.

    Reading your error report again it is completely unrelated to network check (mea culpa).

    I cannot reproduce the problem though - when i shutdown the loopback interface and call "monit status" i get following error (which is expected):

    Cannot create socket to [localhost]:2812 -- Connection timed out
    

    Monit uses getaddrinfo() and this function uses the /etc/nsswitch.conf (same way as gethostbyname()) ... if you have default "hosts: files dns" entry then it will use /etc/hosts first and then fallback to DNS.

    => the problem seems to be configuration issue - please check /etc/nsswitch.conf settings and /etc/hosts (should contain "127.0.0.1 localhost") on your system.

  4. Alain Mouette reporter

    First of all, I would like to apologize for being harsh, I was having a personal issue (with so else) and my reaction was not called for!

    Well, I am guilty of mis-reporting, things behave differnetly if I shut down lo ou eth0, here is an image (sorry but this is from a console and I cannot ger a text copy): Monit-ErroLocalhost.png

    As you can see, the message that I reported is for eth0. It seemas logical for monit status not to work with lo down, but having eth0 down may be very important for diagnosing a server (that is why I filled this issue as a bug).

    I have saved a VirtualBox Applience if you need a live run, root passwd is "nodejs". All configurations were made by this script

  5. Tildeslash repo owner

    Thanks for the appliance Alain.

    I have reproduced the problem, but it is not related to monit, but rather problem of "ifdown" which seems to break the name resolving.

    1.) when you use ifdown eth0 then the machine name resolver stops using /etc/hosts file and "monit status" really returns the mentioned "Cannot translate 'localhost' to IP address -- Name or service not known" error, but any other system utility has exactly the same problem: for example command "host localhost" returns: ";;connection timed out; no servers could be reached;". I have checked the /etc/nsswitch.conf and /etc/hosts - looks fine, but the system really doesn't lookup the hosts in the nsswitch.conf order and tries to use DNS.

    2.) when i shutdown the eth0 interface using ifconfig: ifconfig eth0 down, then the "files" based name resolving continues to work normally despite the eth0 is down - "monit status" works, "host localhost" works too.

    => the problem is not related to monit, but it is some feature of "ifdown" which does some extra changes and breaks the system name resolving in addition to shutting down the interface. If the eth0 interface is shut down with "ifconfig", everything works correctly (that will be equal if the eth0 cable/networkcard is unplugged/broken on physical machine or if the parent network interface is shutdown on the bridged virtual host).

  6. Alain Mouette reporter

    I am making a lot of tests, including disconnecting the cable (in VirtualBox). This link down issue is really confusing. I will post something (here) when I can get anything more concrete...

  7. Nico De Ceulaer

    Hi @alainm789 I'm getting hit by exactly the same issue as reported by you above, some time ago. Did your testing/investigation end up with any extra information? (and hopefully solutions) ?

    kind regards in advance

  8. Log in to comment