Skip to main content

ps command switches

watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15'
 
 Every 1.0s: ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15                                                                      Mon Jan 12 17:57:24 2015

  PID USER     CMD                         %MEM %CPU
 1953 rahul    /usr/lib/firefox/firefox    18.7 18.4
 1751 rahul    cinnamon --replace           2.5  3.2
 1193 root     /usr/bin/X :0 -audit 0 -aut  1.8  3.0
 2170 rahul    totem /media/rahul/C384-4DE  1.2  0.1
 1769 rahul    nemo -n                      1.0  0.0
 1915 rahul    python /usr/lib/linuxmint/m  0.8  0.0
 4650 rahul    gedit /home/Apache bench ma  0.7  0.0
 1543 rahul    /usr/lib/cinnamon-settings-  0.5  0.0
 2256 rahul    gnome-terminal               0.5  0.0
 1909 rahul    cinnamon-screensaver         0.4  0.0
 1737 rahul    /usr/bin/python /usr/bin/ci  0.4  0.0
 1770 rahul    nm-applet                    0.4  0.0
 1768 rahul    /usr/lib/cinnamon-settings-  0.4  0.0
 1432 rahul    cinnamon-session --session   0.2  0.0
 
 
 Above can watch the full process with pid,uname...etc 
 
 
ps -ef : Full list of process or ps aux
 
ps -elf : Full length list
 
ps -p <pid> -o ppid=  : To get the parent process id of a process
 
ps -p <pid> -o etime= : To get the time the process running
 
ps -ylC httpd --sort:rss sort the resident set size of process specified by the switch C

rahul-Inspiron-3542 weighttp # ps -ylC apache2 --sort:rss
S   UID   PID  PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0 11086     1  0  80   0  2668 17821 poll_s ?        00:00:00 apache2
S    33 11089 11086  0  80   0  2924 106544 pipe_w ?       00:00:00 apache2
S    33 11090 11086  0  80   0  2928 106544 pipe_w ?       00:00:00 apache2

 
 
 
rahul-Inspiron-3542 weighttp # ps ef -o pid,ppid,pmem,rss,pcpu 
 PID  PPID %MEM   RSS %CPU
 2570  2263  0.0  2476  0.0
 2578  2570  0.0  3344  0.0
11847  2578  0.0   892  0.0
 1193  1183  1.8 73392  3.0
 1175     1  0.0   960  0.0
 1064     1  0.0   964  0.0
 1061     1  0.0   968  0.0
 1060     1  0.0   972  0.0
 1053     1  0.0   972  0.0
 1049     1  0.0   972  0.0
 
 
  
 

Comments

Popular posts from this blog

Modsecurity block rule for XMLRPC and wp-login attack

SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134  <Locationmatch "/wp-login.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"  SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"  SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"  SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"  </Locationmatch>  SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000234  <Locationmatch "/xmlrpc.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000235,msg:'ip address blocked for 5 m...

Apache tuning documentation

Apache bench marking ======================= Things or checklist to be considered before the test     CPU: avoid power-saving mode. cpufreq-set -g performance.     File descriptors: raise the limit to (at least) the number of concurrent connections you wish to handle, using ulimit -n in your shell, or setrlimit(RLIMIT_NOFILE) in your server. Beware, some systems forbid you to raise the limit, you might need to investigate a bit to find how to unlock it.     Disable the logs of your server (you do not want to lose time logging thousands of requests instead of answering them).     Raise /proc/sys/net/somaxconn to the number of concurrent connections you want to handle. To understand why this is necessary, read the technical report or the excellent paper Measuring the Capacity of a Web Server (Banga and Druschel, Usenix 97). More on the fascinating topic of the accept() queue can be found in accept()able Strategies for Im...

How to tweak linux server harddisk using hdparm

hdparm switches explained http://manpages.ubuntu.com/manpages/intrepid/man8/hdparm.8.html   First of all you have to install hdparm in linux. apt-get install hdparm #hdparm /dev/sda /dev/sda: readonly = 0 (off) readahead = 120 (on) geometry = 8850/255/63, sectors = 142182912, start = 0 Hard disk Performance Information # hdparm -tT /dev/hda /dev/hdd: Timing cached reads: 496 MB in 2.00 seconds = 247.42 MB/sec Timing buffered disk reads: 60 MB in 3.03 seconds = 19.81 MB/sec Hard drive set to low, slow settings # hdparm -cuda /dev/hda /dev/hda: IO_support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) readahead = 256 (on) Use below tweaks to increase disk read write performance. For sda drive ~]# hdparm -a 2048 /dev/sda /dev/sda: setting fs readahead to 2048 readahead = 2048 (on) For sdb drive [root@439298a ~]# hdparm -a 2048 /dev/sdb /dev/sdb: setting fs readahead to 2048 readahead = 2048 (on) ]# echo “anticipatory” >...