summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-02-27 12:41:24 +0530
committerVijay Bellur <vijay@gluster.com>2012-03-14 02:27:42 -0700
commita476aba5b0368c3bc649db319ee748ae410144d9 (patch)
treeac6ea7e9ac361f3516ae2a2867f3c2d5aa86e047 /cli/src/cli-rpc-ops.c
parentfcb5ebde1e84da871a7f43df9ecbce7d1d1de435 (diff)
cli, glusterd, nfs: "volume status|profile|top" for nfs servers
Enables usage of volume monitoring operations "volume status", "volume top" and "volume profile" for nfs servers. These operations can be performed on nfs-servers by passing "nfs" as an option in cli. The output is similar to the normal brick outputs for these commands. The new syntaxes for the changed commands are as below, #gluster volume profile <VOLNAME> {start|info|stop} [nfs] #gluster volume top <VOLNAME> {[open|read|write|opendir|readdir [nfs]] |[read-perf|write-perf [nfs|{bs <size> count <count>}]]} [brick <brick>] [list-cnt <count>] #gluster volume status [all | <VOLNAME> [nfs|<BRICK>]] [detail|clients|mem|inode|fd|callpool] Change-Id: Ia6eb50c60aecacf9b413d3ea993f4cdd90ec0e07 BUG: 795267 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/2820 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c85
1 files changed, 64 insertions, 21 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 20688b09..dbef04a9 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -3506,7 +3506,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval)
uint64_t sec = 0;
uint64_t r_count = 0;
uint64_t w_count = 0;
- char *brick = NULL;
uint64_t rb_counts[32] = {0};
uint64_t wb_counts[32] = {0};
cli_profile_info_t profile_info[GF_FOP_MAXVALUE] = {{0}};
@@ -3519,9 +3518,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval)
int ret = 0;
double total_percentage_latency = 0;
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%d-brick", count);
- ret = dict_get_str (dict, key, &brick);
for (i = 0; i < 32; i++) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%d-%d-read-%d", count,
@@ -3584,7 +3580,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval)
ret = dict_get_uint64 (dict, key, &w_count);
if (ret == 0) {
- cli_out ("Brick: %s", brick);
}
if (interval == -1)
@@ -3681,6 +3676,9 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
int i = 1;
int32_t brick_count = 0;
char *volname = NULL;
+ char *brick = NULL;
+ char str[1024] = {0,};
+
if (-1 == req->rpc_status) {
goto out;
}
@@ -3775,6 +3773,23 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
while (i <= brick_count) {
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "%d-brick", i);
+ ret = dict_get_str (dict, key, &brick);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Couldn't get brick name");
+ goto out;
+ }
+
+ ret = dict_get_str_boolean (dict, "nfs", _gf_false);
+ if (ret)
+ snprintf (str, sizeof (str), "NFS Server : %s", brick);
+ else
+ snprintf (str, sizeof (str), "Brick: %s", brick);
+ cli_out (str);
+ memset (str, '-', strlen (str));
+ cli_out (str);
+
snprintf (key, sizeof (key), "%d-cumulative", i);
ret = dict_get_int32 (dict, key, &interval);
if (ret == 0) {
@@ -3935,7 +3950,12 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
ret = dict_get_str (dict, brick, &bricks);
if (ret)
goto out;
- cli_out ("Brick: %s", bricks);
+ ret = dict_get_str_boolean (dict, "nfs", _gf_false);
+ if (ret)
+ cli_out ("NFS Server : %s", bricks);
+ else
+ cli_out ("Brick: %s", bricks);
+
snprintf(key, sizeof (key), "%d-members", i);
ret = dict_get_int32 (dict, key, &members);
@@ -4237,7 +4257,7 @@ out:
}
void
-cli_print_volume_status_mem (dict_t *dict)
+cli_print_volume_status_mem (dict_t *dict, gf_boolean_t nfs)
{
int ret = -1;
char *volname = NULL;
@@ -4273,7 +4293,10 @@ cli_print_volume_status_mem (dict_t *dict)
ret = dict_get_str (dict, key, &path);
if (ret)
goto out;
- cli_out ("Brick : %s:%s", hostname, path);
+ if (nfs)
+ cli_out ("%s : %s", hostname, path);
+ else
+ cli_out ("Brick : %s:%s", hostname, path);
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.status", i);
@@ -4368,7 +4391,7 @@ out:
}
void
-cli_print_volume_status_clients (dict_t *dict)
+cli_print_volume_status_clients (dict_t *dict, gf_boolean_t nfs)
{
int ret = -1;
char *volname = NULL;
@@ -4408,7 +4431,11 @@ cli_print_volume_status_clients (dict_t *dict)
ret = dict_get_str (dict, key, &path);
if (ret)
goto out;
- cli_out ("Brick : %s:%s", hostname, path);
+
+ if (nfs)
+ cli_out ("%s : %s", hostname, path);
+ else
+ cli_out ("Brick : %s:%s", hostname, path);
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.status", i);
@@ -4609,7 +4636,7 @@ out:
}
void
-cli_print_volume_status_inode (dict_t *dict)
+cli_print_volume_status_inode (dict_t *dict, gf_boolean_t nfs)
{
int ret = -1;
char *volname = NULL;
@@ -4646,7 +4673,10 @@ cli_print_volume_status_inode (dict_t *dict)
ret = dict_get_str (dict, key, &path);
if (ret)
goto out;
- cli_out ("Brick : %s:%s", hostname, path);
+ if (nfs)
+ cli_out ("%s : %s", hostname, path);
+ else
+ cli_out ("Brick : %s:%s", hostname, path);
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.status", i);
@@ -4762,7 +4792,7 @@ out:
}
void
-cli_print_volume_status_fd (dict_t *dict)
+cli_print_volume_status_fd (dict_t *dict, gf_boolean_t nfs)
{
int ret = -1;
char *volname = NULL;
@@ -4799,7 +4829,11 @@ cli_print_volume_status_fd (dict_t *dict)
ret = dict_get_str (dict, key, &path);
if (ret)
goto out;
- cli_out ("Brick : %s:%s", hostname, path);
+
+ if (nfs)
+ cli_out ("%s : %s", hostname, path);
+ else
+ cli_out ("Brick : %s:%s", hostname, path);
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.status", i);
@@ -4976,7 +5010,7 @@ cli_print_volume_status_call_stack (dict_t *dict, char *prefix)
}
void
-cli_print_volume_status_callpool (dict_t *dict)
+cli_print_volume_status_callpool (dict_t *dict, gf_boolean_t nfs)
{
int ret = -1;
char *volname = NULL;
@@ -5013,7 +5047,11 @@ cli_print_volume_status_callpool (dict_t *dict)
ret = dict_get_str (dict, key, &path);
if (ret)
goto out;
- cli_out ("Brick : %s:%s", hostname, path);
+
+ if (nfs)
+ cli_out ("%s : %s", hostname, path);
+ else
+ cli_out ("Brick : %s:%s", hostname, path);
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "brick%d.status", i);
@@ -5058,6 +5096,7 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,
int i = 0;
int pid = -1;
uint32_t cmd = 0;
+ gf_boolean_t nfs = _gf_false;
char key[1024] = {0,};
char *hostname = NULL;
char *path = NULL;
@@ -5101,6 +5140,10 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,
ret = 0;
goto out;
}
+
+ if (cmd & GF_CLI_STATUS_NFS)
+ nfs = _gf_true;
+
ret = dict_get_int32 (dict, "count", &count);
if (ret)
goto out;
@@ -5125,23 +5168,23 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,
switch (cmd & GF_CLI_STATUS_MASK) {
case GF_CLI_STATUS_MEM:
- cli_print_volume_status_mem (dict);
+ cli_print_volume_status_mem (dict, nfs);
goto cont;
break;
case GF_CLI_STATUS_CLIENTS:
- cli_print_volume_status_clients (dict);
+ cli_print_volume_status_clients (dict, nfs);
goto cont;
break;
case GF_CLI_STATUS_INODE:
- cli_print_volume_status_inode (dict);
+ cli_print_volume_status_inode (dict, nfs);
goto cont;
break;
case GF_CLI_STATUS_FD:
- cli_print_volume_status_fd (dict);
+ cli_print_volume_status_fd (dict, nfs);
goto cont;
break;
case GF_CLI_STATUS_CALLPOOL:
- cli_print_volume_status_callpool (dict);
+ cli_print_volume_status_callpool (dict, nfs);
goto cont;
break;
default: