Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from __future__ import division
- import time
- st = open('/proc/stat')
- line = st.readlines()[0].split()
- st.close()
- load1 = int(line[1])+int(line[2])+int(line[3])
- total1 = load1 + int(line[4])
- time.sleep(1)
- st = open('/proc/stat')
- line = st.readlines()[0].split()
- st.close()
- load2 = int(line[1])+int(line[2])+int(line[3])
- total2 = load1 + int(line[4])
- res = 100*(load2 - load1)/(total2 - total1)
- print "Load: %3.2f%%" % res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement