rewrite munin plugins
This commit is contained in:
parent
638adc71ec
commit
df96f2e590
50
misc/munin/wormhole_active
Executable file
50
misc/munin/wormhole_active
Executable file
|
@ -0,0 +1,50 @@
|
|||
#! /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
|
||||
transit_waiting.label Transit Waiting
|
||||
transit_waiting.draw LINE1
|
||||
transit_waiting.type GAUGE
|
||||
transit_connected.label Transit Connected
|
||||
transit_connected.draw LINE1
|
||||
transit_connected.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"]
|
||||
ta = data["transit"]["active"]
|
||||
print "transit_waiting.value", ta["waiting"]
|
||||
print "transit_connected.value", ta["connected"]
|
|
@ -1,85 +0,0 @@
|
|||
#! /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, sqlite3
|
||||
|
||||
def count_events():
|
||||
serverdir = os.environ["serverdir"]
|
||||
dbfile = os.path.join(serverdir, "relay.sqlite")
|
||||
if not os.path.exists(dbfile):
|
||||
print "cannot find relay.sqlite, please set env.serverdir"
|
||||
sys.exit(1)
|
||||
db = sqlite3.connect(dbfile)
|
||||
db.row_factory = sqlite3.Row
|
||||
|
||||
c_list = []
|
||||
c_dict = {}
|
||||
def add(key, value):
|
||||
c_list.append((key, value))
|
||||
c_dict[key] = value
|
||||
def q(query, values=()):
|
||||
return db.execute(query, values).fetchone()[0]
|
||||
OLD = time.time() - 10*60
|
||||
add("apps", q("SELECT COUNT(DISTINCT(`app_id`)) FROM `nameplates`"))
|
||||
|
||||
add("total nameplates", q("SELECT COUNT() FROM `nameplates`"))
|
||||
add("waiting nameplates", q("SELECT COUNT() FROM `nameplates`"
|
||||
" WHERE `second` is null"))
|
||||
add("connected nameplates", q("SELECT COUNT() FROM `nameplates`"
|
||||
" WHERE `second` is not null"))
|
||||
add("stale nameplates", q("SELECT COUNT() FROM `nameplates`"
|
||||
" where `updated` < ?", (OLD,)))
|
||||
|
||||
add("total mailboxes", q("SELECT COUNT() FROM `mailboxes`"))
|
||||
add("waiting mailboxes", q("SELECT COUNT() FROM `mailboxes`"
|
||||
" WHERE `second` is null"))
|
||||
add("connected mailboxes", q("SELECT COUNT() FROM `mailboxes`"
|
||||
" WHERE `second` is not null"))
|
||||
|
||||
stale_mailboxes = 0
|
||||
for mbox_row in db.execute("SELECT * FROM `mailboxes`").fetchall():
|
||||
newest = db.execute("SELECT `server_rx` FROM `messages`"
|
||||
" WHERE `app_id`=? AND `mailbox_id`=?"
|
||||
" ORDER BY `server_rx` DESC LIMIT 1",
|
||||
(mbox_row["app_id"], mbox_row["id"])).fetchone()
|
||||
if newest and newest[0] < OLD:
|
||||
stale_mailboxes += 1
|
||||
add("stale mailboxes", stale_mailboxes)
|
||||
|
||||
add("messages", q("SELECT COUNT() FROM `messages`"))
|
||||
|
||||
return c_dict
|
||||
|
||||
CONFIG = """\
|
||||
graph_title Magic-Wormhole Active Channels
|
||||
graph_vlabel Channels
|
||||
graph_category network
|
||||
nameplates.label Total Nameplates
|
||||
nameplates.draw LINE2
|
||||
nameplates.type GAUGE
|
||||
waiting_nameplates.label Waiting Nameplates
|
||||
waiting_nameplates.draw LINE2
|
||||
waiting_nameplates.type GAUGE
|
||||
mailboxes.label Total Mailboxes
|
||||
mailboxes.draw LINE2
|
||||
mailboxes.type GAUGE
|
||||
waiting_mailboxes.label Waiting Mailboxes
|
||||
waiting_mailboxes.draw LINE2
|
||||
waiting_mailboxes.type GAUGE
|
||||
"""
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||
print CONFIG.rstrip()
|
||||
sys.exit(0)
|
||||
|
||||
c = count_events()
|
||||
print "nameplates.value", c["total nameplates"]
|
||||
print "waiting_nameplates.value", c["waiting nameplates"]
|
||||
print "mailboxes.value", c["total mailboxes"]
|
||||
print "waiting_mailboxes.value", c["waiting mailboxes"]
|
|
@ -7,88 +7,41 @@ Use the following in /etc/munin/plugin-conf.d/wormhole :
|
|||
env.serverdir /path/to/your/wormhole/server
|
||||
"""
|
||||
|
||||
import os, sys, sqlite3
|
||||
|
||||
def count_events():
|
||||
serverdir = os.environ["serverdir"]
|
||||
dbfile = os.path.join(serverdir, "relay.sqlite")
|
||||
if not os.path.exists(dbfile):
|
||||
print "cannot find relay.sqlite, please set env.serverdir"
|
||||
sys.exit(1)
|
||||
db = sqlite3.connect(dbfile)
|
||||
|
||||
c_list = []
|
||||
c_dict = {}
|
||||
def add(key, value):
|
||||
c_list.append((key, value))
|
||||
c_dict[key] = value
|
||||
def q(query, values=()):
|
||||
return db.execute(query, values).fetchone()[0]
|
||||
|
||||
add("apps", q("SELECT COUNT(DISTINCT(`app_id`)) FROM `nameplate_usage`"))
|
||||
|
||||
add("total nameplates", q("SELECT COUNT() FROM `nameplate_usage`"))
|
||||
add("happy nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='happy'"))
|
||||
add("lonely nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='lonely'"))
|
||||
add("pruney nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='pruney'"))
|
||||
add("crowded nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='crowded'"))
|
||||
|
||||
add("total mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"))
|
||||
add("happy mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='happy'"))
|
||||
add("scary mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='scary'"))
|
||||
add("lonely mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='lonely'"))
|
||||
add("errory mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='errory'"))
|
||||
add("pruney mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='pruney'"))
|
||||
add("crowded mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='crowded'"))
|
||||
|
||||
add("total transit", q("SELECT COUNT() FROM `transit_usage`"))
|
||||
add("happy transit", q("SELECT COUNT() FROM `transit_usage`"
|
||||
" WHERE `result`='happy'"))
|
||||
add("lonely transit", q("SELECT COUNT() FROM `transit_usage`"
|
||||
" WHERE `result`='lonely'"))
|
||||
add("errory transit", q("SELECT COUNT() FROM `transit_usage`"
|
||||
" WHERE `result`='errory'"))
|
||||
|
||||
add("transit bytes", q("SELECT SUM(`total_bytes`) FROM `transit_usage`"))
|
||||
|
||||
return c_dict
|
||||
import os, sys, time, json
|
||||
|
||||
CONFIG = """\
|
||||
graph_title Magic-Wormhole Server Errors
|
||||
graph_vlabel Events per Hour
|
||||
graph_vlabel Events Since Reboot
|
||||
graph_category network
|
||||
nameplates.label Nameplates
|
||||
nameplates.label Nameplate Errors (total)
|
||||
nameplates.draw LINE1
|
||||
nameplates.type DERIVE
|
||||
nameplates.min 0
|
||||
nameplates.cdef nameplates,3600,*
|
||||
mailboxes.label Mailboxes
|
||||
nameplates.type GAUGE
|
||||
mailboxes.label Mailboxes (total)
|
||||
mailboxes.draw LINE1
|
||||
mailboxes.type DERIVE
|
||||
mailboxes.min 0
|
||||
mailboxes.cdef mailboxes,3600,*
|
||||
mailboxes.type GAUGE
|
||||
mailboxes_scary.label Mailboxes (scary)
|
||||
mailboxes_scary.draw LINE1
|
||||
mailboxes_scary.type GAUGE
|
||||
transit.label Transit
|
||||
transit.draw LINE1
|
||||
transit.type DERIVE
|
||||
transit.min 0
|
||||
transit.cdef transit,3600,*
|
||||
transit.type GAUGE
|
||||
"""
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||
print CONFIG.rstrip()
|
||||
sys.exit(0)
|
||||
|
||||
c = count_events()
|
||||
print "nameplates.value", c["total nameplates"] - c["happy nameplates"]
|
||||
print "mailboxes.value", c["total mailboxes"] - c["happy mailboxes"]
|
||||
print "transit.value", c["total transit"] - c["happy transit"]
|
||||
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))
|
||||
|
|
50
misc/munin/wormhole_event_rate
Executable file
50
misc/munin/wormhole_event_rate
Executable file
|
@ -0,0 +1,50 @@
|
|||
#! /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 Server Events
|
||||
graph_vlabel Events per Hour
|
||||
graph_category network
|
||||
happy.label Happy
|
||||
happy.draw LINE
|
||||
happy.type DERIVE
|
||||
happy.min 0
|
||||
happy.max 60
|
||||
happy.cdef happy,3600,*
|
||||
incomplete.label Incomplete
|
||||
incomplete.draw LINE
|
||||
incomplete.type DERIVE
|
||||
incomplete.min 0
|
||||
incomplete.max 60
|
||||
incomplete.cdef happy,3600,*
|
||||
scary.label Scary
|
||||
scary.draw LINE
|
||||
scary.type DERIVE
|
||||
scary.min 0
|
||||
scary.max 60
|
||||
scary.cdef happy,3600,*
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
atm = data["rendezvous"]["all_time"]["mailbox_moods"]
|
||||
print "happy.value", atm.get("happy", 0)
|
||||
print "incomplete.value", (atm.get("pruney", 0) + atm.get("lonely", 0))
|
||||
print "scary.value", atm.get("scary", 0)
|
|
@ -7,88 +7,48 @@ Use the following in /etc/munin/plugin-conf.d/wormhole :
|
|||
env.serverdir /path/to/your/wormhole/server
|
||||
"""
|
||||
|
||||
import os, sys, sqlite3
|
||||
|
||||
def count_events():
|
||||
serverdir = os.environ["serverdir"]
|
||||
dbfile = os.path.join(serverdir, "relay.sqlite")
|
||||
if not os.path.exists(dbfile):
|
||||
print "cannot find relay.sqlite, please set env.serverdir"
|
||||
sys.exit(1)
|
||||
db = sqlite3.connect(dbfile)
|
||||
|
||||
c_list = []
|
||||
c_dict = {}
|
||||
def add(key, value):
|
||||
c_list.append((key, value))
|
||||
c_dict[key] = value
|
||||
def q(query, values=()):
|
||||
return db.execute(query, values).fetchone()[0]
|
||||
|
||||
add("apps", q("SELECT COUNT(DISTINCT(`app_id`)) FROM `nameplate_usage`"))
|
||||
|
||||
add("total nameplates", q("SELECT COUNT() FROM `nameplate_usage`"))
|
||||
add("happy nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='happy'"))
|
||||
add("lonely nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='lonely'"))
|
||||
add("pruney nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='pruney'"))
|
||||
add("crowded nameplates", q("SELECT COUNT() FROM `nameplate_usage`"
|
||||
" WHERE `result`='crowded'"))
|
||||
|
||||
add("total mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"))
|
||||
add("happy mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='happy'"))
|
||||
add("scary mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='scary'"))
|
||||
add("lonely mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='lonely'"))
|
||||
add("errory mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='errory'"))
|
||||
add("pruney mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='pruney'"))
|
||||
add("crowded mailboxes", q("SELECT COUNT() FROM `mailbox_usage`"
|
||||
" WHERE `result`='crowded'"))
|
||||
|
||||
add("total transit", q("SELECT COUNT() FROM `transit_usage`"))
|
||||
add("happy transit", q("SELECT COUNT() FROM `transit_usage`"
|
||||
" WHERE `result`='happy'"))
|
||||
add("lonely transit", q("SELECT COUNT() FROM `transit_usage`"
|
||||
" WHERE `result`='lonely'"))
|
||||
add("errory transit", q("SELECT COUNT() FROM `transit_usage`"
|
||||
" WHERE `result`='errory'"))
|
||||
|
||||
add("transit bytes", q("SELECT SUM(`total_bytes`) FROM `transit_usage`"))
|
||||
|
||||
return c_dict
|
||||
import os, sys, time, json
|
||||
|
||||
CONFIG = """\
|
||||
graph_title Magic-Wormhole Server Events
|
||||
graph_vlabel Events per Hour
|
||||
graph_title Magic-Wormhole Mailbox Events
|
||||
graph_vlabel Events Since Reboot
|
||||
graph_category network
|
||||
nameplates.label Nameplates
|
||||
nameplates.draw LINE
|
||||
nameplates.type DERIVE
|
||||
nameplates.min 0
|
||||
nameplates.cdef nameplates,3600,*
|
||||
mailboxes.label Mailboxes
|
||||
mailboxes.draw LINE
|
||||
mailboxes.type DERIVE
|
||||
mailboxes.min 0
|
||||
mailboxes.cdef mailboxes,3600,*
|
||||
transit.label Transit
|
||||
transit.draw LINE
|
||||
transit.type DERIVE
|
||||
transit.min 0
|
||||
transit.cdef transit,3600,*
|
||||
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)
|
||||
|
||||
c = count_events()
|
||||
print "nameplates.value", c["total nameplates"]
|
||||
print "mailboxes.value", c["total mailboxes"]
|
||||
print "transit.value", c["total transit"]
|
||||
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)
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
#! /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, sqlite3
|
||||
|
||||
def count_events():
|
||||
serverdir = os.environ["serverdir"]
|
||||
dbfile = os.path.join(serverdir, "relay.sqlite")
|
||||
if not os.path.exists(dbfile):
|
||||
print "cannot find relay.sqlite, please set env.serverdir"
|
||||
sys.exit(1)
|
||||
db = sqlite3.connect(dbfile)
|
||||
db.row_factory = sqlite3.Row
|
||||
|
||||
c_list = []
|
||||
c_dict = {}
|
||||
def add(key, value):
|
||||
c_list.append((key, value))
|
||||
c_dict[key] = value
|
||||
def q(query, values=()):
|
||||
return db.execute(query, values).fetchone()[0]
|
||||
OLD = time.time() - 10*60
|
||||
add("apps", q("SELECT COUNT(DISTINCT(`app_id`)) FROM `nameplates`"))
|
||||
|
||||
add("total nameplates", q("SELECT COUNT() FROM `nameplates`"))
|
||||
add("waiting nameplates", q("SELECT COUNT() FROM `nameplates`"
|
||||
" WHERE `second` is null"))
|
||||
add("connected nameplates", q("SELECT COUNT() FROM `nameplates`"
|
||||
" WHERE `second` is not null"))
|
||||
add("stale nameplates", q("SELECT COUNT() FROM `nameplates`"
|
||||
" where `updated` < ?", (OLD,)))
|
||||
|
||||
add("total mailboxes", q("SELECT COUNT() FROM `mailboxes`"))
|
||||
add("waiting mailboxes", q("SELECT COUNT() FROM `mailboxes`"
|
||||
" WHERE `second` is null"))
|
||||
add("connected mailboxes", q("SELECT COUNT() FROM `mailboxes`"
|
||||
" WHERE `second` is not null"))
|
||||
|
||||
stale_mailboxes = 0
|
||||
for mbox_row in db.execute("SELECT * FROM `mailboxes`").fetchall():
|
||||
newest = db.execute("SELECT `server_rx` FROM `messages`"
|
||||
" WHERE `app_id`=? AND `mailbox_id`=?"
|
||||
" ORDER BY `server_rx` DESC LIMIT 1",
|
||||
(mbox_row["app_id"], mbox_row["id"])).fetchone()
|
||||
if newest and newest[0] < OLD:
|
||||
stale_mailboxes += 1
|
||||
add("stale mailboxes", stale_mailboxes)
|
||||
|
||||
add("messages", q("SELECT COUNT() FROM `messages`"))
|
||||
|
||||
return c_dict
|
||||
|
||||
CONFIG = """\
|
||||
graph_title Magic-Wormhole Queued Messages
|
||||
graph_vlabel Messages
|
||||
graph_category network
|
||||
messages.label Total Messages
|
||||
messages.draw LINE2
|
||||
messages.type GAUGE
|
||||
"""
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||
print CONFIG.rstrip()
|
||||
sys.exit(0)
|
||||
|
||||
c = count_events()
|
||||
print "messages.value", c["messages"]
|
|
@ -7,7 +7,7 @@ Use the following in /etc/munin/plugin-conf.d/wormhole :
|
|||
env.serverdir /path/to/your/wormhole/server
|
||||
"""
|
||||
|
||||
import os, sys, sqlite3
|
||||
import os, sys, time, json
|
||||
|
||||
def count_events():
|
||||
serverdir = os.environ["serverdir"]
|
||||
|
@ -65,18 +65,23 @@ def count_events():
|
|||
|
||||
CONFIG = """\
|
||||
graph_title Magic-Wormhole Transit Usage
|
||||
graph_vlabel Bytes per Hour
|
||||
graph_vlabel Bytes Since Reboot
|
||||
graph_category network
|
||||
bytes.label Transit Bytes
|
||||
bytes.draw LINE1
|
||||
bytes.type DERIVE
|
||||
bytes.min 0
|
||||
bytes.cdef bytes,3600,*
|
||||
bytes.type GAUGE
|
||||
"""
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||
print CONFIG.rstrip()
|
||||
sys.exit(0)
|
||||
|
||||
c = count_events()
|
||||
print "bytes.value", c["transit bytes"]
|
||||
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
|
||||
|
||||
t = data["transit"]["since_reboot"]
|
||||
print "bytes.value", t["bytes"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user