diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 37 | ||||
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 2 | ||||
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 39 | ||||
| -rw-r--r-- | cli/src/cli-xml-output.c | 46 | 
4 files changed, 88 insertions, 36 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) diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index a7e72dabdf8..9c29b7f3b79 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -2334,7 +2334,7 @@ struct cli_cmd volume_cmds[] = {           cli_cmd_check_gsync_exists_cbk},  #endif -         { "volume profile <VOLNAME> {start | info [incremental | cumulative] | stop} [nfs]", +         { "volume profile <VOLNAME> {start|info [peek|incremental [peek]|cumulative|clear]|stop} [nfs]",             cli_cmd_volume_profile_cbk,             "volume profile operations"}, diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index d1b39014dc9..0b6bcb54b81 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -4775,6 +4775,8 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,          char                              *volname = NULL;          char                              *brick = NULL;          char                              str[1024] = {0,}; +        int                               stats_cleared = 0; +        gf1_cli_info_op                   info_op = GF_CLI_INFO_NONE;          if (-1 == req->rpc_status) {                  goto out; @@ -4840,8 +4842,6 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,                                   (rsp.op_ret) ? "unsuccessful": "successful");                          break;                  case GF_CLI_STATS_INFO: -                case GF_CLI_STATS_INFO_INCREMENTAL: -                case GF_CLI_STATS_INFO_CUMULATIVE:                          break;                  default:                          cli_out ("volume profile on %s has been %s ", @@ -4856,11 +4856,15 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        if (op < GF_CLI_STATS_INFO || GF_CLI_STATS_INFO_CUMULATIVE < op) { +        if (GF_CLI_STATS_INFO != op) {                  ret = 0;                  goto out;          } +        ret = dict_get_int32 (dict, "info-op", (int32_t*)&info_op); +        if (ret) +                goto out; +          ret = dict_get_int32 (dict, "count", &brick_count);          if (ret)                  goto out; @@ -4880,6 +4884,7 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,                  }                  ret = dict_get_str_boolean (dict, "nfs", _gf_false); +                  if (ret)                          snprintf (str, sizeof (str), "NFS Server : %s", brick);                  else @@ -4888,15 +4893,25 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,                  memset (str, '-', strlen (str));                  cli_out ("%s", str); -                snprintf (key, sizeof (key), "%d-cumulative", i); -                ret = dict_get_int32 (dict, key, &interval); -                if (ret == 0) { -                        cmd_profile_volume_brick_out (dict, i, interval); -                } -                snprintf (key, sizeof (key), "%d-interval", i); -                ret = dict_get_int32 (dict, key, &interval); -                if (ret == 0) { -                        cmd_profile_volume_brick_out (dict, i, interval); +                if (GF_CLI_INFO_CLEAR == info_op) { +                        snprintf (key, sizeof (key), "%d-stats-cleared", i); +                        ret = dict_get_int32 (dict, key, &stats_cleared); +                        if (ret) +                                goto out; +                        cli_out (stats_cleared ? "Cleared stats." : +                                                 "Failed to clear stats."); +                } else { +                        snprintf (key, sizeof (key), "%d-cumulative", i); +                        ret = dict_get_int32 (dict, key, &interval); +                        if (ret == 0) +                                cmd_profile_volume_brick_out (dict, i, +                                                              interval); + +                        snprintf (key, sizeof (key), "%d-interval", i); +                        ret = dict_get_int32 (dict, key, &interval); +                        if (ret == 0) +                                cmd_profile_volume_brick_out (dict, i, +                                                              interval);                  }                  i++;          } diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 886c372dc3e..822b98df5d1 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -2229,11 +2229,13 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,          xmlDocPtr               doc = NULL;          char                    *volname = NULL;          int                     op = GF_CLI_STATS_NONE; +        int                     info_op = GF_CLI_INFO_NONE;          int                     brick_count = 0;          char                    *brick_name = NULL;          int                     interval = 0;          char                    key[1024] = {0,};          int                     i = 0; +        int                     stats_cleared = 0;          ret = cli_begin_xml_output (&writer, &doc);          if (ret) @@ -2261,7 +2263,7 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,                                                 "%d", op);          XML_RET_CHECK_AND_GOTO (ret, out); -        if (op < GF_CLI_STATS_INFO || GF_CLI_STATS_INFO_CUMULATIVE < op) +        if (GF_CLI_STATS_INFO != op)                  goto cont;          ret = dict_get_int32 (dict, "count", &brick_count); @@ -2271,6 +2273,10 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,                                                 "%d", brick_count);          XML_RET_CHECK_AND_GOTO (ret, out); +        ret = dict_get_int32 (dict, "info-op", &info_op); +        if (ret) +                goto out; +          while (i < brick_count) {                  i++; @@ -2286,23 +2292,37 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,                          (writer, (xmlChar *)"brickName", "%s", brick_name);                  XML_RET_CHECK_AND_GOTO (ret, out); -                snprintf (key, sizeof (key), "%d-cumulative", i); -                ret = dict_get_int32 (dict, key, &interval); -                if (ret == 0) { -                        ret = cli_xml_output_vol_profile_stats -                                (writer, dict, i, interval); +                if (GF_CLI_INFO_CLEAR == info_op) { +                        snprintf (key, sizeof (key), "%d-stats-cleared", i); +                        ret = dict_get_int32 (dict, key, &stats_cleared);                          if (ret)                                  goto out; -                } -                memset (key, 0, sizeof (key)); -                snprintf (key, sizeof (key), "%d-interval", i); -                ret = dict_get_int32 (dict, key, &interval); -                if (ret == 0) { -                        ret = cli_xml_output_vol_profile_stats -                                (writer, dict, i, interval); +                        ret = xmlTextWriterWriteFormatElement +                                (writer, (xmlChar *)"clearStats", "%s",  +                                stats_cleared ? "Cleared stats." : +                                                 "Failed to clear stats.");                          if (ret)                                  goto out; +                } else { +                        snprintf (key, sizeof (key), "%d-cumulative", i); +                        ret = dict_get_int32 (dict, key, &interval); +                        if (ret == 0) { +                                ret = cli_xml_output_vol_profile_stats +                                        (writer, dict, i, interval); +                                if (ret) +                                        goto out; +                        } + +                        memset (key, 0, sizeof (key)); +                        snprintf (key, sizeof (key), "%d-interval", i); +                        ret = dict_get_int32 (dict, key, &interval); +                        if (ret == 0) { +                                ret = cli_xml_output_vol_profile_stats +                                        (writer, dict, i, interval); +                                if (ret) +                                        goto out; +                        }                  }                  /* </brick> */  | 
