42 lines
		
	
	
		
			943 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			943 B
		
	
	
	
		
			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 Active Channels
 | 
						|
graph_vlabel Channels
 | 
						|
graph_category network
 | 
						|
nameplates.label Nameplates
 | 
						|
nameplates.draw LINE2
 | 
						|
nameplates.type GAUGE
 | 
						|
mailboxes.label Mailboxes
 | 
						|
mailboxes.draw LINE2
 | 
						|
mailboxes.type GAUGE
 | 
						|
messages.label Messages
 | 
						|
messages.draw LINE1
 | 
						|
messages.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
 | 
						|
 | 
						|
ra = data["rendezvous"]["active"]
 | 
						|
print "nameplates.value", ra["nameplates_total"]
 | 
						|
print "mailboxes.value", ra["mailboxes_total"]
 | 
						|
print "messages.value", ra["messages_total"]
 |