summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-parser.c4
-rw-r--r--cli/src/cli-cmd-volume.c2
-rw-r--r--cli/src/cli-rpc-ops.c139
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",
+ &current_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",
+ &current_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",
+ &current_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",
+ &current_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",
+ &current_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",
+ &current_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",
+ &current_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;