How Linux Administrator Monitor High Cpu Utilization

March 14, 2011 | By
| Reply More

CPU Linux

CPU is core part the system and processes all the task. There are many methods to check the CPU performance on linux system. Most commonly used commands are top, ps, sar, iostat, mpstat and to check the daily CPU performance. Whenever CPU is busy in processing a particular task, it becomes unavailable to other processes. The other processes have to wait till CPU is free, this become bottleneck in the system.

Monitor high cpu utilization in Linux using ps command

Example: 1 By Using ps Command

[root@localhost ~]# ps u | sort -k 1 -r | head -5
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 4414 0.0 0.0 4492 320 pts/3 R+ 09:20 0:00 -bash
root 4413 0.0 0.0 29348 648 pts/3 S+ 09:20 0:00 sort -k 1 -r
root 4412 0.0 0.0 4216 936 pts/3 R+ 09:20 0:00 ps u
root 4373 0.0 0.0 4128 752 pts/2 S+ 09:15 0:00 /usr/bin/less –is

Above command shows highest CPU & Memory utilization by processes.

Example: 2

[root@localhost ~]# ps -eo pcpu,args | sort -k 1 -r | head -8
%CPU COMMAND
0.4 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
0.1 /usr/bin/python -E /usr/bin/sealert -s
0.0 xfs -droppriv -daemon
0.0 [watchdog/0]
0.0 /usr/sbin/sshd
0.0 /usr/sbin/smartd -q never
0.0 /usr/sbin/sdpd

Example: 3

[root@localhost ~]# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
or
[root@localhost ~]# ps -auxf | sort -nr -k 3 | head -10

Example 4: Most of the administrator uses this command to check CPU usage. Top command provides a real time view of cpu, memory, running process etc..

Linux Top Command,Click To Enlarge

You can watch CPU activity evolve for 10 minutes and save data

[root@localhost ~]# sar -o file-name 60 10

You can just sar and logout and let the report store in files.

[root@localhost ~]# nohup sar -A -o output-file 60 10 1>/dev/null 2>&1 &

Note to display data stored in output-file pass -f option to sar command.

[root@localhost ~]# sar -f output-file

Filed Under : HOWTOS, LINUX HOWTO, MONITORING

Tagged With : ,

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.