summaryrefslogtreecommitdiffstats
path: root/cli/src
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-14 19:08:39 -0800
commit22827d51c232c44a8f5ac003529d907d93baf7b0 (patch)
tree6cd9965c9a87c4332b865a9d602927de62f165e6 /cli/src
parent0598ca33ec95b4f4c44582c6154c52494b910b3a (diff)
bitrot: getting correct value of scrub stat's
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>
Diffstat (limited to 'cli/src')
-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 022f5a1d5f3..d59ff8b6d2c 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -10730,7 +10730,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;
@@ -10784,8 +10788,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;
@@ -10819,7 +10827,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");
@@ -10842,11 +10850,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);