pcp
[Top] [All Lists]

Re: [pcp] pmfg / pmapi / null indom

To: Marko Myllynen <myllynen@xxxxxxxxxx>
Subject: Re: [pcp] pmfg / pmapi / null indom
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Tue, 27 Sep 2016 14:52:54 -0400 (EDT)
Cc: pcp developers <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <564bafd1-9f07-2993-c06c-b383489a19e9@xxxxxxxxxx>
References: <a4f3424b-51ba-2f25-80c9-5b81f11efa45@xxxxxxxxxx> <925318399.2722155.1475000898213.JavaMail.zimbra@xxxxxxxxxx> <564bafd1-9f07-2993-c06c-b383489a19e9@xxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: +wa4eqCuEYtXhrc1P9+q7IuKu5TV/g==
Thread-topic: pmfg / pmapi / null indom

----- Original Message -----
> On 2016-09-27 21:28, Nathan Scott wrote:
> > ----- Original Message -----
> >>
> >> Consider the following example:
> >>
> >> #!/usr/bin/python
> >>
> >> from pcp import pmapi
> >>
> >> pmfg = pmapi.fetchgroup()
> >> sysload = pmfg.extend_indom("kernel.all.sysfork")
> >>
> >> pmfg.fetch()
> >> for inst, name, value in sysload():
> >>     print("inst: %d" % inst)
> >>
> >> This prints:
> >>
> >> inst: -1
> >>
> >> Is this some constant or should this be None in the land of Python?
> > 
> > Its cpmapi.PM_IN_NULL (aka "grep PM_IN_NULL /usr/include/pcp/pmapi.h")
> 
> $ cat ./test.py
> #!/usr/bin/python
> from cpmapi import PM_IN_NULL
> print(PM_IN_NULL)
> $ python ./test.py
> 4294967295
> $ grep PM_IN_NULL /usr/include/pcp/pmapi.h
> #define PM_IN_NULL    0xffffffff
> $
> 

Instance identifiers are unsigned integers, so I suspect its the -1 that
is incorrectly type-encoded somewhere.  Does this help...?  (untested)

diff --git a/src/python/pcp/pmapi.py b/src/python/pcp/pmapi.py
index d52426b..f566d44 100644
--- a/src/python/pcp/pmapi.py
+++ b/src/python/pcp/pmapi.py
@@ -2224,7 +2224,7 @@ class fetchgroup(object):
             """Allocate a single instance to receive a fetchgroup item."""
             stss_t = c_int * num
             values_t = pmAtomValue * num
-            icodes_t = c_int * num
+            icodes_t = c_uint * num
             inames_t = c_char_p * num
             self.sts = c_int()
             self.stss = stss_t()

cheers.

--
Nathan

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