munin: track not-yet-complete usage bytes too
This commit is contained in:
parent
135280a922
commit
9c44ee13cd
|
@ -14,9 +14,12 @@ CONFIG = """\
|
||||||
graph_title Magic-Wormhole Transit Usage (since reboot)
|
graph_title Magic-Wormhole Transit Usage (since reboot)
|
||||||
graph_vlabel Bytes Since Reboot
|
graph_vlabel Bytes Since Reboot
|
||||||
graph_category network
|
graph_category network
|
||||||
bytes.label Transit Bytes
|
bytes.label Transit Bytes (complete)
|
||||||
bytes.draw LINE1
|
bytes.draw LINE1
|
||||||
bytes.type GAUGE
|
bytes.type GAUGE
|
||||||
|
incomplete.label Transit Bytes (incomplete)
|
||||||
|
incomplete.draw LINE1
|
||||||
|
incomplete.type GAUGE
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||||
|
@ -28,10 +31,12 @@ assert os.path.exists(dbfile)
|
||||||
db = sqlite3.connect(dbfile)
|
db = sqlite3.connect(dbfile)
|
||||||
|
|
||||||
MINUTE = 60.0
|
MINUTE = 60.0
|
||||||
updated,rebooted = db.execute("SELECT `updated`,`rebooted` FROM `current`").fetchone()
|
updated,rebooted,incomplete = db.execute("SELECT `updated`,`rebooted`,`incomplete_bytes` FROM `current`").fetchone()
|
||||||
if time.time() > updated + 5*MINUTE:
|
if time.time() > updated + 5*MINUTE:
|
||||||
sys.exit(1) # expired
|
sys.exit(1) # expired
|
||||||
|
|
||||||
value = db.execute("SELECT SUM(`total_bytes`) FROM `usage` WHERE `started` > ?",
|
complete = db.execute("SELECT SUM(`total_bytes`) FROM `usage`"
|
||||||
(rebooted,)).fetchone()[0] or 0
|
" WHERE `started` > ?",
|
||||||
print("bytes.value", value)
|
(rebooted,)).fetchone()[0] or 0
|
||||||
|
print("bytes.value", complete)
|
||||||
|
print("incomplete.value", complete+incomplete)
|
||||||
|
|
|
@ -14,9 +14,12 @@ CONFIG = """\
|
||||||
graph_title Magic-Wormhole Transit Usage (all time)
|
graph_title Magic-Wormhole Transit Usage (all time)
|
||||||
graph_vlabel Bytes Since DB Creation
|
graph_vlabel Bytes Since DB Creation
|
||||||
graph_category network
|
graph_category network
|
||||||
bytes.label Transit Bytes
|
bytes.label Transit Bytes (complete)
|
||||||
bytes.draw LINE1
|
bytes.draw LINE1
|
||||||
bytes.type GAUGE
|
bytes.type GAUGE
|
||||||
|
incomplete.label Transit Bytes (incomplete)
|
||||||
|
incomplete.draw LINE1
|
||||||
|
incomplete.type GAUGE
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
||||||
|
@ -28,9 +31,12 @@ assert os.path.exists(dbfile)
|
||||||
db = sqlite3.connect(dbfile)
|
db = sqlite3.connect(dbfile)
|
||||||
|
|
||||||
MINUTE = 60.0
|
MINUTE = 60.0
|
||||||
updated = db.execute("SELECT `updated` FROM `current`").fetchone()[0]
|
updated,incomplete = db.execute("SELECT `updated`,`incomplete_bytes`"
|
||||||
|
" FROM `current`").fetchone()
|
||||||
if time.time() > updated + 5*MINUTE:
|
if time.time() > updated + 5*MINUTE:
|
||||||
sys.exit(1) # expired
|
sys.exit(1) # expired
|
||||||
|
|
||||||
value = db.execute("SELECT SUM(`total_bytes`) FROM `usage`").fetchone()[0] or 0
|
complete = db.execute("SELECT SUM(`total_bytes`)"
|
||||||
print("bytes.value", value)
|
" FROM `usage`").fetchone()[0] or 0
|
||||||
|
print("bytes.value", complete)
|
||||||
|
print("incomplete.value", complete+incomplete)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user