Guest User

Untitled

a guest
Jun 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. def get_loadavg():
  2.   # For more details, "man proc" and "man uptime"  
  3.   if platform.system() == "Linux":
  4.     return open('/proc/loadavg').read().strip().split()[:3]
  5.   else:  
  6.     command = "uptime"
  7.     process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
  8.     os.waitpid(process.pid, 0)
  9.     output = process.stdout.read().replace(',', ' ').strip().split()
  10.     length = len(output)
  11.     return output[length - 3:length]
Add Comment
Please, Sign In to add comment