From e0601593bd7f4f26056040c3b1c3337499d05430 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 23 Jan 2015 22:43:46 +0100 Subject: [PATCH] Add log support to smart command --- cmdline/device.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmdline/device.c b/cmdline/device.c index 01b2ffed..787e4c6a 100644 --- a/cmdline/device.c +++ b/cmdline/device.c @@ -24,8 +24,8 @@ /** * Annual Failure Rate data points from Backblaze. * - * From: - * https://www.backblaze.com/blog-smart-stats-2014-8.html + * From: https://www.backblaze.com/blog-smart-stats-2014-8.html + * Mentioned link for future update: https://www.backblaze.com/smart */ struct afr_point { uint64_t value; /**< Value of the SMART raw attribute. */ @@ -143,7 +143,7 @@ static double smart_afr_value(struct afr_point* tab, uint64_t value) * Note that this definition is different from the one given * by Seagate, that defines AFR = 1 - exp(-8760/MTBF), that * instead represents the probability of a failure in the next - * year, and then we call it as AFP (Annual Failure Probability). + * year. * * To combine the different AFR from different SMART attributes, * we sums them as we assume that they are independent, @@ -406,6 +406,16 @@ static void state_smart(unsigned n, tommy_list* low) printf("- (not in stats)"); printf("\n"); + + fprintf(stdlog, "smart:%s:%s:%s:%g\n", devinfo->file, devinfo->name, devinfo->smart_serial, afr); + for (j = 0; j < 256; ++j) { + if (devinfo->smart[j] != SMART_UNASSIGNED) + fprintf(stdlog, "attr:%s:%u:%" PRIu64 "\n", devinfo->file, j, devinfo->smart[j]); + } + if (devinfo->smart[SMART_SIZE] != SMART_UNASSIGNED) + fprintf(stdlog, "attr:%s:size:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_SIZE]); + if (devinfo->smart[SMART_ERROR] != SMART_UNASSIGNED) + fprintf(stdlog, "attr:%s:error:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_ERROR]); } printf("\n"); @@ -416,6 +426,8 @@ static void state_smart(unsigned n, tommy_list* low) */ p_at_least_one_failure = poisson_prob_n_or_more_failures(array_failure_rate, 1); + fprintf(stdlog, "summary:array_failure:%g:%g\n", array_failure_rate, p_at_least_one_failure); + /* |<##################################################################72>|####80>| */ printf("The FP column is the probability (in percentage) that the disk is going\n"); printf("to fail in the next year.\n");