magic-wormhole/misc/munin/wormhole_errors

48 lines
1.2 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 Server Errors
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
nameplates.label Nameplate Errors (total)
nameplates.draw LINE1
2016-06-27 00:15:31 +00:00
nameplates.type GAUGE
mailboxes.label Mailboxes (total)
mailboxes.draw LINE1
2016-06-27 00:15:31 +00:00
mailboxes.type GAUGE
mailboxes_scary.label Mailboxes (scary)
mailboxes_scary.draw LINE1
mailboxes_scary.type GAUGE
2016-05-27 00:46:16 +00:00
transit.label Transit
transit.draw LINE1
2016-06-27 00:15:31 +00:00
transit.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 "nameplates.value", (r["nameplates_total"]
- r["nameplate_moods"].get("happy", 0))
print "mailboxes.value", (r["mailboxes_total"]
- r["mailbox_moods"].get("happy", 0))
t = data["transit"]["since_reboot"]
print "transit.value", (t["total"] - t["moods"].get("happy", 0))