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 Proxy Server Settings – Set Proxy For Command Line
Viewed 3681 times since Mon, Feb 18, 2019
RHEL: Display swap/RAM size
Viewed 3389 times since Sat, Jun 2, 2018
RHEL: Getting/Setting hardware clock’s time
Viewed 3138 times since Sat, Jun 2, 2018
Przekazywanie portów TCP rinetd
Viewed 43736 times since Thu, May 24, 2018
How setting the TZ environment variable avoids thousands of system calls
Viewed 10089 times since Mon, May 21, 2018
Linux Cluster Tutorial
Viewed 2210 times since Sat, Sep 29, 2018
Extending Linux LVM partitions script
Viewed 6477 times since Wed, Feb 6, 2019
How To Run Multiple SSH Command On Remote Machine And Exit Safely
Viewed 4427 times since Tue, Aug 6, 2019
15 Linux Yum Command Examples – Install, Uninstall, Update Packages
Viewed 3487 times since Thu, Oct 25, 2018
Jak wygenerować silne hasła jednorazowe w Linuksie?
Viewed 2409 times since Thu, May 24, 2018