diff --git a/src/pmevent/doargs.c b/src/pmevent/doargs.c index 330266e..27bb66a 100644 --- a/src/pmevent/doargs.c +++ b/src/pmevent/doargs.c @@ -17,7 +17,7 @@ #include "pmevent.h" -static char *options = "a:D:gh:K:LO:p:S:s:T:t:zZ:?"; +static char *options = "a:D:gh:K:LO:p:qS:s:T:t:zZ:?"; static char usage[] = "Usage: %s [options] metricname ...\n\n" "Options:\n" @@ -29,6 +29,7 @@ static char usage[] = " -L metrics source is a local context\n" " -O offset initial offset into the reporting time window\n" " -p port port number for connection to existing time control\n" + " -q quieten the diagnostic output\n" " -S starttime start of the reporting time window\n" " -s samples terminate after this many samples\n" " -T endtime end of the reporting time window\n" @@ -141,6 +142,10 @@ doargs(int argc, char **argv) } break; + case 'q': + quiet++; + break; + case 's': /* sample count */ d = (int)strtol(optarg, &endnum, 10); if (Tflag) { diff --git a/src/pmevent/pmevent.c b/src/pmevent/pmevent.c index 5f4d3c7..c3d6276 100644 --- a/src/pmevent/pmevent.c +++ b/src/pmevent/pmevent.c @@ -29,6 +29,7 @@ static pmTime *pmtime; char *host; /* original host */ char *archive = NULL; /* archive source */ int ahtype = -1; /* archive or host or local context */ +int quiet; /* quieten diagnostic output */ struct timeval now; /* current reporting time */ struct timeval first; /* start reporting time */ struct timeval last = {INT_MAX, 999999}; /* end reporting time */ @@ -166,20 +167,22 @@ lookup(pmInDom indom, int inst) static void myeventdump(pmValueSet *, int); static void -mydump(pmDesc *dp, pmValueSet *vsp) +mydump(const char *name, pmDesc *dp, pmValueSet *vsp) { int j; char *p; if (vsp->numval == 0) { - printf(": No value(s) available!\n"); + if (quiet == 0) + printf("%s: No value(s) available!\n", name); return; } else if (vsp->numval < 0) { - printf(": Error: %s\n", pmErrStr(vsp->numval)); + 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) { @@ -335,8 +338,7 @@ myeventdump(pmValueSet *vsp, int idx) xvsp->vlist[0].value.lval); continue; } - printf(" %s", hp->name); - mydump(&hp->desc, xvsp); + mydump(hp->name, &hp->desc, xvsp); } } if (nrecords >= 0) @@ -429,11 +431,12 @@ main(int argc, char **argv) __pmPrintStamp(stdout, &rp->timestamp); printf(" "); } - if (rp->vset[j]->numval == 0) - printf("%s: No values available\n", mp->name); - else if (rp->vset[j]->numval < 0) + if (rp->vset[j]->numval == 0) { + if (quiet == 0) + printf("%s: No values available\n", mp->name); + } else if (rp->vset[j]->numval < 0) { printf("%s: Error: %s\n", mp->name, pmErrStr(rp->vset[j]->numval)); - else { + } else { int i; for (i = 0; i < rp->vset[j]->numval; i++) { if (rp->vset[j]->vlist[i].inst == PM_IN_NULL) diff --git a/src/pmevent/pmevent.h b/src/pmevent/pmevent.h index 16fd365..1bb4677 100644 --- a/src/pmevent/pmevent.h +++ b/src/pmevent/pmevent.h @@ -40,6 +40,7 @@ void doargs(int, char **); extern char *host; extern char *archive; extern int ahtype; +extern int quiet; extern struct timeval now; extern struct timeval first; extern struct timeval last;