Skip to content

Instantly share code, notes, and snippets.

@HarryR
Created October 28, 2011 13:50
Show Gist options
  • Select an option

  • Save HarryR/1322306 to your computer and use it in GitHub Desktop.

Select an option

Save HarryR/1322306 to your computer and use it in GitHub Desktop.
Membase monitor for ServerDensity
#!/usr/bin/env python
import subprocess
import re
class Membase:
def __init__(self, agentConfig, checksLogger, rawConfig):
self.agentConfig = agentConfig
self.checksLogger = checksLogger
self.rawConfig = rawConfig
def run(self):
p = subprocess.Popen(['memstat','--servers=localhost'], stdout=subprocess.PIPE)
out, err = p.communicate()
data = {}
lines = out.splitlines()
header = lines.pop(0)
for line in lines:
line = line.strip().split()
if re.match('^[0-9]+(\.[0-9]+)?$', line[1]):
data[line[0]] = line[1]
return data
if __name__ == "__main__":
mb = Membase(None, None, None)
print mb.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment