55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#! /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 Reboot
 | 
						|
graph_category network
 | 
						|
total.label Total
 | 
						|
total.draw LINE1
 | 
						|
total.type GAUGE
 | 
						|
happy.label Happy
 | 
						|
happy.draw LINE2
 | 
						|
happy.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
 | 
						|
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"]["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 "scary.value", r["mailbox_moods"].get("scary", 0)
 | 
						|
print "errory.value", r["mailbox_moods"].get("errory", 0)
 |