diff --git a/clients/record_meminfo b/clients/record_meminfo new file mode 100644 index 0000000..adee6f6 --- /dev/null +++ b/clients/record_meminfo @@ -0,0 +1,40 @@ +#!/usr/bin/python3 + +import time +import re + +import ltsdb_record + + +now = time.time() +report0 = [] +with open("/proc/meminfo") as mfh: + for ln in mfh: + m = re.match(r"^(?P.*?): *(?P[0-9]*)( (?P.*))?", ln) + measure = m.group("measure") + value = int(m.group("value")) + unit = m.group("unit") + if unit is None and "Pages" in measure: + unit = "pages" + if unit == "kB": + value *= 1024 + unit = "bytes" + report0.append({ "measure": "meminfo." + measure, "unit": unit, "value": value }) + +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) +