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
Tunnel SSH Connections Over SSL Using ‘Stunnel’ On Debian 7 / Ubuntu 13.10
Viewed 1905 times since Fri, Sep 28, 2018
RHCS6: Luci - the cluster management console
Viewed 2316 times since Sun, Jun 3, 2018
Enabling automatic updates in Centos 7 and RHEL 7
Viewed 1668 times since Wed, Oct 17, 2018
RHEL: Crash kernel dumps configuration and analysis on RHEL 5
Viewed 5966 times since Sat, Jun 2, 2018
RHEL7: Configure automatic updates.
Viewed 1121 times since Wed, Oct 17, 2018
Migrate a Linux System from Red Hat Enterprise to CentOS
Viewed 9313 times since Fri, May 15, 2020
Linux: Disks diagnostic using smartctl
Viewed 12751 times since Wed, Jul 25, 2018
How to encrypt a partition with DM-Crypt LUKS on Linux
Viewed 1853 times since Fri, Jul 13, 2018
Linux – Securing your important files with XFS extendend attributes
Viewed 6896 times since Wed, Jul 25, 2018
A Simple Guide to Oracle Cluster File System (OCFS2) using iSCSI on Oracle Cloud Infrastructure
Viewed 6439 times since Sat, Jun 2, 2018