summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorGaurav Kumar Garg <ggarg@redhat.com>2015-03-25 18:07:24 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-11-19 19:41:43 -0800
commit097e131481d25e5b1f859f4ea556b8bf56155472 (patch)
tree0086afbddcf7ea8706a5560484ea30fa9488e102 /cli
parentb479e086ddbcb5cde83c11b67d542dbd4f2bd739 (diff)
glusterd: cli command implementation for bitrot scrub status
CLI command for bitrot scrub status will be : gluster volume bitrot <volname> scrub status Above command will show the statistics of bitrot scrubber. Upon execution of this command it will show some common scrubber tunable value of volume <VOLNAME> followed by statistics of scrubber statistics of individual nodes. sample ouput for single node: Volume name : <VOLNAME> State of scrub: Active Scrub frequency: biweekly Bitrot error log location: /var/log/glusterfs/bitd.log Scrubber error log location: /var/log/glusterfs/scrub.log ========================================================= Node name: Number of Scrubbed files: Number of Unsigned files: Last completed scrub time: Duration of last scrub: Error count: ========================================================= This is just infrastructure. list of bad file, last scrub time, error count value will be taken care by http://review.gluster.org/#/c/12503/ and http://review.gluster.org/#/c/12654/ patches. Change-Id: I3ed3c7057c9d0c894233f4079a7f185d90c202d1 BUG: 1207627 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-on: http://review.gluster.org/10231 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c19
-rw-r--r--cli/src/cli-cmd-volume.c2
-rw-r--r--cli/src/cli-rpc-ops.c163
3 files changed, 181 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 921648f2822..ef07e88b795 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -5116,7 +5116,7 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options)
"biweekly", "monthly",
NULL};
char *scrub_values[] = {"pause", "resume",
- NULL};
+ "status", NULL};
dict_t *dict = NULL;
gf_bitrot_type type = GF_BITROT_OPTION_TYPE_NONE;
int32_t expiry_time = 0;
@@ -5180,6 +5180,23 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options)
}
}
+ if ((strcmp (words[3], "scrub") == 0) &&
+ (strcmp (words[4], "status") == 0)) {
+ if (wordcount == 5) {
+ type = GF_BITROT_CMD_SCRUB_STATUS;
+ ret = dict_set_str (dict, "scrub-value",
+ (char *) words[4]);
+ if (ret) {
+ cli_out ("Failed to set dict for scrub status");
+ goto out;
+ }
+ goto set_type;
+ } else {
+ ret = -1;
+ goto out;
+ }
+ }
+
if (!strcmp (w, "scrub-throttle")) {
if (!words[4]) {
cli_err ("Missing scrub-throttle value for bitrot "
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 86274a85c1d..4e16ce1528f 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -2785,7 +2785,7 @@ struct cli_cmd volume_cmds[] = {
"volume bitrot <volname> scrub-throttle {lazy|normal|aggressive} |\n"
"volume bitrot <volname> scrub-frequency {hourly|daily|weekly|biweekly"
"|monthly} |\n"
- "volume bitrot <volname> scrub {pause|resume}",
+ "volume bitrot <volname> scrub {pause|resume|status}",
cli_cmd_bitrot_cbk,
"Bitrot translator specific operation. For more information about "
"bitrot command type 'man gluster'"
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index ba044efe5d7..27d0595bd3c 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -10666,10 +10666,156 @@ out:
}
int
+gf_cli_print_bitrot_scrub_status (dict_t *dict)
+{
+ int i = 1;
+ int ret = -1;
+ int count = 0;
+ char key[256] = {0,};
+ char *volname = NULL;
+ char *node_name = NULL;
+ char *scrub_freq = NULL;
+ char *state_scrub = NULL;
+ char *scrub_impact = NULL;
+ char *scrub_log_file = NULL;
+ char *bitrot_log_file = NULL;
+ uint64_t scrub_files = 0;
+ uint64_t unsigned_files = 0;
+ uint64_t scrub_time = 0;
+ uint64_t last_scrub = 0;
+ uint64_t error_count = 0;
+
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get volume name");
+
+ ret = dict_get_str (dict, "features.scrub", &state_scrub);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get scrub state value");
+
+ ret = dict_get_str (dict, "features.scrub-throttle", &scrub_impact);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get scrub impact "
+ "value");
+
+ ret = dict_get_str (dict, "features.scrub-freq", &scrub_freq);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get scrub -freq value");
+
+ ret = dict_get_str (dict, "bitrot_log_file", &bitrot_log_file);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get bitrot log file "
+ "location");
+
+ ret = dict_get_str (dict, "scrub_log_file", &scrub_log_file);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get scrubber log file "
+ "location");
+
+ ret = dict_get_int32 (dict, "count", &count);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "count not get count value from"
+ " dictionary");
+ goto out;
+ }
+
+ cli_out ("\n%s: %s\n", "Volume name ", volname);
+
+ cli_out ("%s: %s\n", "State of scrub", state_scrub);
+
+ cli_out ("%s: %s\n", "Scrub impact", scrub_impact);
+
+ cli_out ("%s: %s\n", "Scrub frequency", scrub_freq);
+
+ cli_out ("%s: %s\n", "Bitrot error log location", bitrot_log_file);
+
+ cli_out ("%s: %s\n", "Scrubber error log location", scrub_log_file);
+
+
+ for (i = 1; i <= count; i++) {
+ /* Reset the variables to prevent carryover of values */
+ node_name = NULL;
+ last_scrub = 0;
+ scrub_time = 0;
+ error_count = 0;
+ scrub_files = 0;
+ unsigned_files = 0;
+
+ memset (key, 0, 256);
+ snprintf (key, 256, "node-name-%d", i);
+ ret = dict_get_str (dict, key, &node_name);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get node-name");
+
+ memset (key, 0, 256);
+ snprintf (key, 256, "scrubbed-files-%d", i);
+ ret = dict_get_uint64 (dict, key, &scrub_files);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get scrubbed "
+ "files");
+
+ memset (key, 0, 256);
+ snprintf (key, 256, "unsigned-files-%d", i);
+ ret = dict_get_uint64 (dict, key, &unsigned_files);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get unsigned "
+ "files");
+
+ memset (key, 0, 256);
+ snprintf (key, 256, "scrub-duration-%d", i);
+ ret = dict_get_uint64 (dict, key, &scrub_time);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get last scrub "
+ "duration");
+
+ memset (key, 0, 256);
+ snprintf (key, 256, "last-scrub-time-%d", i);
+ ret = dict_get_uint64 (dict, key, &last_scrub);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get last scrub"
+ " time");
+
+ memset (key, 0, 256);
+ snprintf (key, 256, "error-count-%d", i);
+ ret = dict_get_uint64 (dict, key, &error_count);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get error "
+ "count");
+
+ cli_out ("\n%s\n", "=========================================="
+ "===============");
+
+ cli_out ("%s: %s\n", "Node name", node_name);
+
+ cli_out ("%s: %"PRIu64 "\n", "Number of Scrubbed files",
+ scrub_files);
+
+ 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: %"PRIu64 "\n", "Error count", error_count);
+
+ }
+ cli_out ("%s\n", "=========================================="
+ "===============");
+
+out:
+ return 0;
+}
+
+int
gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
int ret = -1;
+ int type = 0;
gf_cli_rsp rsp = {0, };
dict_t *dict = NULL;
call_frame_t *frame = NULL;
@@ -10723,6 +10869,22 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_DEBUG, "Received resp to bit rot command");
+ ret = dict_get_int32 (dict, "type", &type);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get command type");
+ goto out;
+ }
+
+ if ((type == GF_BITROT_CMD_SCRUB_STATUS) &&
+ !(global_state->mode & GLUSTER_MODE_XML)) {
+ ret = gf_cli_print_bitrot_scrub_status (dict);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to print bitrot "
+ "scrub status");
+ }
+ goto out;
+ }
+
xml_output:
if (global_state->mode & GLUSTER_MODE_XML) {
ret = cli_xml_output_vol_profile (dict, rsp.op_ret,
@@ -10749,7 +10911,6 @@ out:
cli_cmd_broadcast_response (ret);
return ret;
-
}
int32_t