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
|