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
ZPOOL: Remove an existing zpool
Viewed 2794 times since Sun, Jun 3, 2018
RHEL: Extending the maximum inode count on a ext2/ext3/ext4 filesystem
Viewed 3957 times since Sun, May 27, 2018
Linux - How to get IP and MAC address of ethernet adapter in Linux
Viewed 3217 times since Fri, Jun 8, 2018
Red Hat 8 How to Set Up Automatic Updates for CentOS 8
Viewed 4456 times since Fri, Sep 25, 2020
List DNS records, nameservers of a domain from command line
Viewed 2483 times since Sun, Sep 30, 2018
Understanding logrotate utility part 1
Viewed 2210 times since Fri, Nov 30, 2018
How to retrieve and change partition’s UUID Universally Unique Identifier on linux
Viewed 3648 times since Tue, Jul 17, 2018
RHEL: Forgotten ’root’ password / using single-user to gain access
Viewed 8370 times since Sat, Jun 2, 2018
30 Handy Bash Shell Aliases For Linux / Unix / MacOS
Viewed 5642 times since Thu, Feb 11, 2021
Linux – Securing your important files with XFS extendend attributes
Viewed 8015 times since Wed, Jul 25, 2018