Last active
February 12, 2017 01:38
-
-
Save Tab3r/ad43473fe0b00086ffc0 to your computer and use it in GitHub Desktop.
Linux: CPU Usage in percernt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## USING PS ########## | |
## Note: In hign loads, it could return more than 100% of load | |
# Show total % | |
ps aux | awk {'sum+=$3;print sum'} | tail -n 1 | |
# Debug mode: | |
ps aux | awk {'value=$3; if ($3 != "0.0") {print "Adding: " value}; sum+=$3; sumt = "Total sum: " sum; print sumt'} | |
####### USING TOP ######### | |
## Note: It needs 2 seconds to execute to be accurrate | |
top -bn 2 -d 2 | grep '^%Cpu' | tail -n 1 | awk '{print $2+$4+$6 "%"}' |
samirfor
commented
Feb 12, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment