2017-11-09 21:23:46 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
Use the following in /etc/munin/plugin-conf.d/wormhole :
|
|
|
|
|
|
|
|
[wormhole_*]
|
|
|
|
env.usagedb /path/to/your/wormhole/server/usage.sqlite
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os, sys, time, sqlite3
|
|
|
|
|
|
|
|
CONFIG = """\
|
|
|
|
graph_title Magic-Wormhole Transit Active Channels
|
|
|
|
graph_vlabel Channels
|
2018-03-28 21:14:31 +00:00
|
|
|
graph_category wormhole
|
2017-11-09 21:23:46 +00:00
|
|
|
waiting.label Transit Waiting
|
|
|
|
waiting.draw LINE1
|
|
|
|
waiting.type GAUGE
|
|
|
|
connected.label Transit Connected
|
|
|
|
connected.draw LINE1
|
|
|
|
connected.type GAUGE
|
|
|
|
"""
|
|
|
|
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
|
|
|
print(CONFIG.rstrip())
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
dbfile = os.environ["usagedb"]
|
|
|
|
assert os.path.exists(dbfile)
|
|
|
|
db = sqlite3.connect(dbfile)
|
|
|
|
|
|
|
|
MINUTE = 60.0
|
2017-11-10 06:09:27 +00:00
|
|
|
updated,waiting,connected = db.execute("SELECT `updated`,`waiting`,`connected`"
|
|
|
|
" FROM `current`").fetchone()
|
|
|
|
if time.time() > updated + 5*MINUTE:
|
2017-11-09 21:23:46 +00:00
|
|
|
sys.exit(1) # expired
|
|
|
|
|
|
|
|
print("waiting.value", waiting)
|
|
|
|
print("connected.value", connected)
|