X-Spam-Checker-Version: SpamAssassin 3.3.0-rupdated (updated) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_00,FH_DATE_PAST_20XX autolearn=no version=3.3.0-rupdated Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id o3N3G2Fd008805 for ; Thu, 22 Apr 2010 22:16:03 -0500 X-ASG-Debug-ID: 1271992680-568a004c0000-S8gJnT X-Barracuda-URL: http://cuda.sgi.com:80/cgi-bin/mark.cgi Received: from postoffice2.aconex.com (localhost [127.0.0.1]) by cuda.sgi.com (Spam Firewall) with ESMTP id A7705130BEBF for ; Thu, 22 Apr 2010 20:18:01 -0700 (PDT) Received: from postoffice2.aconex.com (mail.aconex.com [203.89.202.182]) by cuda.sgi.com with ESMTP id 3l8czstvcuGx2xno for ; Thu, 22 Apr 2010 20:18:01 -0700 (PDT) Received: from postoffice.aconex.com (localhost [127.0.0.1]) by postoffice2.aconex.com (Spam & Virus Firewall) with ESMTP id 0EB6675B931; Fri, 23 Apr 2010 13:17:59 +1000 (EST) Received: from postoffice.aconex.com (postoffice.yarra.acx [192.168.102.1]) by postoffice2.aconex.com with ESMTP id e0VKTNzbcHpuuB5T; Fri, 23 Apr 2010 13:17:59 +1000 (EST) Received: from gatekeeper.aconex.com (gatekeeper.yarra.acx [192.168.102.10]) by postoffice.aconex.com (Postfix) with ESMTP id D632CA5017F; Fri, 23 Apr 2010 13:14:52 +1000 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by gatekeeper.aconex.com (Postfix) with ESMTP id E30754885FF; Fri, 23 Apr 2010 13:17:58 +1000 (EST) X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on oss.sgi.com X-Virus-Scanned: amavisd-new at aconex.com Received: from gatekeeper.aconex.com ([127.0.0.1]) by localhost (gatekeeper.aconex.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fMYfxGaIcm+7; Fri, 23 Apr 2010 13:17:54 +1000 (EST) Received: from mail-au.aconex.com (mail-au.aconex.com [192.168.102.12]) by gatekeeper.aconex.com (Postfix) with ESMTP id 273544885FD; Fri, 23 Apr 2010 13:17:54 +1000 (EST) Date: Fri, 23 Apr 2010 13:17:54 +1000 (EST) From: nathans@aconex.com Sender: nscott@aconex.com To: kenj@internode.on.net Cc: pcp Message-ID: <1988458083.206861271992673963.JavaMail.root@mail-au.aconex.com> In-Reply-To: <2077613103.206821271992571566.JavaMail.root@mail-au.aconex.com> X-ASG-Orig-Subj: Re: Dynamic names issue Subject: Re: Dynamic names issue MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_15295_957658181.1271992673960" X-Originating-IP: [203.89.192.141] X-Mailer: Zimbra 5.0.18_GA_3011.RHEL5_64 (ZimbraWebClient - FF3.0 (Linux)/5.0.18_GA_3011.RHEL5_64) X-Barracuda-Connect: mail.aconex.com[203.89.202.182] X-Barracuda-Start-Time: 1271992683 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Virus-Scanned: by cuda.sgi.com at sgi.com X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using per-user scores of TAG_LEVEL=2.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.1 tests=NO_REAL_NAME X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.28145 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name X-Virus-Status: Clean ------=_Part_15295_957658181.1271992673960 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit ----- "Ken McDonell" wrote: > The first time a pmid appears in a pmFetch, pmlogger calls pmNameAll > to get all of the names of the metric from the pmns to build the pmns > fragment in the archive ... at this point the only name that can be > found for pmid 2.4.1 is pmcd.agent.status, because the other "name" > is not really in the pmns that is available to pmcd, and is not even > "owned" by the PMDA with domain 2. > > I don't see a simple way to prevent this happening ... How's this patch look? It has the added bonus that it removes two round trip PDUs per metric logged (hmmmm ... wonder if this is why some of my remote loggers take so long to start!). The main open question is whether the (existing) task cache is ever invalid at the time that initial callback happens... there's some hairy code in there, but fortunately the guy who wrote it is right here. :) $ cat tmp/config log advisory on 1sec { sample.secret.foo.bar.max.redirect } $ pminfo -a tmp/archive sample.secret.foo.bar.max.redirect pmcd.pmlogger.archive pmcd.pmlogger.port pmcd.pmlogger.host $ Thoughts? Seems like its much improved this way, I'm wondering why it wasn't done like this before!? (IOW, what am I missing?) cheers. -- Nathan ------=_Part_15295_957658181.1271992673960 Content-Type: text/x-patch; name=pmlogger.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=pmlogger.patch diff --git a/src/pmlogger/callback.c b/src/pmlogger/callback.c index f857d40..4eec34a 100644 --- a/src/pmlogger/callback.c +++ b/src/pmlogger/callback.c @@ -294,6 +294,16 @@ check_inst(pmValueSet *vsp, int hint, pmResult *lrp) return 0; } +static int +lookupTaskCache(task_t *tp, pmID pmid) +{ + int i; + for (i = 0; i < tp->t_numpmid; i++) { + if (tp->t_pmidlist[i] == pmid) + return i; + } + return -1; +} void log_callback(int afid, void *data) @@ -466,27 +476,28 @@ log_callback(int afid, void *data) for (i = 0; i < resp->numpmid; i++) { pmValueSet *vsp = resp->vset[i]; pmDesc desc; - char **names = NULL; + char *names = NULL; int numnames = 0; + sts = __pmLogLookupDesc(&logctl, vsp->pmid, &desc); if (sts < 0) { - if (archive_version == PM_LOG_VERS02) { - if ((numnames = pmNameAll(vsp->pmid, &names)) < 0) { - fprintf(stderr, "pmNameAll: %s\n", pmErrStr(numnames)); - exit(1); - } - } - if ((sts = pmLookupDesc(vsp->pmid, &desc)) < 0) { - fprintf(stderr, "pmLookupDesc: %s\n", pmErrStr(sts)); + /* lookup name and descriptor in task cache */ + int taskindex = lookupTaskCache(tp, vsp->pmid); + if (taskindex == -1) { + fprintf(stderr, "lookupTaskCache cannot find PMID %s\n", + pmIDStr(vsp->pmid)); exit(1); } - if ((sts = __pmLogPutDesc(&logctl, &desc, numnames, names)) < 0) { + if (archive_version == PM_LOG_VERS02) { + numnames = 1; + names = tp->t_namelist[taskindex]; + } + desc = tp->t_desclist[taskindex]; + + if ((sts = __pmLogPutDesc(&logctl, &desc, numnames, &names)) < 0) { fprintf(stderr, "__pmLogPutDesc: %s\n", pmErrStr(sts)); exit(1); } - if (names != NULL) { - free(names); - } } if (desc.indom != PM_INDOM_NULL && vsp->numval > 0) { /* @@ -605,7 +616,7 @@ log_callback(int afid, void *data) } if (rflag && tp->t_size == 0 && pdu_metrics > 0) { - char **names = NULL; + char *names = NULL; tp->t_size = pdu_bytes; @@ -614,27 +625,26 @@ log_callback(int afid, void *data) else fprintf(stderr, "\nMetric "); if (archive_version == PM_LOG_VERS02) { - if (pmNameAll(pdu_first_pmid, &names) < 0) - names = NULL; - } - if (names != NULL) { - fprintf(stderr, "%s", names[0]); - free(names); + int taskindex = lookupTaskCache(tp, pdu_first_pmid); + if (tp->t_namelist[taskindex] != NULL) + names = tp->t_namelist[taskindex]; } + if (names != NULL) + fprintf(stderr, "%s", names); else fprintf(stderr, "%s", pmIDStr(pdu_first_pmid)); if (pdu_metrics > 1) { fprintf(stderr, "\n\t"); if (pdu_metrics > 2) fprintf(stderr, "...\n\t"); + names = NULL; if (archive_version == PM_LOG_VERS02) { - if (pmNameAll(pdu_last_pmid, &names) < 0) - names = NULL; - } - if (names != NULL) { - fprintf(stderr, "%s", names[0]); - free(names); + int taskindex = lookupTaskCache(tp, pdu_last_pmid); + if (tp->t_namelist[taskindex] != NULL) + names = tp->t_namelist[taskindex]; } + if (names != NULL) + fprintf(stderr, "%s", names); else fprintf(stderr, "%s", pmIDStr(pdu_last_pmid)); fprintf(stderr, "\n}"); ------=_Part_15295_957658181.1271992673960--