diff options
author | hari gowtham <hgowtham@redhat.com> | 2017-08-21 15:41:42 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2017-09-06 11:52:40 +0000 |
commit | ecef90aa414a4dcb0a0d520be2334f03d06a4451 (patch) | |
tree | 5559c8f7671dd487af8c4205626024a688a1d078 /cli/src | |
parent | b1b49997574eeb7c6a42e6e8257c81ac8d2d7578 (diff) |
Command to identify client process
command: gluster volume status <volname/all> client-list
output:
Client connections for volume v1
Name count
----- ------
fuse 2
tierd 1
total clients for volume v1 : 3
-----------------------------------------------------------------
Client connections for volume v2
Name count
----- ------
tierd 1
fuse.gsync 1
total clients for volume v2 : 2
-----------------------------------------------------------------
Updates: #178
Change-Id: I0ff2579d6adf57cc0d3bd0161a2ec6ac6c4747c0
Signed-off-by: hari gowtham <hgowtham@redhat.com>
Reviewed-on: https://review.gluster.org/18095
Smoke: Gluster Build System <jenkins@build.gluster.org>
Tested-by: hari gowtham <hari.gowtham005@gmail.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 4 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 2 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 139 |
3 files changed, 143 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 984ce5bbad0..ae4f78c522d 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3249,7 +3249,8 @@ cli_cmd_get_statusop (const char *arg) uint32_t ret = GF_CLI_STATUS_NONE; char *w = NULL; char *opwords[] = {"detail", "mem", "clients", "fd", - "inode", "callpool", "tasks", NULL}; + "inode", "callpool", "tasks", "client-list", + NULL}; struct { char *opname; uint32_t opcode; @@ -3261,6 +3262,7 @@ cli_cmd_get_statusop (const char *arg) { "inode", GF_CLI_STATUS_INODE }, { "callpool", GF_CLI_STATUS_CALLPOOL }, { "tasks", GF_CLI_STATUS_TASKS }, + { "client-list", GF_CLI_STATUS_CLIENT_LIST }, { NULL } }; diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index e6d168d3d8f..7bf99eb5e12 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -3289,7 +3289,7 @@ struct cli_cmd volume_cmds[] = { "volume top operations"}, { "volume status [all | <VOLNAME> [nfs|shd|<BRICK>|quotad|tierd]]" - " [detail|clients|mem|inode|fd|callpool|tasks]", + " [detail|clients|mem|inode|fd|callpool|tasks|client-list]", cli_cmd_volume_status_cbk, "display status of all or specified volume(s)/brick"}, diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 03071dd9e45..1840b208431 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -7299,6 +7299,141 @@ out: } void +cli_print_volume_status_client_list (dict_t *dict, gf_boolean_t notbrick) +{ + int ret = -1; + char *volname = NULL; + int client_count = 0; + int current_count = 0; + char key[1024] = {0,}; + int i = 0; + int total = 0; + char *name = NULL; + gf_boolean_t is_fuse_done = _gf_false; + gf_boolean_t is_gfapi_done = _gf_false; + gf_boolean_t is_tierd_done = _gf_false; + gf_boolean_t is_rebalance_done = _gf_false; + gf_boolean_t is_glustershd_done = _gf_false; + gf_boolean_t is_quotad_done = _gf_false; + gf_boolean_t is_snapd_done = _gf_false; + + GF_ASSERT (dict); + + ret = dict_get_str (dict, "volname", &volname); + if (ret) + goto out; + cli_out ("Client connections for volume %s", volname); + + ret = dict_get_int32 (dict, "client-count", &client_count); + if (ret) + goto out; + + cli_out ("%-48s %15s", "Name", "count"); + cli_out ("%-48s %15s", "-----", "------"); + for (i = 0; i < client_count; i++) { + name = NULL; + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), + "client%d.name", i); + ret = dict_get_str (dict, key, &name); + + if (!strncmp (name, "fuse", 4)) { + if (!is_fuse_done) { + is_fuse_done = _gf_true; + ret = dict_get_int32 (dict, + "fuse-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } else if (!strncmp (name, "gfapi", 5)) { + if (!is_gfapi_done) { + is_gfapi_done = _gf_true; + ret = dict_get_int32 (dict, + "gfapi-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } else if (!strcmp(name, "tierd")) { + if (!is_tierd_done) { + is_tierd_done = _gf_true; + ret = dict_get_int32 (dict, + "tierd-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } else if (!strcmp(name, "rebalance")) { + if (!is_rebalance_done) { + is_rebalance_done = _gf_true; + ret = dict_get_int32 (dict, + "rebalance-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } else if (!strcmp(name, "glustershd")) { + if (!is_glustershd_done) { + is_glustershd_done = _gf_true; + ret = dict_get_int32 (dict, + "glustershd-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } else if (!strcmp(name, "quotad")) { + if (!is_quotad_done) { + is_quotad_done = _gf_true; + ret = dict_get_int32 (dict, + "quotad-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } else if (!strcmp(name, "snapd")) { + if (!is_snapd_done) { + is_snapd_done = _gf_true; + ret = dict_get_int32 (dict, + "snapd-count", + ¤t_count); + if (ret) + goto out; + total = total + current_count; + goto print; + } + continue; + } + +print: + cli_out ("%-48s %15d", name, current_count); + + } +out: + cli_out ("\ntotal clients for volume %s : %d ", volname, total); + cli_out ("-----------------------------------------------------------------\n"); + return; +} + +void cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) { int ret = -1; @@ -8293,6 +8428,10 @@ xml_end: cli_print_volume_status_clients (dict, notbrick); goto cont; break; + case GF_CLI_STATUS_CLIENT_LIST: + cli_print_volume_status_client_list (dict, notbrick); + goto cont; + break; case GF_CLI_STATUS_INODE: cli_print_volume_status_inode (dict, notbrick); goto cont; |