Created
January 17, 2012 18:31
-
-
Save daniel-garcia/1628009 to your computer and use it in GitHub Desktop.
Getting rrdcached statistics from zenoss in a zencommand datasource
This file contains 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/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