diff options
| author | Kaushal M <kaushal@redhat.com> | 2012-01-01 15:59:28 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2012-01-27 04:20:04 -0800 | 
| commit | 623919a78a7faac30d1f0df5793681da2c449e32 (patch) | |
| tree | ee213fa96ebf5feb938babf36c34cb7c8d5f6a24 /xlators/protocol/server/src | |
| parent | a078235dbede380ca695251e86a1502ca131d816 (diff) | |
cli: Extend "volume status" with statedump info
This patch enhances and extends the "volume status" command with information
obtained from the statedump of the bricks of volumes.
Adds new status types : clients, inode, fd, mem, callpool
The new syntax of "volume status" is,
 #gluster volume status [all|{<volname> [<brickname>]
                         [misc-details|clients|inode|fd|mem|callpool]}]
Change-Id: I8d019718465bbc3de727653a839de7238f45da5c
BUG: 765495
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/2637
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Diffstat (limited to 'xlators/protocol/server/src')
| -rw-r--r-- | xlators/protocol/server/src/server.c | 139 | 
1 files changed, 136 insertions, 3 deletions
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index d767199d0a7..60bc517ddbe 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -164,6 +164,38 @@ ret:  /* */  int +server_fd_to_dict (xlator_t *this, dict_t *dict) +{ +        server_conf_t           *conf = NULL; +        server_connection_t     *trav = NULL; +        char                    key[GF_DUMP_MAX_BUF_LEN] = {0,}; +        int                     count = 0; +        int                     ret = -1; + +        GF_VALIDATE_OR_GOTO (THIS->name, this, out); +        GF_VALIDATE_OR_GOTO (this->name, dict, out); + +        conf = this->private; +        if (!conf) +                return -1; + +        ret = pthread_mutex_trylock (&conf->mutex); +        if (ret) +                return -1; + +        list_for_each_entry (trav, &conf->conns, list) { +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "conn%d", count++); +                fdtable_dump_to_dict (trav->fdtable, key, dict); +        } +        pthread_mutex_unlock (&conf->mutex); + +        ret = dict_set_int32 (dict, "conncount", count); +out: +        return ret; +} + +int  server_fd (xlator_t *this)  {          server_conf_t        *conf = NULL; @@ -218,6 +250,53 @@ out:  }  int +server_priv_to_dict (xlator_t *this, dict_t *dict) +{ +        server_conf_t   *conf = NULL; +        rpc_transport_t *xprt = NULL; +        peer_info_t     *peerinfo = NULL; +        char            key[32] = {0,}; +        int             count = 0; +        int             ret = -1; + +        GF_VALIDATE_OR_GOTO (THIS->name, this, out); +        GF_VALIDATE_OR_GOTO (THIS->name, dict, out); + +        conf = this->private; +        if (!conf) +                return 0; +        //TODO: Dump only specific info to dict + +        list_for_each_entry (xprt, &conf->xprt_list, list) { +                peerinfo = &xprt->peerinfo; +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "client%d.hostname", count); +                ret = dict_set_str (dict, key, peerinfo->identifier); +                if (ret) +                        goto out; + +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "client%d.bytesread", count); +                ret = dict_set_uint64 (dict, key, xprt->total_bytes_read); +                if (ret) +                        goto out; + +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "client%d.byteswrite", count); +                ret = dict_set_uint64 (dict, key, xprt->total_bytes_write); +                if (ret) +                        goto out; + +                count++; +        } + +        ret = dict_set_int32 (dict, "clientcount", count); + +out: +        return ret; +} + +int  server_priv (xlator_t *this)  {          server_conf_t    *conf = NULL; @@ -250,6 +329,57 @@ out:  }  int +server_inode_to_dict (xlator_t *this, dict_t *dict) +{ +        server_conf_t           *conf = NULL; +        server_connection_t     *trav = NULL; +        char                    key[32] = {0,}; +        int                     count = 0; +        int                     ret = -1; +        xlator_t                *prev_bound_xl = NULL; + +        GF_VALIDATE_OR_GOTO (THIS->name, this, out); +        GF_VALIDATE_OR_GOTO (this->name, dict, out); + +        conf = this->private; +        if (!conf) +                return -1; + +        ret = pthread_mutex_trylock (&conf->mutex); +        if (ret) +                return -1; + +        list_for_each_entry (trav, &conf->conns, list) { +                if (trav->bound_xl && trav->bound_xl->itable) { +                        /* Presently every brick contains only one +                         * bound_xl for all connections. This will lead +                         * to duplicating of the inode lists, if listing +                         * is done for every connection. This simple check +                         * prevents duplication in the present case. If +                         * need arises the check can be improved. +                         */ +                        if (trav->bound_xl == prev_bound_xl) +                                continue; +                        prev_bound_xl = trav->bound_xl; + +                        memset (key, 0, sizeof (key)); +                        snprintf (key, sizeof (key), "conn%d", count); +                        inode_table_dump_to_dict (trav->bound_xl->itable, +                                                  key, dict); +                        count++; +                } +        } +        pthread_mutex_unlock (&conf->mutex); + +        ret = dict_set_int32 (dict, "conncount", count); + +out: +        if (prev_bound_xl) +                prev_bound_xl = NULL; +        return ret; +} + +int  server_inode (xlator_t *this)  {          server_conf_t        *conf = NULL; @@ -811,9 +941,12 @@ struct xlator_cbks cbks = {  };  struct xlator_dumpops dumpops = { -        .priv  = server_priv, -        .fd    = server_fd, -        .inode = server_inode, +        .priv           = server_priv, +        .fd             = server_fd, +        .inode          = server_inode, +        .priv_to_dict   = server_priv_to_dict, +        .fd_to_dict     = server_fd_to_dict, +        .inode_to_dict  = server_inode_to_dict,  };  | 
