1 ### Author: Dean Wilson <dean.wilson@gmail.com> 2 3 class dstat_plugin(dstat): 4 """ 5 Memcache hit count plugin. 6 7 Displays the number of memcache get_hits and get_misses. 8 """ 9 def __init__(self): 10 self.name = 'Memcache Hits' 11 self.nick = ('Hit', 'Miss') 12 self.vars = ('get_hits', 'get_misses') 13 self.type = 'd' 14 self.width = 6 15 self.scale = 50 16 17 def check(self): 18 try: 19 global memcache 20 import memcache 21 self.mc = memcache.Client(['127.0.0.1:11211'], debug=0) 22 except: 23 raise Exception('Plugin needs the memcache module') 24 25 def extract(self): 26 stats = self.mc.get_stats() 27 for key in self.vars: 28 self.val[key] = int(stats[0][1][key])