Permalink
Browse files

first cut of design

  • Loading branch information...
1 parent 6872a6b commit c3756a8ce07bb4ac13710fba4cca4701e4f0fea6 @bcui6611 bcui6611 committed Mar 29, 2012
Showing with 2,277 additions and 0 deletions.
  1. +25 −0 analyzer.py
  2. +115 −0 buckets.py
  3. +19 −0 cluster.py
  4. +91 −0 cluster_stats.py
  5. +284 −0 dbaccessor.py
  6. +39 −0 diskqueue_stats.py
  7. +160 −0 healthChecker.py
  8. +36 −0 info.py
  9. +81 −0 listservers.py
  10. +442 −0 mc_bin_client.py
  11. +194 −0 memcacheConstants.py
  12. +453 −0 node.py
  13. +163 −0 restclient.py
  14. +162 −0 usage.py
  15. +13 −0 util_cli.py
View
@@ -0,0 +1,25 @@
+import cluster_stats
+import diskqueue_stats
+import dbaccessor
+
+class StatsAnalyzer:
+ def __init__(self):
+ self.accessor = dbaccessor.DbAccesor()
+
+ def run_analysis(self):
+ self.accessor.connect_db()
+ self.accessor.browse_db()
+
+ #print cluster_stats.ClusterCapsule
+ for pill in cluster_stats.ClusterCapsule:
+ #print pill['name']
+ for counter in pill['ingredients']:
+ if counter['type'] == 'SQL':
+ result = self.accessor.execute(counter['code'])
+ print counter["description"], ":", result[0]
+ elif counter['type'] == 'python':
+ result = eval("cluster_stats.{0}().run(self.accessor)".format(counter['code']))
+ print counter["description"], ": ", result
+
+ self.accessor.close()
+ self.accessor.remove_db()
View
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from usage import usage
+
+import restclient
+
+rest_cmds = {
+ 'bucket-list': '/pools/default/buckets',
+ 'bucket-stats': '/pools/default/buckets/{0}/stats?zoom=hour',
+ 'bucket-node-stats': '/pools/default/buckets/{0}/stats/{1}?zoom=day'
+ }
+methods = {
+ 'bucket-list': 'GET',
+ 'bucket-stats': 'GET',
+ 'bucket-node-stats': 'GET',
+ }
+
+stats = [
+ 'cmd_get',
+ 'cmd_set',
+ 'delete_hits',
+ 'ep_tap_total_total_backlog_size',
+ 'curr_items',
+ 'curr_items_tot',
+ 'disk_write_queue',
+ 'curr_connections',
+ ]
+
+class Buckets:
+ def __init__(self):
+ self.debug = False
+ self.rest_cmd = rest_cmds['bucket-list']
+ self.method = 'GET'
+
+ def runCmd(self, cmd, server, port,
+ user, password, opts):
+ self.user = user
+ self.password = password
+
+ bucketname = ''
+ buckettype = ''
+ authtype = 'sasl'
+ bucketport = '11211'
+ bucketpassword = ''
+ bucketramsize = ''
+ bucketreplication = '1'
+ output = 'default'
+
+ for (o, a) in opts:
+ if o == '-b' or o == '--bucket':
+ bucketname = a
+ if o == '--bucket-type':
+ buckettype = a
+ if o == '--bucket-port':
+ bucketport = a
+ if o == '--bucket-password':
+ bucketpassword = a
+ if o == '--bucket-ramsize':
+ bucketramsize = a
+ if o == '--bucket-replica':
+ bucketreplication = a
+ if o == '-d' or o == '--debug':
+ self.debug = True
+ if o in ('-o', '--output'):
+ output = a
+ self.rest_cmd = rest_cmds[cmd]
+ rest = restclient.RestClient(server, port, {'debug':self.debug})
+
+ # get the parameters straight
+
+ opts = {}
+ opts['error_msg'] = "unable to %s" % cmd
+ opts['success_msg'] = "%s" % cmd
+ data = rest.restCmd(methods[cmd], self.rest_cmd,
+ self.user, self.password, opts)
+
+ return rest.getJson(data)
+
+class BucketStats:
+ def __init__(self, bucket_name):
+ self.debug = False
+ self.rest_cmd = rest_cmds['bucket-stats'].format(bucket_name)
+ self.method = 'GET'
+
+ def runCmd(self, cmd, server, port,
+ user, password, opts):
+ opts = {}
+ opts['error_msg'] = "unable to %s" % cmd
+ opts['success_msg'] = "%s" % cmd
+
+ #print server, port, cmd, self.rest_cmd
+ rest = restclient.RestClient(server, port, {'debug':self.debug})
+ data = rest.restCmd(methods[cmd], self.rest_cmd,
+ user, password, opts)
+ return rest.getJson(data)
+
+class BucketNodeStats:
+ def __init__(self, bucket_name, stat_name):
+ self.debug = False
+ self.rest_cmd = rest_cmds['bucket-node-stats'].format(bucket_name, stat_name)
+ self.method = 'GET'
+
+ def runCmd(self, cmd, server, port,
+ user, password, opts):
+ opts = {}
+ opts['error_msg'] = "unable to %s" % cmd
+ opts['success_msg'] = "%s" % cmd
+
+ #print server, port, cmd, self.rest_cmd
+ rest = restclient.RestClient(server, port, {'debug':self.debug})
+ data = rest.restCmd(methods[cmd], self.rest_cmd,
+ user, password, opts)
+ return rest.getJson(data)
+
View
@@ -0,0 +1,19 @@
+
+ClusterCapsule = {
+ "pill" : { "name" : "Node Status",
+ "ingredients" : {
+ "counter" : {
+ "Descripition" : "Number of Nodes",
+ "Code" : "SELECT count(*) FROM ServerNode"
+ },
+ "counter" : {
+ "Descripition" : "Number of Down Nodes",
+ "Code" : "SELECT count(*) FROM ServerNode WHERE status='down'"
+ },
+ "counter" : {
+ "Description" : "Number of Warmup Nodes",
+ "Code" : "SELECT count(*) FROM ServerNode WHERE status='warmup'"
+ }
+ }
+ }
+}
View
@@ -0,0 +1,91 @@
+import dbaccessor
+
+class DGMRatio:
+ def run(self, accessor):
+ hdd = accessor.execute("SELECT sum(usedbyData) FROM StorageInfo WHERE type='hdd'")
+ ram = accessor.execute("SELECT sum(usedbyData) FROM StorageInfo WHERE type='ram'")
+ if ram[0] > 0:
+ ratio = hdd[0] / ram[0]
+ else:
+ ratio = 0
+ return ratio
+
+class ARRatio:
+ def run(self, accessor):
+ active = accessor.execute("SELECT sum(currentItems) FROM SystemStats")
+ replica = accessor.execute("SELECT sum(replicaCurrentItems) FROM SystemStats")
+ if replica[0] > 0:
+ ratio = active[0] / replica[0]
+ else:
+ ratio = 0
+ return ratio
+
+class OpsRatio:
+ def run(self, accessor):
+ ops = accessor.execute("SELECT sum(getOps), sum(setOps), sum(delOps) FROM BucketOps")
+ total = accessor.execute("SELECT count(*) FROM BucketOps")
+ get_avg = ops[0] / total[0]
+ set_avg = ops[1] / total[0]
+ del_avg = ops[2] / total[0]
+ total_avg = get_avg + set_avg + del_avg
+ return (get_avg / total_avg * 100, set_avg / total_avg * 100, del_avg / total_avg * 100)
+
+ClusterCapsule = [
+ {"name" : "Node Status",
+ "ingredients" : [
+ {
+ "description" : "Number of Nodes",
+ "type" : "SQL",
+ "code" : "SELECT count(*) FROM ServerNode"
+ },
+ {
+ "description" : "Number of Down Nodes",
+ "type" : "SQL",
+ "code" : "SELECT count(*) FROM ServerNode WHERE status='down'"
+ },
+ {
+ "description" : "Number of Warmup Nodes",
+ "type" : "SQL",
+ "code" : "SELECT count(*) FROM ServerNode WHERE status='warmup'"
+ }
+ ]
+ },
+ {"name" : "Total Data Size",
+ "ingredients" : [
+ {
+ "description" : "Total Data Size",
+ "type" : "SQL",
+ "code" : "SELECT sum(usedbyData) FROM StorageInfo WHERE type='hdd'"
+ }
+ ]
+ },
+ {"name" : "DGM",
+ "ingredients" : [
+ {
+ "description" : "DGM Ratio",
+ "type" : "python",
+ "code" : "DGMRatio"
+ },
+ ]
+ },
+ {"name" : "Active / Replica Resident Ratio",
+ "ingredients" : [
+ {
+ "description" : " A/R Ratio",
+ "type" : "python",
+ "code" : "ARRatio"
+ },
+ ]
+ },
+ {"name" : "OPS performance",
+ "ingredients" : [
+ {
+ "description" : "Read/Write/Delete ops ratio",
+ "type" : "python",
+ "code" : "OpsRatio"
+ },
+ ]
+ }
+]
+
+
Oops, something went wrong.

0 comments on commit c3756a8

Please sign in to comment.