diff options
author | Dawit Alemu <dalemu@redhat.com> | 2013-12-30 22:59:39 -0500 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-01-24 02:05:35 -0800 |
commit | 48b8186bdc2f5e45b58aadf849b2bd60c9a77330 (patch) | |
tree | b6c3c49cb40bf14572da45b346a54ab175739859 /cli/src/cli-cmd-parser.c | |
parent | bb63256b7ea1f186bbe3fae9040a6c191c9d6544 (diff) |
cli: Add options to the CLI that let the user control the reset of
stats
"volume profile info" automatically clears incremental stats. There
isn't a command to:
- fetch stats without clearing incremental stats and
- clear cumulative and incremental stats
This change introduces two arguments (i.e. peek and clear). 'clear'
will wipe both incremental and cumulative stats. 'peek' fetches stats
without wiping incremental stats.
'volume profile info peek' - fetches incremental and cumulative stats
without wiping incremental stats
'volume profile info incremental peek' - fetches incremental stats
without wiping incremental stats
'volume profile info clear' - clears both incremental and cumultiave
stats
Change-Id: I91834515ad672eca5f882809941147d7d997c4c9
BUG: 1047416
Signed-off-by: Dawit Alemu <dalemu@redhat.com>
Reviewed-on: http://review.gluster.org/6620
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index dd9398184aa..7a2ff026d88 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1972,10 +1972,13 @@ int32_t cli_cmd_volume_profile_parse (const char **words, int wordcount, dict_t **options) { - dict_t *dict = NULL; - char *volname = NULL; - int ret = -1; - gf1_cli_stats_op op = GF_CLI_STATS_NONE; + dict_t *dict = NULL; + char *volname = NULL; + int ret = -1; + gf1_cli_stats_op op = GF_CLI_STATS_NONE; + gf1_cli_info_op info_op = GF_CLI_INFO_NONE; + gf_boolean_t is_peek = _gf_false; + char *opwords[] = { "start", "stop", "info", NULL }; char *w = NULL; @@ -2005,7 +2008,7 @@ cli_cmd_volume_profile_parse (const char **words, int wordcount, wordcount > 5) goto out; - if (strcmp (w, "info") == 0 && wordcount > 6) + if (strcmp (w, "info") == 0 && wordcount > 7) goto out; if (strcmp (w, "start") == 0) { @@ -2014,16 +2017,22 @@ cli_cmd_volume_profile_parse (const char **words, int wordcount, op = GF_CLI_STATS_STOP; } else if (strcmp (w, "info") == 0) { op = GF_CLI_STATS_INFO; + info_op = GF_CLI_INFO_ALL; if (wordcount > 4) { if (strcmp (words[4], "incremental") == 0) { - op = GF_CLI_STATS_INFO_INCREMENTAL; + info_op = GF_CLI_INFO_INCREMENTAL; + if (wordcount > 5 && + strcmp (words[5], "peek") == 0) { + is_peek = _gf_true; + } } else if (strcmp (words[4], "cumulative") == 0) { - op = GF_CLI_STATS_INFO_CUMULATIVE; + info_op = GF_CLI_INFO_CUMULATIVE; + } else if (strcmp (words[4], "clear") == 0) { + info_op = GF_CLI_INFO_CLEAR; + } else if (strcmp (words[4], "peek") == 0) { + is_peek = _gf_true; } } - ret = dict_set_int32 (dict, "info-op", op); - if (ret) - goto out; } else GF_ASSERT (!"opword mismatch"); @@ -2031,6 +2040,14 @@ cli_cmd_volume_profile_parse (const char **words, int wordcount, if (ret) goto out; + ret = dict_set_int32 (dict, "info-op", (int32_t)info_op); + if (ret) + goto out; + + ret = dict_set_int32 (dict, "peek", is_peek); + if (ret) + goto out; + if (!strcmp (words[wordcount - 1], "nfs")) { ret = dict_set_int32 (dict, "nfs", _gf_true); if (ret) |