Merge branch 'master' of git.hjp.at:hjp/ltsdb

This commit is contained in:
Peter J. Holzer 2023-01-26 21:28:24 +01:00 committed by Peter J. Holzer
commit cfc514a3eb
1 changed files with 43 additions and 0 deletions

43
clients/record_reboot_overdue Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/python3
import time
import glob
import os.path
import ltsdb_record
now = time.time()
with open("/proc/uptime") as fh:
ln = fh.readline()
uptime = float(ln.split()[0])
last_reboot = now - uptime
last_mtime = 0
for p in glob.glob("/boot/**/*", recursive=True):
mtime = os.path.getmtime(p)
if mtime > last_mtime:
last_mtime = mtime
if last_mtime > last_reboot:
overdue = now - last_mtime
else:
overdue = 0
report0 = []
report0.append({ "measure": "reboot_overdue", "unit": "s", "value": overdue})
report = [
{
"description": {
"hostname": ltsdb_record.node,
"measure": r["measure"],
"unit": r["unit"]
},
"data": [
[now, r["value"]]
]
}
for r in report0
]
success = ltsdb_record.record_observations(report)
exit(1 - success)