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
LVM: Remove an existing Volume Group
Viewed 6436 times since Sat, Jun 2, 2018
HowTo: Retrieve Email from a POP3 Server using the Command Line
Viewed 14127 times since Mon, Feb 18, 2019
How To Create a Linux Swap File
Viewed 3563 times since Fri, Jun 8, 2018
Używanie rsync poprzez Secure Shell
Viewed 42177 times since Thu, May 24, 2018
HOWTO: Use SSL/port 465 in smarthost stunnel
Viewed 4754 times since Fri, Sep 28, 2018
red hat 7 tmpfiles service
Viewed 2624 times since Thu, Oct 11, 2018
How to Analyze or Read OS Watcher Output in three easy steps -- With Example ?
Viewed 44643 times since Thu, Jun 21, 2018
How to disable SSH cipher/ MAC algorithms for Linux and Unix
Viewed 52041 times since Fri, Aug 21, 2020
RHEL: Getting/Setting hardware clock’s time
Viewed 4637 times since Sat, Jun 2, 2018
Build a simple RPM that packages a single file
Viewed 10005 times since Sat, Jun 2, 2018