From: Michael Meffie Date: Fri, 9 Apr 2010 15:46:10 +0000 (-0400) Subject: afsmonitor: avoid showing full perf stats garbage X-Git-Tag: openafs-devel-1_5_74~46 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7214af16a9cc23632f2a00d035e6c0afec887e55;p=packages%2Fo%2Fopenafs.git afsmonitor: avoid showing full perf stats garbage Unfortunately, the full perf stats contain timeval structures which do not have the same size everywhere. Avoid displaying gargbage, but at least try to show the overall stats. Change-Id: I9245b333ac15212194490e1a3f11b7c98dfaadda Reviewed-on: http://gerrit.openafs.org/1730 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afsmonitor/afsmon-output.c b/src/afsmonitor/afsmon-output.c index 1dc0e5907..f9d9b5612 100644 --- a/src/afsmonitor/afsmon-output.c +++ b/src/afsmonitor/afsmon-output.c @@ -368,14 +368,6 @@ Print_fs_FullPerfInfo(struct xstat_fs_ProbeResults *a_fs_Results) char *printableTime; /*Ptr to printable time string */ time_t probeTime; - numLongs = a_fs_Results->data.AFS_CollData_len; - if (numLongs != fullPerfLongs) { - fprintf(fs_outFD, - " ** Data size mismatch in full performance collection!\n"); - fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs, - numLongs); - return; - } probeTime = a_fs_Results->probeTime; printableTime = ctime(&probeTime); @@ -388,8 +380,24 @@ Print_fs_FullPerfInfo(struct xstat_fs_ProbeResults *a_fs_Results) a_fs_Results->collectionNumber, a_fs_Results->connP->hostName, a_fs_Results->probeNum, printableTime); - Print_fs_OverallPerfInfo(&(fullPerfP->overall)); - Print_fs_DetailedPerfInfo(&(fullPerfP->det)); + numLongs = a_fs_Results->data.AFS_CollData_len; + if (numLongs != fullPerfLongs) { + fprintf(fs_outFD, + " ** Data size mismatch in full performance collection!\n"); + fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs, + numLongs); + + /* Unfortunately, the full perf stats contain timeval structures which + * do not have the same size everywhere. At least try to print + * the overall stats. + */ + if (numLongs >= (sizeof(struct afs_stats_CMPerf) / sizeof(afs_int32))) { + Print_fs_OverallPerfInfo(&(fullPerfP->overall)); + } + } else { + Print_fs_OverallPerfInfo(&(fullPerfP->overall)); + Print_fs_DetailedPerfInfo(&(fullPerfP->det)); + } } /*Print_fs_FullPerfInfo */ diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index 08e3b4e77..be0351a21 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -1808,6 +1808,7 @@ fs_Results_ltoa(struct fs_Display_Data *a_fsData, /* target buffer */ int idx; int i, j; afs_int32 *tmpbuf; + afs_int32 numInt32s; if (afsmon_debug) { fprintf(debugFD, "[ %s ] Called, a_fsData= %p, a_fsResults= %p\n", rn, @@ -1823,6 +1824,25 @@ fs_Results_ltoa(struct fs_Display_Data *a_fsData, /* target buffer */ * - fullPerfP->det which gives detailed info about file server operation * execution times */ + /* + * Unfortunately, the full perf stats contain timeval structures which + * do not have the same size everywhere. Avoid displaying gargbage, + * but at least try to show the overall stats. + */ + numInt32s = a_fsResults->data.AFS_CollData_len; + if (numInt32s != + (sizeof(struct fs_stats_FullPerfStats) / sizeof(afs_int32))) { + srcbuf = a_fsResults->data.AFS_CollData_val; + for (i = 0; i < NUM_FS_STAT_ENTRIES; i++) { + if (i < numInt32s && i < NUM_XSTAT_FS_AFS_PERFSTATS_LONGS) { + sprintf(a_fsData->data[i], "%d", srcbuf[i]); + } else { + sprintf(a_fsData->data[i], "%s", "--"); + } + } + return 0; + } + /* copy overall performance statistics */ srcbuf = (afs_int32 *) & (fullPerfP->overall); idx = 0;