Skip to content

Instantly share code, notes, and snippets.

@rwohleb
Created November 6, 2010 09:54
Show Gist options
  • Save rwohleb/665318 to your computer and use it in GitHub Desktop.
Save rwohleb/665318 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#
# Memcache monitoring plugin for server density
# http://www.serverdensity.com/
#
# Depends on python-memcached
# http://www.tummy.com/Community/software/python-memcached/
# easy_install python-memcached
#
# based on:
# https://gist.github.com/340666/65888413a3930a56e3bf9bf3ad6ffbc94107d5ad
#
import memcache
class Memcached:
def __init__(self, agentConfig, checksLogger, rawConfig):
self.agentConfig = agentConfig
self.checksLogger = checksLogger
self.rawConfig = rawConfig
self.mc = memcache.Client(['localhost:11211'], debug=0)
self.stats = self.mc.get_stats()
def run(self):
try:
data = {
'gets': self.stats[0][1]['cmd_get'],
'sets': self.stats[0][1]['cmd_set'],
'hits': self.stats[0][1]['get_hits'],
'misses': self.stats[0][1]['get_misses']
}
except:
data = {}
return data
if __name__ == '__main__':
mc = Memcached(None, None, None)
print mc.run()
@deplorableword
Copy link

This is awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment