misc/dump-stats.py: tool to show stats.json validity
Run like 'watch python misc/dump-stats.py' against a 'wormhole-server start --stats-file=stats.json'
This commit is contained in:
parent
44bc99e987
commit
31be12a4be
19
misc/dump-stats.py
Executable file
19
misc/dump-stats.py
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
import time, json
|
||||||
|
|
||||||
|
# Run this as 'watch python misc/dump-stats.py' against a 'wormhole-server
|
||||||
|
# start --stats-file=stats.json'
|
||||||
|
|
||||||
|
with open("stats.json") as f:
|
||||||
|
data_s = f.read()
|
||||||
|
|
||||||
|
now = time.time()
|
||||||
|
data = json.loads(data_s)
|
||||||
|
if now < data["valid_until"]:
|
||||||
|
valid = "valid"
|
||||||
|
else:
|
||||||
|
valid = "EXPIRED"
|
||||||
|
age = now - data["created"]
|
||||||
|
|
||||||
|
print("age: %d (%s)" % (age, valid))
|
||||||
|
print(data_s)
|
Loading…
Reference in New Issue
Block a user