"Fossies" - the Fresh Open Source Software Archive

Member "dstat-0.7.4/plugins/dstat_memcache_hits.py" (17 Jan 2019, 778 Bytes) of package /linux/privat/dstat-0.7.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "dstat_memcache_hits.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.7.3_vs_0.7.4.

    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])