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
Linux – delete the LUN and remove traces from OS
Viewed 3087 times since Tue, May 22, 2018
Creating SWAP partition using FDISK & FALLOCATE commands
Viewed 2909 times since Thu, Jan 16, 2020
VMWare tools free
Viewed 8164 times since Mon, Jul 16, 2018
How To Use the Linux Auditing System on CentOS 7
Viewed 3665 times since Fri, Apr 5, 2019
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 2436 times since Sun, Jun 3, 2018
Script to Offline and Remove A Disk In Linux
Viewed 1763 times since Mon, Jan 28, 2019
Monitoring bezpieczeństwa Linux: integracja auditd + OSSEC cz. I
Viewed 2178 times since Fri, Apr 5, 2019
SSH ProxyCommand example: Going through one host to reach another server
Viewed 13147 times since Tue, Aug 6, 2019
Linux RAID Mdadm Cheat Sheet
Viewed 5140 times since Fri, May 15, 2020
Oracle Linux 7 – How to audit changes to a trusted file such as /etc/passwd or /etc/shadow
Viewed 2705 times since Wed, Jul 25, 2018