pcp
[Top] [All Lists]

Re: [pcp] pmlogger_check is fooled by localhost

To: kenj@xxxxxxxxxxxxxxxx
Subject: Re: [pcp] pmlogger_check is fooled by localhost
From: Max Matveev <makc@xxxxxxxxx>
Date: Fri, 9 Apr 2010 16:54:20 +1000
Cc: pcp@xxxxxxxxxxx
In-reply-to: <1270704927.8807.7.camel@xxxxxxxxxxxxxxxx>
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>
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

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