Thursday 9 May 2013

Top Command



top

Top command Details
-Line1 (same as cmd 'uptime')
-current time
-up time of the machine
-number of users logged in
-Load average on system at 1, 5, 15 min interval.
-other commands
-uptime
-w
-takes the value from /proc/loadavg
-A load average of 1 means your cpu is being fully utilized and processes are not having to wait to use a CPU.
-A load average above 1 indicates that processes need to wait and your system will be less responsive.
-If your load average is consistently above 3 and your system is running slow you may want to upgrade to more CPU’s or a faster CPU.
Line2
-total number of tasks/process on the machine,
-number of running process,
-number of sleeping process,
-number of stopped process,
-number of Zombie process.
Line3
-Show CPU utilization details
-%us - % of user processes utilized
-%sy - % of system processes
-%id - % of available cpu (it should be greater than 90%)
-%wa - % of time CPU is waiting for IO. ( it should be 0 or 1 or 3)
-When analyzing the Cpu(s) look at the %id to see how much cpu is available.
-If %id is low then focus on %us, %sy, and %wa to determine what is using the CPU.
Line4
-Gives RAM details
Line5
-Gives SWAP details.
Line6
-PID – process ID of the process
-USER – User who is running the process
-PR – The priority of the process
-NI – Nice value of the process (higher value indicates lower priority)
-VIRT – The total amount of virtual memory used
-RES – Resident task size
-SHR – Amount of shared memory used
-S – State of the task.
-S (sleeping)
-D (uninterruptible sleep)
-R (running)
-Z (zombies)
-T (stopped or traced)
-%CPU – Percentage of CPU used
-%MEM – Percentage of Memory used
-TIME+ – Total CPU time used
-COMMAND – Command issued
==========================================
Top commands shortcuts
l --To display or to hide load average line
t --To display or to hide task/cpu line
1 --To display or hide all other CPU's
m --to display or to hide RAM and SWAP details
s --To change the time interval for updating top results(value is in sec's)
R --To sort by PID number
u -- Press u then username to get only that user process details
P --To sort by CPU utilization
M --To sort by RAM utilization
c --To display or hide command full path
r --To renice a process, press r then the PID no then the renice value to renice a process.
k --To kill a process, press k then PID number then enter to kill a process
w --To save the modified configuration permanently.
q --To quit the top command.
h --for getting help on top command
==========================================
List processes owned by user u1
-top -u u1
List the Stuck process
-top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}'


No comments:

Post a Comment