magic-wormhole/misc/munin/wormhole_events

54 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-05-27 00:46:16 +00:00
#! /usr/bin/env python
"""
Use the following in /etc/munin/plugin-conf.d/wormhole :
[wormhole_*]
env.serverdir /path/to/your/wormhole/server
"""
2016-06-27 00:15:31 +00:00
import os, sys, time, json
2016-05-27 00:46:16 +00:00
CONFIG = """\
graph_title Magic-Wormhole Mailbox Events (since reboot)
2016-06-27 00:15:31 +00:00
graph_vlabel Events Since Reboot
2016-05-27 00:46:16 +00:00
graph_category network
2016-06-27 00:15:31 +00:00
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
2016-06-27 00:15:31 +00:00
pruney.label Pruney
pruney.draw LINE1
pruney.type GAUGE
lonely.label Lonely
lonely.draw LINE2
lonely.type GAUGE
2016-06-27 00:15:31 +00:00
errory.label Errory
errory.draw LINE1
errory.type GAUGE
2016-05-27 00:46:16 +00:00
"""
if len(sys.argv) > 1 and sys.argv[1] == "config":
print CONFIG.rstrip()
sys.exit(0)
2016-06-27 00:15:31 +00:00
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"]["since_reboot"]
print "happy.value", r["mailbox_moods"].get("happy", 0)
print "total.value", r["mailboxes_total"]
2016-06-27 00:15:31 +00:00
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)
2016-06-27 00:15:31 +00:00
print "errory.value", r["mailbox_moods"].get("errory", 0)