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
Szybkie sprawdzenie zewnętrznego adresu IP i hosta
Viewed 3110 times since Thu, May 24, 2018
How to convert RAW image to VDI and otherwise
Viewed 14532 times since Wed, Oct 3, 2018
Extending Linux LVM partitions script
Viewed 6136 times since Wed, Feb 6, 2019
Extending Linux LVM partitions - scripts
Viewed 6276 times since Sun, May 20, 2018
7 Tips – Tuning Command Line History in Bash
Viewed 4684 times since Fri, Jul 5, 2019
LVM: Mount LVM Partition(s) in Rescue Mode
Viewed 4387 times since Sat, Jun 2, 2018
Procedura powiekszania OCFS2 online
Viewed 5181 times since Fri, Jun 8, 2018
Using stunnel to Encrypt Database Connections
Viewed 2649 times since Fri, Sep 28, 2018
Install OpenVPN On CentOS / RHEL 7
Viewed 2731 times since Fri, May 15, 2020
SSH Essentials: Working with SSH Servers, Clients, and Keys
Viewed 3985 times since Wed, Jun 27, 2018