Leave a Comment
How to count resource usage in linux
1 |
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 5 |
It will output something like this:
1 2 3 4 5 6 |
PID PPID CMD %MEM %CPU 2591 2113 /usr/lib/firefox/firefox 7.3 43.5 2549 2520 /usr/lib/virtualbox/Virtual 3.4 8.2 2288 1 /home/gacanepa/.dropbox-dis 1.4 0.3 1889 1543 c:\TeamViewer\TeamViewer.ex 1.0 0.2 2113 1801 /usr/bin/cinnamon 0.9 3.5 |
Sum can be count like this:
1 |
ps -eo pid,ppid,%mem,%cpu --sort=-%mem | head -n 5 | awk '{sum+=$4 ; print $0} END{print "sum=",sum}' |
It will output:
1 2 3 4 5 6 7 |
PID PPID %MEM %CPU 2591 2113 7.3 43.5 2549 2520 3.4 8.2 2288 1 1.4 0.3 1889 1543 1.0 0.2 2113 1801 0.9 3.5 sum= 55.7 |
https://www.tecmint.com/find-linux-processes-memory-ram-cpu-usage/
Total cpu info can be found as follows:
1 |
lscpu | egrep '^Thread|^Core|^Socket|^CPU\(' |
https://unix.stackexchange.com/questions/218074/how-to-know-number-of-cores-of-a-system-in-linux
Similar Posts
LEAVE A COMMENT
Для отправки комментария вам необходимо авторизоваться.