mirror of
https://github.com/KevinMidboe/Node-Com-Handler.git
synced 2025-10-29 17:50:27 +00:00
Shortend down on load.py and made it logically faster.
This commit is contained in:
20
status/load.py
Normal file
20
status/load.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from subprocess import check_output
|
||||||
|
from re import findall
|
||||||
|
from platform import system
|
||||||
|
|
||||||
|
def load():
|
||||||
|
sysName = system()
|
||||||
|
if sysName == 'Linux':
|
||||||
|
arpOutput = check_output("cat /proc/loadavg", shell=True)
|
||||||
|
elif sysName == 'Darwin':
|
||||||
|
arpOutput = check_output("uptime", shell=True)
|
||||||
|
else:
|
||||||
|
return {"Error": "Running OS does not supported load."}
|
||||||
|
|
||||||
|
arpOutput = arpOutput.decode()
|
||||||
|
return findall('[0-9]{1,2}[\.][0-9]{2}', arpOutput)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(load())
|
||||||
Reference in New Issue
Block a user