pcp
[Top] [All Lists]

Re: [pcp] pmlogger_check is fooled by localhost

To: Max Matveev <makc@xxxxxxxxx>
Subject: Re: [pcp] pmlogger_check is fooled by localhost
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Mon, 12 Apr 2010 09:58:38 +1000
Cc: pcp@xxxxxxxxxxx
In-reply-to: <19393.8355.508754.477098@xxxxxxxxxxxx>
References: <19387.53537.727368.123975@xxxxxxxxxxxx> <1270603621.15121.79.camel@xxxxxxxxxxxxxxxx> <19387.65322.68301.468516@xxxxxxxxxxxx> <1270642137.15121.125.camel@xxxxxxxxxxxxxxxx> <19389.24907.135424.300701@xxxxxxxxxxxx> <1270704927.8807.7.camel@xxxxxxxxxxxxxxxx> <19390.53020.92570.731051@xxxxxxxxxxxx> <1270847750.18793.8.camel@bozo-laptop> <19393.8355.508754.477098@xxxxxxxxxxxx>
Reply-to: kenj@xxxxxxxxxxxxxxxx
I'm afraid it is more than just GetPort() ... we try and get the fqdn of
the pmcd host in several places ...
      * GetPort() - to be written to the port map file (/tmp/pmlogger/*
        in unix-land)
      * sendstatus() - for response to a pmlc "status" request
      * do_preamble() - for the "fake" initial pmResult that contains
        the metrics pmcd.pmlogger.host, pmcd.pmlogger.port and
        pmcd.pmlogger.archive from pmlogger (not pmcd)

So, one option could be for -H to disable all of the gethostname() and
gethostbyname() calls and use the -h from the command line (or
"localhost" by default) without translation.

This would still leave the messy question of what to do with -P?  You
cannot have -h with -P, and -P needs to be able to talk to pmcd on the
local host, so should -P imply "localhost" with -H, or the result of
gethostname() without -H?

But before exploring that, in your dns-free environment, what does
gethostbyname("localhost") return?

And I assume pcp -h localhost works as expected, correct?

On Sun, 2010-04-11 at 11:06 +1000, Max Matveev wrote: 
> On Sat, 10 Apr 2010 07:15:50 +1000, Ken McDonell wrote:
> 
>  kenj> Yep, pretty close to my patch (no man page from me either) ... I just
>  kenj> went for the -H as a flag, rather than -H hostname (which is the same 
> as
>  kenj> -h hostname, unless hostname happens to be localhost).
> I can live with H being a flag, but I really like to remove
> gethostbyname from GetPort - it's just another place where pmlogger is
> trying to second-guess user's input and yet another place when it can
> go wrong.
> 
>  kenj> But more importantly your source and mine don't match without the
>  kenj> patch ... I don't have archive_host[] in my source, it uses local[]
>  kenj> there and there is no second test for pmcd_host being NULL, no 
> strncmp()
>  kenj> in an else branch ... ???
> That's because patch was on top of the earlier change I've made which is
> available from
> 
> http://oss.sgi.com/cgi-bin/gitweb.cgi?p=makc/pcp;a=shortlog;h=refs/heads/pmlogger
> 
> It includes using different names for __pmLogCreate() and for the
> pmNewConext and not trying to resolve the name when creating a map
> file.
> 
> And strncmp is a brain-fart - I'm surpised that the stuff works.
> 
> max



<Prev in Thread] Current Thread [Next in Thread>