Record meminfo
This commit is contained in:
parent
ed3f7872e9
commit
52a5f60389
|
@ -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<measure>.*?): *(?P<value>[0-9]*)( (?P<unit>.*))?", 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)
|
||||
|
Loading…
Reference in New Issue