Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from __future__ import division
  3. import time
  4. st = open('/proc/stat')
  5. line = st.readlines()[0].split()
  6. st.close()
  7. load1 = int(line[1])+int(line[2])+int(line[3])
  8. total1 = load1 + int(line[4])
  9. time.sleep(1)
  10. st = open('/proc/stat')
  11. line = st.readlines()[0].split()
  12. st.close()
  13. load2 = int(line[1])+int(line[2])+int(line[3])
  14. total2 = load1 + int(line[4])
  15. res = 100*(load2 - load1)/(total2 - total1)
  16. print "Load: %3.2f%%" % res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement