Skip to content

Instantly share code, notes, and snippets.

@daniel-garcia
Created January 17, 2012 18:31
Show Gist options
  • Save daniel-garcia/1628009 to your computer and use it in GitHub Desktop.
Save daniel-garcia/1628009 to your computer and use it in GitHub Desktop.
Getting rrdcached statistics from zenoss in a zencommand datasource
#!/usr/bin/env python
import socket,os
try:
zenhome = os.environ['ZENHOME']
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(zenhome + "/var/rrdcached.sock")
s.send('STATS\n')
data = s.recv(1024)
s.close()
lines = data.splitlines()[1:]
stats = {}
for line in lines:
key, value = line.split(" ", 1)
stats[key[:len(key)-1]] = int(value)
for key, value in stats.items():
print "%s=%d" %(key, value)
except:
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment