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: Sat, 10 Apr 2010 07:15:50 +1000
Cc: pcp@xxxxxxxxxxx
In-reply-to: <19390.53020.92570.731051@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>
Reply-to: kenj@xxxxxxxxxxxxxxxx
Max,

Yep, pretty close to my patch (no man page from me either) ... I just
went for the -H as a flag, rather than -H hostname (which is the same as
-h hostname, unless hostname happens to be localhost).

But more importantly your source and mine don't match without the
patch ... I don't have archive_host[] in my source, it uses local[]
there and there is no second test for pmcd_host being NULL, no strncmp()
in an else branch ... ???

Attached is my patch.

On Fri, 2010-04-09 at 16:54 +1000, Max Matveev wrote:
> On Thu, 08 Apr 2010 15:35:27 +1000, Ken McDonell wrote:
> 
>  kenj> This means stopping pmlogger doing the localhost -> hostname() mapping,
>  kenj> which probably means another command line argument to pmlogger to not 
> do
>  kenj> the mapping, while maintaining compatibility by doing the mapping in 
> the
>  kenj> default case.
> Do you mean like this (with a matching change to pmlogger.1):
> 
> diff --git a/src/pmlogger/pmlogger.c b/src/pmlogger/pmlogger.c
> index 25310d3..d60a223 100644
> --- a/src/pmlogger/pmlogger.c
> +++ b/src/pmlogger/pmlogger.c
> @@ -483,6 +483,7 @@ main(int argc, char **argv)
>      fd_set             readyfds;
>      char               *p;
>      char               *runtime = NULL;
> +    int                        dont_use_localhost = 1;
>  
>      __pmSetProgname(argv[0]);
>  
> @@ -492,7 +493,7 @@ main(int argc, char **argv)
>       *         corresponding changes are made to pmnewlog when
>                 pmlogger
>       *         options are passed through from the control file
>       */
> -    while ((c = getopt(argc, argv, "c:D:h:l:Ln:Prs:T:t:uv:V:x:?")) != EOF) {
> +    while ((c = getopt(argc, argv, "c:D:H:h:l:Ln:Prs:T:t:uv:V:x:?")) != EOF) 
> {
>         switch (c) {
>  
>         case 'c':               /* config file */
> @@ -527,6 +528,9 @@ main(int argc, char **argv)
>                 pmDebug |= sts;
>             break;
>  
> +       case 'H':
> +           dont_use_localhost = 0;
> +           /* fallthru */
>         case 'h':               /* hostname for PMCD to contact */
>             pmcd_host = optarg;
>             break;
> @@ -628,6 +632,7 @@ main(int argc, char **argv)
>  Options:\n\
>    -c configfile file to load configuration from\n\
>    -h host      metrics source is PMCD on host\n\
> +  -H host      metrics source is PMCD on host(do not subsitute the host 
> name)\n
>    -l logfile   redirect diagnostics and trace output\n\
>    -L           linger, even if not primary logger instance and
>    nothing to log\n
>    -n pmnsfile   use an alternative PMNS\n\
> @@ -658,7 +663,7 @@ Options:\n\
>      if (pmcd_host == NULL || strcmp(pmcd_host, "localhost") == 0) {
>         (void)gethostname(archive_host, sizeof(archive_host));
>         archive_host[sizeof(archive_host)-1] = '\0';
> -       if (pmcd_host == NULL)
> +       if ((pmcd_host == NULL) || dont_use_localhost)
>             pmcd_host = archive_host;
>      } else {
>         strncmp(archive_host, pmcd_host, sizeof(archive_host));
> 
> max

Attachment: patch.localhost
Description: Text Data

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