From 62b22d751653e54b129a46dd036e4f77ca3ae1bf Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Fri, 3 Feb 2023 13:27:25 +0100 Subject: [PATCH 1/2] Record OS version --- clients/record_os_version | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 clients/record_os_version diff --git a/clients/record_os_version b/clients/record_os_version new file mode 100755 index 0000000..d1f8206 --- /dev/null +++ b/clients/record_os_version @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +import re +import subprocess +import time + +import ltsdb_record + +p = subprocess.run(["/usr/bin/lsb_release", "-ir"], capture_output=True, text=True) +for ln in p.stdout.split("\n")[:-1]: + m = re.match(r"(.*?)\s*:\s+(.*)", ln) + if m: + if m.group(1) == "Distributor ID": + distributor = m.group(2).lower() + elif m.group(1) == "Release": + release = m.group(2) +if distributor == "ubuntu": + # special rule for ubuntu. The format is year.month, so we convert the + # months into fractional years + m = re.match(r"(\d+)\.(\d+)", release) + release = int(m.group(1)) + (int(m.group(2)) - 1) / 12 +else: + # for everybody else we assume its a fp number + release = float(release) + +report0 = [] +report0.append({ "measure": "os_version_" + distributor, "unit": "version", "value": release}) +now = time.time() +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) From d3a439bb492bc502ebaa2a80a0d76ab59dc981ef Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 4 Feb 2023 12:16:37 +0100 Subject: [PATCH 2/2] Stop if we run out of tickmark frequencies --- dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard.py b/dashboard.py index a90179b..b650c7e 100644 --- a/dashboard.py +++ b/dashboard.py @@ -171,7 +171,7 @@ class TimeSeries(Widget): min_step = 25 steps = ("s", "m", "h", "D", "10D", "M", "Y") step_i = 0 - while True: + while step_i < len(steps): t0 = tickmarks[-1]["t"] x0 = tickmarks[-1]["x"] d0 = datetime.datetime.fromtimestamp(t0)