2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/zope/zeomonitor

48 lines
1.1 KiB
Plaintext
Raw Normal View History

2008-07-03 06:59:52 +02:00
#!/usr/bin/env python
def safe(s):
s = s.replace("-", "_")
s = s.replace(" ", "_")
s = s.replace(".", "_")
return s
def config(data):
for i in data:
print "%s.label %s"%(safe(i[0]), i[0])
if i[0].startswith("Clients"):
pass
else:
print "%s.type DERIVE"%safe(i[0])
print "graph_title zeo %s per minute"%i[0]
print "graph_args -l 0"
print "graph_vlabel n"
print "graph_period minute"
print "graph_category appserver"
2008-07-03 06:59:52 +02:00
def get_data():
import sys
from socket import socket, AF_INET, SOCK_STREAM
field = sys.argv[0].split("_",1)[1]
s=socket(AF_INET, SOCK_STREAM)
s.connect(("localhost", 8101))
data=s.recv(2048).split("\n")
s.close()
data = [d.split(": ") for d in data [5:-2]]
if field:
data = [ d for d in data if safe(d[0]) == field]
return data
def sample(data):
for i in data:
print "%s.value %s"%(i[0].replace(" ","_"),i[1])
def main():
import sys
data = get_data()
if 'config' in sys.argv:
return config(data)
sample(data)
if __name__ == '__main__':
main()