Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_loadavg():
- # For more details, "man proc" and "man uptime"
- if platform.system() == "Linux":
- return open('/proc/loadavg').read().strip().split()[:3]
- else:
- command = "uptime"
- process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
- os.waitpid(process.pid, 0)
- output = process.stdout.read().replace(',', ' ').strip().split()
- length = len(output)
- return output[length - 3:length]
Add Comment
Please, Sign In to add comment