munin: improve 'events' ordering, add new plugin

This commit is contained in:
Brian Warner 2016-07-27 18:43:10 -07:00
parent 890b47cad2
commit 27ae3b722c
2 changed files with 65 additions and 13 deletions

View File

@ -13,21 +13,21 @@ CONFIG = """\
graph_title Magic-Wormhole Mailbox Events
graph_vlabel Events Since Reboot
graph_category network
total.label Total
total.draw LINE1
total.type GAUGE
happy.label Happy
happy.draw LINE2
happy.type GAUGE
total.label Total
total.draw LINE1
total.type GAUGE
scary.label Scary
scary.draw LINE2
scary.type GAUGE
pruney.label Pruney
pruney.draw LINE1
pruney.type GAUGE
incomplete.label Incomplete (pruned/lonely)
incomplete.draw LINE2
incomplete.type GAUGE
scary.label Scary
scary.draw LINE1
scary.type GAUGE
lonely.label Lonely
lonely.draw LINE2
lonely.type GAUGE
errory.label Errory
errory.draw LINE1
errory.type GAUGE
@ -45,10 +45,9 @@ if time.time() > data["valid_until"]:
sys.exit(1) # expired
r = data["rendezvous"]["since_reboot"]
print "total.value", r["mailboxes_total"]
print "happy.value", r["mailbox_moods"].get("happy", 0)
print "pruney.value", r["mailbox_moods"].get("pruney", 0)
print "incomplete.value", (r["mailbox_moods"].get("pruney", 0)
+ r["mailbox_moods"].get("lonely", 0))
print "total.value", r["mailboxes_total"]
print "scary.value", r["mailbox_moods"].get("scary", 0)
print "pruney.value", r["mailbox_moods"].get("pruney", 0)
print "lonely.value", r["mailbox_moods"].get("lonely", 0)
print "errory.value", r["mailbox_moods"].get("errory", 0)

View File

@ -0,0 +1,53 @@
#! /usr/bin/env python
"""
Use the following in /etc/munin/plugin-conf.d/wormhole :
[wormhole_*]
env.serverdir /path/to/your/wormhole/server
"""
import os, sys, time, json
CONFIG = """\
graph_title Magic-Wormhole Mailbox Events
graph_vlabel Events Since DB Creation
graph_category network
happy.label Happy
happy.draw LINE2
happy.type GAUGE
total.label Total
total.draw LINE1
total.type GAUGE
scary.label Scary
scary.draw LINE2
scary.type GAUGE
pruney.label Pruney
pruney.draw LINE1
pruney.type GAUGE
lonely.label Lonely
lonely.draw LINE2
lonely.type GAUGE
errory.label Errory
errory.draw LINE1
errory.type GAUGE
"""
if len(sys.argv) > 1 and sys.argv[1] == "config":
print CONFIG.rstrip()
sys.exit(0)
serverdir = os.environ["serverdir"]
fn = os.path.join(serverdir, "stats.json")
with open(fn) as f:
data = json.load(f)
if time.time() > data["valid_until"]:
sys.exit(1) # expired
r = data["rendezvous"]["all_time"]
print "happy.value", r["mailbox_moods"].get("happy", 0)
print "total.value", r["mailboxes_total"]
print "scary.value", r["mailbox_moods"].get("scary", 0)
print "pruney.value", r["mailbox_moods"].get("pruney", 0)
print "lonely.value", r["mailbox_moods"].get("lonely", 0)
print "errory.value", r["mailbox_moods"].get("errory", 0)