Created
November 6, 2010 09:54
-
-
Save rwohleb/665318 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is awesome, thanks!