Hi -
I have finally made some progress on the "fetchgroup" api extension
that we had talked about a year ago and then some [1]. It's starting
to come together, and am looking for feedback on design or smaller
issues.
The work is all on git://sourceware.org/git/pcpfans.git fche/fetchgroup .
The core implementation is in libpcp/src/fetchgroup.c; a man page in
man/man3/pmfetchgroup.3 with a sample program (below); and adapts
src/pmmgr and src/pmclient to the api. QA and fixes are coming. The
man page would be a good one to start from. I'd be happy to explain
further.
#include <pcp/pmapi.h>
#include <assert.h>
#include <stdio.h>
int main () {
pmFG fg;
pmAtomValue v, v2;
int sts, i;
int c = pmNewContext(PM_CONTEXT_HOST, "local:");
assert (c >= 0);
sts = pmCreateFetchGroup(&fg);
assert (sts == 0);
sts = pmExtendFetchGroup_item(fg, "kernel.all.load", "1 minute",
NULL, &v, PM_TYPE_FLOAT, NULL);
assert (sts == 0);
sts = pmExtendFetchGroup_item(fg, "kernel.all.idletime", NULL,
"hour", &v2, PM_TYPE_DOUBLE, NULL);
assert (sts == 0);
for (i=0; i<10; i++) {
sts = pmFetchGroup(fg);
assert (sts == 0);
printf ("1-minute load: %f; idletime: %f h\n", v.f, v2.d);
sleep (1);
}
sts = pmDestroyFetchGroup(fg);
assert (sts == 0);
pmDestroyContext (c);
}
[1] http://oss.sgi.com/archives/pcp/2014-10/msg00029.html
- FChE
|