Monit don't get the real hostname as localhostname

Issue #670 closed
Daniel Carrasco created an issue

Hello,

I've noticed that monit output shows and wrong hostname using the http interface. The xml version shows this:

curl http://localhost:2812/_status?format=xml
... <localhostname>CPU</localhostname> ...

It happens on all the machines I've tested and I don't really know where it gets the CPU hostname...

Comments (10)

  1. Tildeslash repo owner

    Please can you send the configuration of "check system" service if it is present in your monit configuration file?

  2. Daniel Carrasco reporter

    Thanks for your response.

    I'm not using "check system", so is commented.

    Anyway, i've uncommented the first two lines to check:

    check system $HOST
        if loadavg (1min) > 4 then alert
    

    and I see the same result on local host name:

    <localhostname>CPU</localhostname>
    

    Also I can see a new check called "system" with a right value:

    System 'i2tic-server-graylog-web-02'
      status                       OK
    ...
    

    I forgot to say that I'm using Debian 8 with compiled binaries downloaded from the webpage. My version is 5.23, but also happens on 5.24.

    Greetings!!

  3. Tildeslash repo owner

    Thanks for data, unfortunately i'm still not able to reproduce the problem.

    The hostname is set based on gethostname() output. Please can you check output of hostname command-line utility? (it should match the gethostname() output).

  4. Daniel Carrasco reporter

    My hostname command shows the correct info:

    # hostname
    i2tic-server-graylog-web-02
    

    Just the same as "System" section.

    gethostname() from php, c...?

  5. Tildeslash repo owner

    Monit uses libc's gethostname().

    The 'System' section reads the value from the same place ... can you verify the <localhost/> and GUI value? It should be the same.

  6. Daniel Carrasco reporter

    Hi,

    Thanks for all your help,

    Finally I've found the problem: I've another file with another system configuration that has the "CPU" as name (my mistake, I didn't remembered that CPU check was there using system)... Now looks like localhostname is OK.

    Thanks again and sorry.

  7. Log in to comment