Linux - How to monitor CPU usage

Linux - How to monitor CPU usage

 
In Linux, top can be used to monitor CPU usage of the system. Top is similar to topas in AIX though both are not the same.

Question : How to monitor CPU usage in Linux?
Answer : ps command can be used to report a snapshot of the current processes in Linux. Use option aux and sort based on the column to get the top usage based on the parameter you need. If you need to get CPU then you will need to sort column 3.
Example :
[root@server ~]# watch -n 2 'echo `ps aux |head -1`;ps aux |sort -nrk 3| head -10'
Note : Above command will output top 10 processes with highest %CPU in an interval of 2 seconds. Press "Crtl C" to stop.


Question : How to monitor CPU usage in Linux?
Answer : Besides using method above, top command can be used to monitor %CPU in Linux.
Example :
[root@server ~]# top


Question : How to monitor CPU usage in Linux?
Answer : sar command can be used to monitor %CPU in Linux. Use sar with option "u" and specific the interval and numintervals needed.
Example :
[root@server ~]# sar -u 3 3
Note : Above command with execute sar -u in an interval of 3 seconds for 3 times.
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
LVM: Extend SWAP size by adding a new Logical Volume
Viewed 3173 times since Sat, Jun 2, 2018
Understanding logrotate utility part 1
Viewed 1767 times since Fri, Nov 30, 2018
Super Grub2 Disk
Viewed 3433 times since Wed, May 22, 2019
RHCS6: Reduce a Global Filesystem 2 (GFS2)
Viewed 3420 times since Sun, Jun 3, 2018
LVM: Extend SWAP size by growing existing Logical Volume
Viewed 2491 times since Sat, Jun 2, 2018
Install Security Patches or Updates Automatically on CentOS and RHEL
Viewed 1796 times since Fri, Oct 26, 2018
LVM: Reduce root PV/VG
Viewed 5241 times since Sat, Jun 2, 2018
Linux / UNIX: Run Command a Number of Times In a Row
Viewed 15918 times since Tue, Aug 6, 2019
Applescript: Run or Call a Shell Script
Viewed 4230 times since Tue, Aug 6, 2019
Enabling automatic updates in Centos 7 and RHEL 7
Viewed 2512 times since Wed, Oct 17, 2018