Pages

Wednesday, September 11, 2013

The Top Stuff

Share it Please
Displaying top CPU_consuming processes
ps aux | head -1; ps aux | sort -rn +2 | head -10

Displaying top 10 memory-consuming processes
ps aux | head -1; ps aux | sort -rn +3 | head

Displaying process in order of being penalized
ps -eakl | head -1; ps -eakl | sort -rn +5

Displaying process in order of priority
ps -eakl | sort -n +6 | head

Displaying process in order of nice value
ps -eakl | sort -n +7

Displaying the process in order of time
ps vx | head -1;ps vx | grep -v PID | sort -rn +3 | head -10

Displaying the process in order of real memory use
ps vx | head -1; ps vx | grep -v PID | sort -rn +6 | head -10

Displaying the process in order of I/O
ps vx | head -1; ps vx | grep -v PID | sort -rn +4 | head -10

Displaying WLM classes
ps -a -o pid, user, class, pcpu, pmem, args

Determinimg process ID of wait processes
ps vg | head -1; ps vg | grep -w wait

Wait process bound to CPU
ps -mo THREAD -p

Find Out The Top 10 Memory Consuming Process
ps -auxf | sort -nr -k 4 | head -10

Find Out top 10 CPU Consuming Process
ps -auxf | sort -nr -k 3 | head -10

Biggest 10 Files
du -sh * | sort -n | tail
du -x -a . | sort -n -r | head -n 10

List All the Process By memory usage
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
ps -eo pcpu,pid,user,args | sort -r -k1 | less

Highest CPU Usage
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 | awk "{ print $2 }"

Total Memory Usage
sar -q 1 | tail -1 | awk '{ print "" $3}' | sed 's/%//g'

CPU Threshold
top -b -n 1 | awk -F'[:,]' '/^Cpu/{sub("\\..*","",$2); print $2}'

Process Using memory
ps aux | awk '{if ($5 != 0 ) print $2,$5,$6,$11}' | sort -k2n

Largest File Or Directory
du -sk /var/log/* | sort -r -n | head -10

Processes Count Used By Users
ps hax -o user | sort | uniq -c

Memory Percentage Usage of a Process
ps -o comm,%mem,args PID

Top Files Using perl
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'

Top File Users
for x in `ps -eF| awk '{ print $2 }'`;do echo `ls /proc/$x/fd 2> /dev/null | wc -l` $x `cat /proc/$x/cmdline 2> /dev/null`;done | sort -n -r | head -n 20