summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorGaurav Kumar Garg <garg.gaurav52@gmail.com>2015-11-25 17:38:43 +0530
committerVenky Shankar <vshankar@redhat.com>2015-12-17 19:29:00 -0800
commit530533fe44f08f30d1230c65db0054be7c6d3281 (patch)
treef28c4122cb9a18d8fb55df6a91495987bbbda146 /cli
parent459314829691e3cb0c31f4971111d7dadfb199d8 (diff)
bitrot: getting correct value of scrub stat's
This patch is backport of: http://review.gluster.org/#/c/12776/ When user execute bitrot scrub status command then gluster is not giving correct value of Number of Scrubbed files, Number of Unsigned files, Last completed scrub time, Duration of last scrub. With this patch scrub status will give correct value for all the above fields. >> Change-Id: Ic966f76d22db5b0c889e6386a1c2219afbda1f49 >> BUG: 1285989 >> Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> >> Signed-off-by: Kotresh HR <khiremat@redhat.com> >> Reviewed-on: http://review.gluster.org/12776 >> Tested-by: NetBSD Build System <jenkins@build.gluster.org> >> Tested-by: Gluster Build System <jenkins@build.gluster.com> >> Reviewed-by: Venky Shankar <vshankar@redhat.com> Change-Id: Ic966f76d22db5b0c889e6386a1c2219afbda1f49 BUG: 1291546 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> (cherry picked from commit 22827d51c232c44a8f5ac003529d907d93baf7b0) Change-Id: Icef24cce35c8d54ffdfa5282491338318e78780b Reviewed-on: http://review.gluster.org/12966 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index b623051cad9..6dcf0f37e3f 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -10736,7 +10736,11 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
uint64_t scrub_files = 0;
uint64_t unsigned_files = 0;
uint64_t scrub_time = 0;
- uint64_t last_scrub = 0;
+ uint64_t days = 0;
+ uint64_t hour = 0;
+ uint64_t minut = 0;
+ uint64_t second = 0;
+ char *last_scrub = NULL;
uint64_t error_count = 0;
@@ -10790,8 +10794,12 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
for (i = 1; i <= count; i++) {
/* Reset the variables to prevent carryover of values */
node_name = NULL;
- last_scrub = 0;
+ last_scrub = NULL;
scrub_time = 0;
+ days = 0;
+ hour = 0;
+ minut = 0;
+ second = 0;
error_count = 0;
scrub_files = 0;
unsigned_files = 0;
@@ -10825,7 +10833,7 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
memset (key, 0, 256);
snprintf (key, 256, "last-scrub-time-%d", i);
- ret = dict_get_uint64 (dict, key, &last_scrub);
+ ret = dict_get_str (dict, key, &last_scrub);
if (ret)
gf_log ("cli", GF_LOG_TRACE, "failed to get last scrub"
" time");
@@ -10848,11 +10856,17 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
cli_out ("%s: %"PRIu64 "\n", "Number of Unsigned files",
unsigned_files);
- cli_out ("%s: %"PRIu64 "\n", "Last completed scrub time",
- scrub_time);
-
- cli_out ("%s: %"PRIu64 "\n", "Duration of last scrub",
- last_scrub);
+ cli_out ("%s: %s\n", "Last completed scrub time",
+ (*last_scrub) ? last_scrub : "Scrubber pending to "
+ "complete.");
+
+ /* Printing last scrub duration time in human readable form*/
+ days = scrub_time/86400;
+ hour = (scrub_time%86400)/3600;
+ minut = (scrub_time%86400%3600)/60;
+ second = (scrub_time%86400%3600%60);
+ cli_out ("%s: %"PRIu64 ":%"PRIu64 ":%"PRIu64 ":%"PRIu64 "\n",
+ "Duration of last scrub", days, hour, minut, second);
cli_out ("%s: %"PRIu64 "\n", "Error count", error_count);