afsmonitor: avoid showing full perf stats garbage
authorMichael Meffie <mmeffie@sinenomine.net>
Fri, 9 Apr 2010 15:46:10 +0000 (11:46 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 9 Apr 2010 20:08:43 +0000 (13:08 -0700)
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 <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afsmonitor/afsmon-output.c
src/afsmonitor/afsmonitor.c

index 1dc0e59..f9d9b56 100644 (file)
@@ -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 */
 
index 08e3b4e..be0351a 100644 (file)
@@ -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;