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
30 Handy Bash Shell Aliases For Linux / Unix / MacOS
Viewed 5022 times since Thu, Feb 11, 2021
Manage Linux Password Expiration and Aging Using chage
Viewed 4808 times since Tue, Sep 11, 2018
LVM: Reduce SWAP size by shrinking existing Logical Volume
Viewed 6373 times since Sat, Jun 2, 2018
Fałszujemy rozpoznania skanerów #1
Viewed 3159 times since Mon, May 21, 2018
Linux nslookup Command Examples for DNS Lookup
Viewed 9135 times since Sat, Sep 29, 2018
RHEL7: Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot.
Viewed 12977 times since Mon, Aug 6, 2018
7 Tips – Tuning Command Line History in Bash
Viewed 5600 times since Fri, Jul 5, 2019
How to disable SSH cipher/ MAC algorithms for Linux and Unix
Viewed 47588 times since Fri, Aug 21, 2020
ubuntu How to Reset Forgotten Passwords in Ubuntu 16.04
Viewed 3625 times since Tue, Dec 8, 2020
Secure Remote Logging to Central Log Server Using RSYSLOG on CentOS 6 / CentOS 7 and stunnel
Viewed 4222 times since Sun, Dec 6, 2020