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: Ryan Doyle <ryan@xxxxxxxxxxxx>
Date: Wed, 11 May 2016 20:01:27 +1000
Cc: mgoodwin@xxxxxxxxxx, Nathan Scott <nathans@xxxxxxxxxx>, pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CAHnM1zxJj8c6A18YUmjDXDJvc_Nwb=MwzxkCAfwUE3=OGXt25w@xxxxxxxxxxxxxx>
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: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0
Hi Sitaram

On 11/05/16 16:06, Sitaram Shelke wrote:

I have added some code to https://github.com/sitaramshelke/pmapi-procinfo .
I was able to print all pids in instances of the metric
'proc.psinfo.pid'  using the normal approach that we used in the
previous example but I could not figure out the way to print external
names of those instances. For example, '024999 bash' for pid  24999.
So I used pmGetInDom() for this. Using this I was able to get pids as
well as names for those instances.
But I want to know is it the right way?

pmGetInDom is the right way to get a internal instance ID to external instance name mapping. The variable you've called "pidlist" on line 30 is actually the internal instance ID. It just to happens that it uses the same ID as the PID (which does make sense).

I've sent you a pull request that shows you how you can get the external instance name from a pmResult (by looking up information in the pmGetInDom call).

It's not the most efficient lookup (it ends up O(n^2)) and not something you would want to do with every pmFetch() call but its good enough for this example.

Also, the pmNameInDom() function could be used to lookup the external instance name from an internal instance ID but we would be doing an API call for each instance in the pmResult.

Lastly, I've moved the card you are working on now to "Doing" on the Wekan board. You're free to move these around too of course so there is no need to wait for me.

Cheers!
Ryan

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