Ticket #1079: patch_scsiprint_v1.02.diff

File patch_scsiprint_v1.02.diff, 2.8 KB (added by Rick Chen, 6 years ago)
  • scsiprint.cpp

    diff --git a/scsiprint.cpp b/scsiprint.cpp
    index cca0dcc..5576b60 100644
    a b scsiGetSmartData(scsi_device * device, bool attribs)  
    332332        }
    333333        if (255 == triptemp)
    334334            pout("Drive Trip Temperature:        <not available>\n");
    335         else
    336             pout("Drive Trip Temperature:        %d C\n", triptemp);
     335        else {
     336            jout("Drive Trip Temperature:        %d C\n", triptemp);
     337            jglb["temperature"]["drive_trip"] = triptemp;
     338    }
    337339    }
    338340    pout("\n");
    339341    return err;
    scsiPrintErrorCounterLog(scsi_device * device)  
    828830             "algorithm      processed    uncorrected\n");
    829831        pout("           fast | delayed   rewrites  corrected  "
    830832             "invocations   [10^9 bytes]  errors\n");
     833
     834        json::ref jref = jglb["scsi_error_counter_log"];
    831835        for (int k = 0; k < 3; ++k) {
    832836            if (! found[k])
    833837                continue;
    834838            ecp = &errCounterArr[k];
    835839            static const char * const pageNames[3] =
    836840                                 {"read:   ", "write:  ", "verify: "};
    837             pout("%s%8" PRIu64 " %8" PRIu64 "  %8" PRIu64 "  %8" PRIu64
     841            static const char * jpageNames[3] =
     842                                 {"read", "write", "verify"};
     843            jout("%s%8" PRIu64 " %8" PRIu64 "  %8" PRIu64 "  %8" PRIu64
    838844                 "   %8" PRIu64, pageNames[k], ecp->counter[0],
    839845                 ecp->counter[1], ecp->counter[2], ecp->counter[3],
    840846                 ecp->counter[4]);
    841847            double processed_gb = ecp->counter[5] / 1000000000.0;
    842             pout("   %12.3f    %8" PRIu64 "\n", processed_gb,
     848            jout("   %12.3f    %8" PRIu64 "\n", processed_gb,
    843849                 ecp->counter[6]);
     850            // Error counter log info
     851            jref[jpageNames[k]]["errors_corrected_by_eccfast"] = ecp->counter[0];
     852            jref[jpageNames[k]]["errors_corrected_by_eccdelayed"] = ecp->counter[1];
     853            jref[jpageNames[k]]["errors_corrected_by_rereads_rewrites"] = ecp->counter[2];
     854            jref[jpageNames[k]]["total_errors_corrected"] = ecp->counter[3];
     855            jref[jpageNames[k]]["correction_algorithm_invocations"] = ecp->counter[4];
     856            jref[jpageNames[k]]["gigabytes_processed"] = strprintf("%.3f", processed_gb);
     857            jref[jpageNames[k]]["total_uncorrected_errors"] = ecp->counter[6];
    844858        }
    845859    }
    846860    else
    scsiPrintTemp(scsi_device * device)  
    22242238    }
    22252239    if (255 == trip)
    22262240        pout("Drive Trip Temperature:        <not available>\n");
    2227     else
    2228         pout("Drive Trip Temperature:        %d C\n", trip);
     2241    else {
     2242        jout("Drive Trip Temperature:        %d C\n", trip);
     2243        jglb["temperature"]["drive_trip"] = trip;
     2244    }
    22292245    pout("\n");
    22302246}
    22312247