Repository
Munin (contrib)
Last change
2017-02-23
Graph Categories
Keywords
Language
Python (2.x)

zeomonitor

Sadly there is no documentation for this plugin.

#!/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"

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()