Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   pmExtendFetchGroup_item    ( 3 )

упрощенная выборка и преобразование значений показателей производительности (simplified performance metrics value fetch and conversion)

  Name  |  C synopsis  |  Description  |    Examples    |  Unusual situations  |  Diagnostic  |  See also  |

Примеры (Examples)

The following program demonstrates fetchgroup usage.  Run it with
       different $PCP_DISK_UNITS environment variables to see different
       unit/rate conversion in effect.

#include <pcp/pmapi.h> #include <stdio.h>

#define pcpassert(sts) \ while (sts<0) { fprintf(stderr, "%s\n", pmErrStr(sts)); exit(42); }

int main() { pmFG fg; pmAtomValue v, v2; enum { v3_maxnum = 100 }; pmAtomValue v3_values[v3_maxnum]; char *v3_names[v3_maxnum]; int v3_stss[v3_maxnum]; unsigned int v3_num; int sts, i; char *diskunits = getenv("PCP_DISK_UNITS"); struct timeval t;

sts = pmCreateFetchGroup(&fg, PM_CONTEXT_HOST, "local:"); pcpassert(sts); sts = pmExtendFetchGroup_item(fg, "kernel.all.load", "1 minute", NULL, &v, PM_TYPE_FLOAT, NULL); pcpassert(sts); sts = pmExtendFetchGroup_item(fg, "kernel.all.idletime", NULL, "hour", &v2, PM_TYPE_DOUBLE, NULL); pcpassert(sts); sts = pmExtendFetchGroup_indom(fg, "disk.dev.total", diskunits, NULL, v3_names, v3_values, PM_TYPE_STRING, v3_stss, v3_maxnum, &v3_num, NULL); pcpassert(sts); sts = pmExtendFetchGroup_timestamp(fg, &t); pcpassert(sts);

for (i=0; i < 10; i++) { unsigned int j; char stamp[28];

sts = pmFetchGroup(fg); pcpassert(sts); printf("%s", pmCtime(&t.tv_sec, stamp)); printf("1-minute load: %f; idletime: %f h\n", v.f, v2.d); for (j=0; j < v3_num; j++) { if (v3_stss[j] == 0) printf("disk %s i/o operations (%s): %s\n", v3_names[j] ? v3_names[j] : "?", diskunits ? diskunits : "-", v3_values[j].cp); } sleep(1); }

sts = pmDestroyFetchGroup(fg); pcpassert(sts); return 0; }