Monday 31 March 2014

one liner

* sort the folder, sub-folder and files with size order:

sort -sh | sort -h #[ sort -h, --human-numeric-sort ]


*High memory & CPU Usage process: [ ps aux ]

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

Sort by Mem%:
 ps aux | sort -nrk4  | head -5 |awk '{print $1, $4}' # I would use this.
 ps aux | sort -nk4  | tail -5 |awk '{print $1, $4}'


Sort by RSS:
ps aux | sort -nrk6  | head -5 |awk '{print $1, $6}'


ps aux | sort -nrk6  | head -5 |awk '{print "Process Name = "$1, "Memory % = ", $4, "RSS = ", $6}'
Process Name = mysql Memory % =  46.5 RSS =  829792
Process Name = hadoop Memory % =  6.0 RSS =  108592
Process Name = hadoop Memory % =  5.5 RSS =  99688
Process Name = hadoop Memory % =  5.0 RSS =  90036
Process Name = hadoop Memory % =  0.7 RSS =  12828


Sort By CPU:

ubuntu@domU-12-31-38-01-79-24:/etc/nagios$ ps aux | grep -v USER |sort -nrk3  | head -5 |awk '{print "Process Name = "$1, "cpu = ", $3, "Memory % = ", $4, "RSS = ", $6}'
Process Name = mysql cpu =  4.2 Memory % =  46.5 RSS =  829760
Process Name = ubuntu cpu =  0.0 Memory % =  0.0 RSS =  940
Process Name = ubuntu cpu =  0.0 Memory % =  0.0 RSS =  640
Process Name = ubuntu cpu =  0.0 Memory % =  0.0 RSS =  836
Process Name = ubuntu cpu =  0.0 Memory % =  0.0 RSS =  1080


# ps -elFL
F S UID        PID  PPID   LWP  C NLWP PRI  NI ADDR SZ WCHAN    RSS PSR STIME TTY          TIME CMD

$ getconf LONG_BIT  [ To see the system arch [ 32 / 64 bit ] ]

No comments:

Post a Comment