21ab4e
From 005578793abb9a37a81591e107b442acfc2f3ea4 Mon Sep 17 00:00:00 2001
21ab4e
From: Samikshan Bairagya <samikshan@gmail.com>
21ab4e
Date: Mon, 10 Apr 2017 18:46:42 +0530
21ab4e
Subject: [PATCH 613/616] glusterd: Add brick capacity details to get-state CLI
21ab4e
 output
21ab4e
21ab4e
>Reviewed-on: https://review.gluster.org/17029
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
21ab4e
Change-Id: I53fe180e71d41d56b129254b93bb74014a2cdb43
21ab4e
BUG: 1488018
21ab4e
Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/117174
21ab4e
Tested-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/mgmt/glusterd/src/glusterd-handler.c | 19 +++++++++++++++++++
21ab4e
 1 file changed, 19 insertions(+)
21ab4e
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
21ab4e
index 8a781f8..7e24c9b 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
21ab4e
@@ -5270,6 +5270,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
21ab4e
         glusterd_brickinfo_t        *brickinfo = NULL;
21ab4e
         glusterd_snap_t             *snapinfo = NULL;
21ab4e
         xlator_t                    *this = NULL;
21ab4e
+        struct statvfs               brickstat = {0};
21ab4e
         char                        *odir = NULL;
21ab4e
         char                        *filename = NULL;
21ab4e
         char                        *ofilepath = NULL;
21ab4e
@@ -5280,6 +5281,8 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
21ab4e
         char                         timestamp[16] = {0,};
21ab4e
         int                          start_index = 0;
21ab4e
         uint32_t                     get_state_cmd = 0;
21ab4e
+        uint64_t                     memtotal = 0;
21ab4e
+        uint64_t                     memfree = 0;
21ab4e
 
21ab4e
         char    *vol_type_str = NULL;
21ab4e
         char    *hot_tier_type_str = NULL;
21ab4e
@@ -5522,6 +5525,22 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
21ab4e
                                       "Hot" : "Cold");
21ab4e
                         }
21ab4e
 
21ab4e
+                        ret = sys_statvfs (brickinfo->path, &brickstat);
21ab4e
+                        if (ret) {
21ab4e
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
21ab4e
+                                        GD_MSG_FILE_OP_FAILED,
21ab4e
+                                        "statfs error: %s ", strerror (errno));
21ab4e
+                                goto out;
21ab4e
+                        }
21ab4e
+
21ab4e
+                        memfree = brickstat.f_bfree * brickstat.f_bsize;
21ab4e
+                        memtotal = brickstat.f_blocks * brickstat.f_bsize;
21ab4e
+
21ab4e
+                        fprintf (fp, "Volume%d.Brick%d.spacefree: %"PRIu64"Bytes\n",
21ab4e
+                                 count_bkp, count, memfree);
21ab4e
+                        fprintf (fp, "Volume%d.Brick%d.spacetotal: %"PRIu64"Bytes\n",
21ab4e
+                                 count_bkp, count, memtotal);
21ab4e
+
21ab4e
                         if (get_state_cmd != GF_CLI_GET_STATE_DETAIL)
21ab4e
                                 continue;
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e