pcp
[Top] [All Lists]

Re: PCP versions of console tools - Next Steps

To: Sitaram Shelke <sitaramshelke@xxxxxxxxx>
Subject: Re: PCP versions of console tools - Next Steps
From: fche@xxxxxxxxxx (Frank Ch. Eigler)
Date: Wed, 11 May 2016 13:16:31 -0400
Cc: Ryan Doyle <ryan@xxxxxxxxxxxx>, pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CAHnM1zxJj8c6A18YUmjDXDJvc_Nwb=MwzxkCAfwUE3=OGXt25w@xxxxxxxxxxxxxx> (Sitaram Shelke's message of "Wed, 11 May 2016 11:36:00 +0530")
References: <CAHnM1zzTfNgt4Hsgt_Pgq7M-yz+ewd_FehB+QMxixE1MFfKOvA@xxxxxxxxxxxxxx> <572F065E.20601@xxxxxxxxxxxx> <CAHnM1zzfB6H=-oz3HnsvByGSih6Ktj9Zo3cr-kGM5DE4npa60g@xxxxxxxxxxxxxx> <573067F5.9040409@xxxxxxxxxxxx> <CAHnM1zxDgpxK2m5AQ=pL8Dwz1nydtW36ZJC8wkj9axYDdaMiMg@xxxxxxxxxxxxxx> <57307EA4.1070204@xxxxxxxxxxxx> <CAHnM1zxJj8c6A18YUmjDXDJvc_Nwb=MwzxkCAfwUE3=OGXt25w@xxxxxxxxxxxxxx>
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)
sitaramshelke wrote:

> > I have added some code to https://github.com/sitaramshelke/pmapi-procinfo .
> [...]

May I recommend you try the python pmfg (pmFetchGroup) API instead
of the low level one?  It takes care of quite a bit of the hassle.
Based on src/pmclient/pmclient_fg.py , something like:

   class TotalRead():
         ...
         def connect(self):
             /* decode context type & parameter via pmGetOptions* */
             self.fg = pmapi.fetchgroup(....)
             self.pids = self.fg.extend_indom('proc.psinfo.pid')

         def execute(self):
             self.fg.fetch()
             for (pid, pidname, value) in self.pids():
                try:
                    print "PID %d value %d" % (pid, value())
                except:
                    pass


(This the proc.psinfo.pid metric is sort of a reflexive test only,
in that its metric value is exactly the instance-domain-instance code#.)


- FChE

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