/* * we only ever have one metric */ static void mydump(pmDesc *dp, pmValueSet *vsp, char *indent) { int j; char *p; if (indent != NULL) printf("%s", indent); if (vsp->numval == 0) { printf("No value(s) available!\n"); return; } else if (vsp->numval < 0) { printf("Error: %s\n", pmErrStr(vsp->numval)); return; } for (j = 0; j < vsp->numval; j++) { pmValue *vp = &vsp->vlist[j]; if (dp->indom != PM_INDOM_NULL) { if ((p = lookup(dp->indom, vp->inst)) == NULL) { if (p_force) { /* the instance disappeared; ignore it */ printf(" inst [%d \"%s\"]\n", vp->inst, "DISAPPEARED"); continue; } else { /* report the error and give up */ printf("pmNameIndom: indom=%s inst=%d: %s\n", pmInDomStr(dp->indom), vp->inst, pmErrStr(PM_ERR_INST)); printf(" inst [%d]", vp->inst); } } else printf(" inst [%d or \"%s\"]", vp->inst, p); } else printf(" "); printf(" value "); pmPrintValue(stdout, vsp->valfmt, dp->type, vp, 1); putchar('\n'); if (!events) continue; if (dp->type == PM_TYPE_HIGHRES_EVENT) myeventdump(vsp, j, 1); else if (dp->type == PM_TYPE_EVENT) myeventdump(vsp, j, 0); } }
static void mydump(const char *name, pmDesc *dp, pmValueSet *vsp) { int j; char *p; if (vsp->numval == 0) { if (verbose) printf("%s: No value(s) available!\n", name); return; } else if (vsp->numval < 0) { printf("%s: Error: %s\n", name, pmErrStr(vsp->numval)); return; } printf(" %s", name); for (j = 0; j < vsp->numval; j++) { pmValue *vp = &vsp->vlist[j]; if (dp->indom != PM_INDOM_NULL) { if (vsp->numval > 1) printf("\n "); if ((p = lookup(dp->indom, vp->inst)) == NULL) printf("[%d]", vp->inst); else printf("[\"%s\"]", p); } putchar(' '); switch (dp->type) { case PM_TYPE_AGGREGATE: case PM_TYPE_AGGREGATE_STATIC: { /* * pinched from pmPrintValue, just without the preamble of * floating point values */ char *p; int i; putchar('['); p = &vp->value.pval->vbuf[0]; for (i = 0; i < vp->value.pval->vlen - PM_VAL_HDR_SIZE; i++, p++) printf("%02x", *p & 0xff); putchar(']'); putchar('\n'); break; } case PM_TYPE_EVENT: case PM_TYPE_HIGHRES_EVENT: /* odd, nested event type! */ myeventdump(vsp, j, dp->type != PM_TYPE_EVENT); break; default: pmPrintValue(stdout, vsp->valfmt, dp->type, vp, 1); putchar('\n'); } } }
/* Print event performance metric values */ void printevents(Context *x, pmValueSet *vset, int cols) { int i, sts, highres = (x->desc.type != PM_TYPE_EVENT); unsigned inst; for (i = 0; i < vset->numval; i++) { inst = (unsigned int)vset->vlist[i].inst; if (inst == PM_IN_NULL) printf("%s:", x->metric); else { int k; char *iname = NULL; if (x->inum > 0) { for (k = 0; k < x->inum; k++) { if (x->iids[k] == inst) { iname = x->inames[k]; break; } } } else { /* all instances selected */ __pmHashNode *hnp; hnp = __pmHashSearch(inst, &x->ihash); if (hnp == NULL) { if (archive) sts = pmNameInDomArchive(x->desc.indom, inst, &iname); else sts = pmNameInDom(x->desc.indom, inst, &iname); if (sts < 0) { fprintf(stderr, "%s: pmNameInDom: %s[%u]: %s\n", pmProgname, x->metric, inst, pmErrStr(sts)); exit(EXIT_FAILURE); } if ((sts = __pmHashAdd(inst, (void *)iname, &x->ihash)) < 0) { fprintf(stderr, "%s: __pmHashAdd: %s[%s (%u)]: %s\n", pmProgname, x->metric, iname, inst, pmErrStr(sts)); exit(EXIT_FAILURE); } } else iname = (char *)hnp->data; } if (iname == NULL) continue; printf("%s[%s]:", x->metric, iname); } myeventdump(vset, i, highres); } }