Thanks for data. I think the problem could be solved by changing the /etc/hosts 
order so it returns the real hostname first or by asigning the hostname to real 
IP address (not loopback):

Current state:
--8<--
127.0.0.1       localhost.localdomain loclhost talyn.bm-home.lan talyn
--8<--


Either moving the hostname to real IP (adding the line with the network IP of 
the given host):
--8<--
127.0.0.1   localhost.localdomain localhost 
x.x.x.x         talyn.bm-home.lan talyn
--8<--

Or switching the hostname and localhost order (retains the hostname on 
127.0.0.1):
--8<--
127.0.0.1   talyn.bm-home.lan talyn localhost.localdomain localhost 
--8<--


Your other machines probably uses one of the above setups.

On Monit side we can modify the hostname assignment to skip the localhost 
entries returned by the resolver and use the first non-localhost name. This 
will allow to pickup the hostname even if it is present in the /etc/hosts past 
the "localhost" entries.



On Feb 14, 2012, at 11:21 AM, Lawrence, Wayne wrote:

> Hi Martin,
>  
> To answer your questions in order.
>  
> 1) All hosts are tunning monit 5.3.2 the host which resolves correctly is 
> running centos 6.2.
>   the hosts that dont resolve correctly are running ubuntu 11.10 and Arch 
> linux.
>  
> 2) the hostname outputs are as follows
> On the ubuntu host
> talyn
> on the Arch host
> scorpius.bm-home.lan
> 
> 3) outputs from getent hosts `hostname`
> on the ubuntu host
> 127.0.0.1       localhost.localdomain loclhost talyn.bm-home.lan talyn
> on the Arch host
> 127.0.0.1       localhost.localdomain localhost scorpius.bm-home.lan scorpius
> 
> I may be ,missing something blatantly obvious but if you have any suggestions 
> to put this right i would appreciate it.
>  
> Regards
>  
> Wayne
>  
> On 14 February 2012 09:14, Martin Pala <[email protected]> wrote:
> Hi,
> 
> monit <= 5.2.4 used just  the libc's interface gethostname(), which should 
> match the output of the "hostname" CLI utility.
> 
> monit >= 5.2.5 gets the hostname also via gethostname(), but then also tries 
> to resolve that name to get the fully qualified domain name using system's 
> getaddrinfo() API (the resolver is driven by nsswitch.conf and resolv.conf).
> 
> Few questions?
> 1.) which monit versions are running the two hosts which report as 
> "localhost.localdomain" and which monit versions those who report correct 
> hostname?
> 2.) what is the "hostname" output on host with "localhost.localdomain"?
> 3.) what is the "getent hosts `hostname`" output on host with 
> "localhost.localdomain"?
> 
> Regards,
> Martin
> 
> 
> On Feb 9, 2012, at 11:10 AM, Lawrence, Wayne wrote:
> 
> > Hi,
> >
> > Just a quick question if anyone can answer it. Where does monit get the 
> > hostname from?
> >
> > I have serveral servers which all report their correct hostanme at the cli 
> > but when i get emails from monit or view them in m/monit they show as 
> > localhost.localdomain. One reports everything coreclty the other 2 are 
> > giving the localhost/localdomain problem.
> >
> > I know the server names are correct as they all resolve correctly but I 
> > want consistency across my servers.
> >
> > Rergards
> >
> > Wayne
> > --
> > To unsubscribe:
> > https://lists.nongnu.org/mailman/listinfo/monit-general
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to