From c77a3b4c123e472e923f8f130c94e9bb5ed32915 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 14 Feb 2017 09:59:05 +0100 Subject: [PATCH] Added support for checing load on MacOS --- status/load.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/status/load.py b/status/load.py index 54b8a6e..ff780fe 100755 --- a/status/load.py +++ b/status/load.py @@ -1,11 +1,20 @@ #!/usr/bin/env python3 from subprocess import check_output from re import findall +from platform import system def load(): - arpOutput = check_output("cat /proc/loadavg", shell=True) - arpOutput = arpOutput.decode() - print(findall('[0-9]{1,2}[\.][0-9]{2}', arpOutput)) + sysName = system() + if sysName == 'Linux': + arpOutput = check_output("cat /proc/loadavg", shell=True) + arpOutput = arpOutput.decode() + return findall('[0-9]{1,2}[\.][0-9]{2}', arpOutput) + elif sysName == 'Darwin': + arpOutput = check_output("uptime", shell=True) + arpOutput = arpOutput.decode() + return findall('[0-9]{1,2}[\.][0-9]{2}', arpOutput) + + return {"Error": "Running OS does not supported load."} if __name__ == '__main__': - load() + print(load())