MB-23556: Add response stats to cbstats 55/76555/4
authorolivermd <oliver.downard@couchbase.com>
Mon, 10 Apr 2017 13:33:41 +0000 (14:33 +0100)
committerDave Rigby <daver@couchbase.com>
Mon, 10 Apr 2017 16:10:50 +0000 (16:10 +0000)
Example output:

$ ./management/cbstats localhost:12000 responses
 SUCCESS: 14410

$ ./ep-engine/management/cbstats localhost:12000 responses all
 AUTH_CONTINUE:                   0
 AUTH_ERROR:                      0
 AUTH_STALE:                      0
 DELTA_BADVAL:                    0
 E2BIG:                           0
 EACCESS:                         0
 EBUSY:                           0
 EINTERNAL:                       0
 EINVAL:                          0
 ENOMEM:                          0
 ERANGE:                          0
 ETMPFAIL:                        0
 KEY_EEXISTS:                     0
 KEY_ENOENT:                      0
 LOCKED:                          0
 NOT_INITIALIZED:                 0
 NOT_MY_VBUCKET:                  0
 NOT_STORED:                      0
 NOT_SUPPORTED:                   0
 NO_BUCKET:                       0
 ROLLBACK:                        0
 SUBDOC_DELTA_EINVAL:             0
 SUBDOC_DOC_NOTJSON:              0
 SUBDOC_INVALID_COMBO:            0
 SUBDOC_MULTI_PATH_FAILURE:       0
 SUBDOC_NUM_ERANGE:               0
 SUBDOC_PATH_E2BIG:               0
 SUBDOC_PATH_E2DEEP:              0
 SUBDOC_PATH_EEXISTS:             0
 SUBDOC_PATH_EINVAL:              0
 SUBDOC_PATH_ENOENT:              0
 SUBDOC_PATH_MISMATCH:            0
 SUBDOC_SUCCESS_DELETED:          0
 SUBDOC_VALUE_CANTINSERT:         0
 SUBDOC_VALUE_ETOODEEP:           0
 SUBDOC_XATTR_INVALID_FLAG_COMBO: 0
 SUBDOC_XATTR_INVALID_KEY_COMBO:  0
 SUBDOC_XATTR_UNKNOWN_MACRO:      0
 SUCCESS:                         24909
 UNKNOWN_COLLECTION:              0
 UNKNOWN_COMMAND:                 0
 XATTR_EINVAL:                    0

Change-Id: Id75d6f19d4302a62c4c4d13274ba09a6bf8a0743
Reviewed-on: http://review.couchbase.org/76555
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
management/cbstats

index 8c9a8eb..41b7336 100755 (executable)
@@ -668,6 +668,20 @@ def stats_tasks(mc, *args):
     tasks_stats_formatter(stats_perform(mc, 'tasks'), *args)
 
 @cmd
+def stats_responses(mc, all=''):
+    resps = json.loads(stats_perform(mc, 'responses')['responses'])
+    c = mc.get_error_map()['errors']
+    d = {}
+    for k, v in resps.iteritems():
+        try:
+            if v > 0 or all:
+                d[c[int(k, 16)]['name']] = v
+        except KeyError:
+            pass # Ignore it, no matching status code
+
+    stats_formatter(d)
+
+@cmd
 def reset(mc):
     stats_perform(mc, 'reset')
 
@@ -694,6 +708,7 @@ def main():
     c.addCommand('prev-vbucket', stats_prev_vbucket, 'prev-vbucket')
     c.addCommand('raw', stats_raw, 'raw argument')
     c.addCommand('reset', reset, 'reset')
+    c.addCommand('responses', stats_responses, 'responses [all]')
     c.addCommand('slabs', stats_slabs, 'slabs (memcached bucket only)')
     c.addCommand('tap', stats_tap, 'tap')
     c.addCommand('tapagg', stats_tapagg, 'tapagg')