pcp
[Top] [All Lists]

Re: [pcp] PMDA CIFS

To: AurÃlien Aptel <aurelien.aptel+pcp@xxxxxxxxx>
Subject: Re: [pcp] PMDA CIFS
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Wed, 4 Sep 2013 21:01:59 -0400 (EDT)
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CA+5B0FOAL5U8wn9WagrHCdFpY45MEVkM5rF4CypwJPi1Mx5cMw@xxxxxxxxxxxxxx>
References: <CA+5B0FNcq2X8EnNf35nMDGfu2Y5pSgOABVao7umiNiyNOjvFXw@xxxxxxxxxxxxxx> <2018836669.6550029.1377571301699.JavaMail.root@xxxxxxxxxx> <CA+5B0FOJCgd3_432=3n+OSHOAtxJ7RwHkivwnKqkmEUJC9uuKg@xxxxxxxxxxxxxx> <465361629.9900993.1377812441964.JavaMail.root@xxxxxxxxxx> <CA+5B0FPNLbOCOuxPzVCiZN5jevdVy8m7osaTopDWY1tbezCKPA@xxxxxxxxxxxxxx> <1429143227.12940240.1378249580687.JavaMail.root@xxxxxxxxxx> <CA+5B0FOAL5U8wn9WagrHCdFpY45MEVkM5rF4CypwJPi1Mx5cMw@xxxxxxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: IbTqaQdMHWsLZvhRCIb0D4Plx84/mw==
Thread-topic: PMDA CIFS
Hi AurÃlien,

----- Original Message -----
> The indom are all created. I'm sure I must be doing something wrong.
> 

OK - I think your code is good, but you are tripping a subtle reference
counting issue in the C/Perl wrapper code.  If you change the code that
creates local %smb1 and %smb2 hashes to instead use globals, it works -
looks like nobody created indom hashes with non-global scope before!

Anyway, with attached patch things behave as you're after, I believe,
even with the current perl PMDA wrapper.

If you prefer to keep the locals, you'll want the following patch which
addresses the root cause:

diff --git a/src/perl/PMDA/PMDA.xs b/src/perl/PMDA/PMDA.xs
index 3884926..472ca46 100644
--- a/src/perl/PMDA/PMDA.xs
+++ b/src/perl/PMDA/PMDA.xs
@@ -498,7 +498,7 @@ update_hash_indom(SV *insts, pmInDom indom)
 
     hv_iterinit(ihash);
     while ((data = hv_iternextsv(ihash, &instance, &instsize)) != NULL)
-       pmdaCacheStore(indom, PMDA_CACHE_ADD, instance, data);
+       pmdaCacheStore(indom, PMDA_CACHE_ADD, instance, SvREFCNT_inc(data));
 
     sts = pmdaCacheOp(indom, PMDA_CACHE_SAVE);
     if (sts < 0)


Also, if you issue add_indom with a different order to the sequential
indom numbering, IIRC you need to subsequently use the returned value
(its used as an array index) for indom operations like 'replace' later.
So, I tend to just initialise in the right order and not worry about it
(you'll see in pmdasimple though that it assigns back to $now_indom).

cheers.

ps: one initial bit of early feedback on your updates - I'd recommend
a metric naming convention along the lines of the disk.dev metrics (see
"pminfo disk.dev").  The num_* naming is a bit redundant - just use the
operation names directly, like disk.dev.read (disk read operations), so
cifs.smb1.read instead of num_read.  And "byte_read" -> "read_bytes" is
closer to names used elsewhere (like disk.dev.read_bytes).

--
Nathan

Attachment: cifs-workaround.patch
Description: Text Data

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