add system load module

This commit is contained in:
Dave Pedu 2015-12-05 01:22:07 -08:00
parent 3740e7943f
commit 157eb4a592
2 changed files with 33 additions and 0 deletions

View File

@ -7,6 +7,11 @@
"type":"uptime",
"freq":"30",
"args":{}
},
{
"type":"load",
"freq":"30",
"args":{}
}
]
}

View File

@ -0,0 +1,28 @@
def load():
with open("/proc/loadavg", "r") as f:
m1, m5, m15, procs, pid = f.read().strip().split(" ")
return {
"load_1m": m1,
"load_5m": m5,
"load_15m":m15
}
mapping = {
"load": {
"properties": {
"load_15m": {
"type": "double"
},
"load_5m": {
"type": "double"
},
"load_1m": {
"type": "double"
}
}
}
}
if __name__ == '__main__':
avg = load()
print(' '.join([avg["load_1m"], avg["load_5m"], avg["load_15m"]]))