Ejemplo n.º 1
0
static void
myeventdump(pmValueSet *vsp, int inst, int highres)
{
    int		r;		/* event records */
    int		p;		/* event parameters */
    int		nrecords;
    int		flags;

    if (highres) {
        pmHighResResult	**hr;

        if ((nrecords = pmUnpackHighResEventRecords(vsp, inst, &hr)) < 0) {
            fprintf(stderr, "pmUnpackHighResEventRecords: %s\n",
                    pmErrStr(nrecords));
            return;
        }
        setup_event_derived_metrics();
        for (r = 0; r < nrecords; r++) {
            printf("    --- event record [%d] timestamp ", r);
            __pmPrintHighResStamp(stdout, &hr[r]->timestamp);
            if (dump_nparams(hr[r]->numpmid) < 0)
                continue;
            flags = 0;
            for (p = 0; p < hr[r]->numpmid; p++)
                dump_parameter(hr[r]->vset[p], p, &flags);
        }
        pmFreeHighResEventResult(hr);
    }
    else {
        pmResult	**res;

        if ((nrecords = pmUnpackEventRecords(vsp, inst, &res)) < 0) {
            fprintf(stderr, "pmUnpackEventRecords: %s\n", pmErrStr(nrecords));
            return;
        }
        setup_event_derived_metrics();
        for (r = 0; r < nrecords; r++) {
            printf("    --- event record [%d] timestamp ", r);
            __pmPrintStamp(stdout, &res[r]->timestamp);
            if (dump_nparams(res[r]->numpmid) < 0)
                continue;
            flags = 0;
            for (p = 0; p < res[r]->numpmid; p++)
                dump_parameter(res[r]->vset[p], p, &flags);
        }
        pmFreeEventResult(res);
    }
}
Ejemplo n.º 2
0
static void
dump_event(int numnames, char **names, pmValueSet *vsp, int index, int indom, int type)
{
    int		r;		/* event records */
    int		p;		/* event parameters */
    int		flags;
    int		nrecords;
    int		nmissed = 0;
    int		highres = (type == PM_TYPE_HIGHRES_EVENT);
    char	*iname;
    pmValue	*vp = &vsp->vlist[index];

    if (index > 0)
	printf("            ");
    printf("  %s (", pmIDStr(vsp->pmid));
    __pmPrintMetricNames(stdout, numnames, names, " or ");
    if (indom != PM_INDOM_NULL) {
	putchar('[');
	if (pmNameInDom(indom, vp->inst, &iname) < 0)
	    printf("%d or ???])", vp->inst);
	else {
	    printf("%d or \"%s\"])", vp->inst, iname);
	    free(iname);
	}
    }
    else {
	printf(")");
    }
    printf(": ");

    if (highres) {
	pmHighResResult	**hr;

	if ((nrecords = pmUnpackHighResEventRecords(vsp, index, &hr)) < 0)
	    return;
	if (nrecords == 0) {
	    printf("No event records\n");
	    pmFreeHighResEventResult(hr);
	    return;
	}
	setup_event_derived_metrics();

	for (r = 0; r < nrecords; r++) {
	    if (hr[r]->numpmid == 2 && hr[r]->vset[0]->pmid == pmid_flags &&
		(hr[r]->vset[0]->vlist[0].value.lval & PM_EVENT_FLAG_MISSED) &&
		hr[r]->vset[1]->pmid == pmid_missed) {
		nmissed += hr[r]->vset[1]->vlist[0].value.lval;
	    }
	}
	dump_nrecords(nrecords, nmissed);

	for (r = 0; r < nrecords; r++) {
	    printf("              --- event record [%d] timestamp ", r);
	    __pmPrintHighResStamp(stdout, &hr[r]->timestamp);
	    if (dump_nparams(hr[r]->numpmid) < 0)
		continue;
	    flags = 0;
	    for (p = 0; p < hr[r]->numpmid; p++)
		dump_parameter(hr[r]->vset[p], p, &flags);
	}
	pmFreeHighResEventResult(hr);
    }
    else {
	pmResult	**res;

	if ((nrecords = pmUnpackEventRecords(vsp, index, &res)) < 0)
	    return;
	if (nrecords == 0) {
	    printf("No event records\n");
	    pmFreeEventResult(res);
	    return;
	}
	setup_event_derived_metrics();

	for (r = 0; r < nrecords; r++) {
	    if (res[r]->numpmid == 2 && res[r]->vset[0]->pmid == pmid_flags &&
		(res[r]->vset[0]->vlist[0].value.lval & PM_EVENT_FLAG_MISSED) &&
		res[r]->vset[1]->pmid == pmid_missed) {
		nmissed += res[r]->vset[1]->vlist[0].value.lval;
	    }
	}
	dump_nrecords(nrecords, nmissed);

	for (r = 0; r < nrecords; r++) {
	    printf("              --- event record [%d] timestamp ", r);
	    __pmPrintStamp(stdout, &res[r]->timestamp);
	    if (dump_nparams(res[r]->numpmid) < 0)
		continue;
	    flags = 0;
	    for (p = 0; p < res[r]->numpmid; p++)
		dump_parameter(res[r]->vset[p], p, &flags);
	}
	pmFreeEventResult(res);
    }
}
Ejemplo n.º 3
0
static void
myeventdump(pmValueSet *vsp, int idx, int highres)
{
    int		r;		/* event records */
    int		p;		/* event parameters */
    int		flags;
    int		numpmid;
    int		nrecords;
    pmResult	**res = NULL;
    pmHighResResult **hres = NULL;

    if (highres) {
	if ((nrecords = pmUnpackHighResEventRecords(vsp, idx, &hres)) < 0) {
	    printf(" pmUnpackEventRecords: %s\n", pmErrStr(nrecords));
	    return;
	}
    }
    else {
	if ((nrecords = pmUnpackEventRecords(vsp, idx, &res)) < 0) {
	    printf(" pmUnpackEventRecords: %s\n", pmErrStr(nrecords));
	    return;
	}
    }
    printf(" %d event records\n", nrecords);

    if (pmid_flags == 0) {
	/*
	 * get PMID for event.flags and event.missed
	 * note that pmUnpackEventRecords() will have called
	 * __pmRegisterAnon(), so the anonymous metrics
	 * should now be in the PMNS
	 */
	char	*name_flags = "event.flags";
	char	*name_missed = "event.missed";
	int	sts;

	sts = pmLookupName(1, &name_flags, &pmid_flags);
	if (sts < 0) {
	    /* should not happen! */
	    fprintf(stderr, "Warning: cannot get PMID for %s: %s\n",
			name_flags, pmErrStr(sts));
	    /* avoid subsequent warnings ... */
	    __pmid_int(&pmid_flags)->item = 1;
	}
	sts = pmLookupName(1, &name_missed, &pmid_missed);
	if (sts < 0) {
	    /* should not happen! */
	    fprintf(stderr, "Warning: cannot get PMID for %s: %s\n",
			name_missed, pmErrStr(sts));
	    /* avoid subsequent warnings ... */
	    __pmid_int(&pmid_missed)->item = 1;
	}
    }

    for (r = 0; r < nrecords; r++) {
	printf("  ");
	if (highres) {
	    numpmid = hres[r]->numpmid;
	    __pmPrintHighResStamp(stdout, &hres[r]->timestamp);
	}
	else {
	    numpmid = res[r]->numpmid;
	    __pmPrintStamp(stdout, &res[r]->timestamp);
	}

	printf(" --- event record [%d]", r);
	if (numpmid == 0) {
	    printf(" ---\n");
	    printf("    ==> No parameters\n");
	    continue;
	}
	if (numpmid < 0) {
	    printf(" ---\n");
	    printf("	Error: illegal number of parameters (%d)\n", numpmid);
	    continue;
	}
	flags = 0;
	if (highres) {
	    for (p = 0; p < numpmid; p++)
		myvaluesetdump(hres[r]->vset[p], p, &flags);
	}
	else {
	    for (p = 0; p < numpmid; p++)
		myvaluesetdump(res[r]->vset[p], p, &flags);
	}
    }
    if (highres)
	pmFreeHighResEventResult(hres);
    if (res)
	pmFreeEventResult(res);
}