From 27ae3b722cbcbd9f2c50e097b6bc82a9c2038b4f Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 27 Jul 2016 18:43:10 -0700 Subject: [PATCH] munin: improve 'events' ordering, add new plugin --- misc/munin/wormhole_events | 25 +++++++------- misc/munin/wormhole_events_alltime | 53 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 misc/munin/wormhole_events_alltime diff --git a/misc/munin/wormhole_events b/misc/munin/wormhole_events index b40ca75..b070bff 100755 --- a/misc/munin/wormhole_events +++ b/misc/munin/wormhole_events @@ -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) diff --git a/misc/munin/wormhole_events_alltime b/misc/munin/wormhole_events_alltime new file mode 100644 index 0000000..f5e87b6 --- /dev/null +++ b/misc/munin/wormhole_events_alltime @@ -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)