mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Converted imapproxy_ to multigraph
This commit is contained in:
parent
a80fce235d
commit
e316273af8
1 changed files with 61 additions and 87 deletions
|
@ -3,7 +3,7 @@
|
|||
"""=cut
|
||||
=head1 NAME
|
||||
|
||||
imapproxy - Munin Plugin to monitor imapproxy using pimpstat
|
||||
imapproxy - Munin multigraph plugin to monitor imapproxy using pimpstat
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
|||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 Author
|
||||
|
||||
|
@ -40,111 +40,85 @@ def print_autoconf():
|
|||
sys.exit(0)
|
||||
|
||||
|
||||
def print_config(graph):
|
||||
if graph == "cache":
|
||||
print "graph_title Cache Statistics For ImapProxy"
|
||||
print "graph_args -l 0 --base 1000"
|
||||
print "graph_total total"
|
||||
print "graph_vlabel Cache Connections / ${graph_period}"
|
||||
print "graph_category imapproxy"
|
||||
print "cache_hits.draw AREA"
|
||||
print "cache_hits.type DERIVE"
|
||||
print "cache_hits.label Cache Hits"
|
||||
print "cache_hits.min 0"
|
||||
print "cache_misses.draw STACK"
|
||||
print "cache_misses.type DERIVE"
|
||||
print "cache_misses.label Cache Misses"
|
||||
print "cache_misses.min 0"
|
||||
if graph == "connections":
|
||||
print "graph_title Connection Statistics For ImapProxy"
|
||||
print "graph_args -l 0 --base 1000"
|
||||
print "graph_total total"
|
||||
print "graph_vlabel Connections / ${graph_period}"
|
||||
print "graph_category imapproxy"
|
||||
print "connections_reused.draw AREA"
|
||||
print "connections_reused.type DERIVE"
|
||||
print "connections_reused.label Reused Connections"
|
||||
print "connections_reused.min 0"
|
||||
print "connections_created.draw STACK"
|
||||
print "connections_created.type DERIVE"
|
||||
print "connections_created.label Created Connections"
|
||||
print "connections_created.min 0"
|
||||
def print_config():
|
||||
print "multigraph imapproxy_cache"
|
||||
print "graph_title Cache Statistics For ImapProxy"
|
||||
print "graph_args -l 0 --base 1000"
|
||||
print "graph_total total"
|
||||
print "graph_vlabel Cache Connections / ${graph_period}"
|
||||
print "graph_category imapproxy"
|
||||
print "cache_hits.draw AREA"
|
||||
print "cache_hits.type DERIVE"
|
||||
print "cache_hits.label Cache Hits"
|
||||
print "cache_hits.min 0"
|
||||
print "cache_misses.draw STACK"
|
||||
print "cache_misses.type DERIVE"
|
||||
print "cache_misses.label Cache Misses"
|
||||
print "cache_misses.min 0"
|
||||
print
|
||||
print "multigraph imapproxy_connections"
|
||||
print "graph_title Connection Statistics For ImapProxy"
|
||||
print "graph_args -l 0 --base 1000"
|
||||
print "graph_total total"
|
||||
print "graph_vlabel Connections / ${graph_period}"
|
||||
print "graph_category imapproxy"
|
||||
print "connections_reused.draw AREA"
|
||||
print "connections_reused.type DERIVE"
|
||||
print "connections_reused.label Reused Connections"
|
||||
print "connections_reused.min 0"
|
||||
print "connections_created.draw STACK"
|
||||
print "connections_created.type DERIVE"
|
||||
print "connections_created.label Created Connections"
|
||||
print "connections_created.min 0"
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def print_suggest():
|
||||
print "cache"
|
||||
print "connections"
|
||||
sys.exit(0)
|
||||
|
||||
def print_fetch(graph):
|
||||
if graph == "cache":
|
||||
hits = 0
|
||||
misses = 0
|
||||
cache = Popen(
|
||||
"pimpstat -c | egrep 'Cache (Hits|Misses)'",
|
||||
shell=True,
|
||||
stdout=PIPE
|
||||
)
|
||||
for line in cache.stdout:
|
||||
if re.search(r'Hits', line):
|
||||
hits = line.split()[0]
|
||||
if re.search(r'Misses', line):
|
||||
misses = line.split()[0]
|
||||
print "cache_hits.value %s" % hits
|
||||
print "cache_misses.value %s" % misses
|
||||
if graph == "connections":
|
||||
created = 0
|
||||
reused = 0
|
||||
connections = Popen(
|
||||
"pimpstat -c | egrep 'Total (Reused|Created)'",
|
||||
shell=True,
|
||||
stdout=PIPE
|
||||
)
|
||||
for line in connections.stdout:
|
||||
if re.search(r'Created', line):
|
||||
created = line.split()[0]
|
||||
if re.search(r'Reused', line):
|
||||
reused = line.split()[0]
|
||||
print "connections_created.value %s" % created
|
||||
print "connections_reused.value %s" % resused
|
||||
def print_fetch():
|
||||
cache_hits = 0
|
||||
cache_misses = 0
|
||||
connections_created = 0
|
||||
connections_reused = 0
|
||||
connections = Popen(
|
||||
"pimpstat -c | egrep '(Total (Reused|Created)|Cache (Hits|Misses))'",
|
||||
shell=True,
|
||||
stdout=PIPE
|
||||
)
|
||||
for line in connections.stdout:
|
||||
if re.search(r'Hits', line):
|
||||
cache_hits = line.split()[0]
|
||||
if re.search(r'Misses', line):
|
||||
cache_misses = line.split()[0]
|
||||
if re.search(r'Created', line):
|
||||
connections_created = line.split()[0]
|
||||
if re.search(r'Reused', line):
|
||||
connections_reused = line.split()[0]
|
||||
print "multigraph imapproxy_cache"
|
||||
print "cache_hits.value %s" % cache_hits
|
||||
print "cache_misses.value %s" % cache_misses
|
||||
print
|
||||
print "multigraph imapproxy_connections"
|
||||
print "connections_created.value %s" % connections_created
|
||||
print "connections_reused.value %s" % connections_reused
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
def main():
|
||||
basename = "imapproxy_"
|
||||
calledname = os.path.basename(sys.argv[0])
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
command = sys.argv[1]
|
||||
else:
|
||||
command = "fetch"
|
||||
|
||||
if calledname == basename and command == "fetch":
|
||||
print >> sys.stderr, "Please use either suggest or autoconf"
|
||||
sys.exit(1)
|
||||
if calledname == basename and command not in ["autoconf","suggest"]:
|
||||
if command not in ["autoconf","config","fetch"]:
|
||||
print >> sys.stderr, "Command %s not known, please use either autoconf or suggest" % command
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
graph = calledname[calledname.find("_")+1:]
|
||||
if calledname != basename and graph not in ["cache","connections"]:
|
||||
print >> sys.stderr, "%s is not a known graph" % graph
|
||||
sys.exit(1)
|
||||
|
||||
if calledname != basename and command not in ["config", "fetch"]:
|
||||
print >> sys.stderr, "Command %s not known, please use either config or fetch" % command
|
||||
sys.exit(1)
|
||||
|
||||
if command == "autoconf":
|
||||
print_autoconf()
|
||||
elif command == "config":
|
||||
print_config(graph)
|
||||
elif command =="suggest":
|
||||
print_suggest()
|
||||
print_config()
|
||||
else:
|
||||
print_fetch(graph)
|
||||
print_fetch()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue