Hope, you must have checked CPU utilization on your Windows PC via task manager , also windows 7 and above have widget for the same. But what about Linux? Well , Linux have several ways by which we can easily determine CPU utilization , Utilization per processor , Average utilization and determining which process is consuming maximum CPU(s) etc.
1. Top:
Top is used for real time monitoring of processor activity so that we can take a look at the machine stats and optimize the same.It displays complete system information and by default displays the processes in the order of CPU usage. While top command is running , Press M in upper case to sort the memory usage.
The screenshot below shows the Output of Top command:
We get different type of information in the different columns:
Sar command is very useful tool to determine CPU Utilization.
Syntax:
$ sar -u 2 5
The above command will show the CPU utilization of Linux machine at interval of 2 seconds , 5 times.
3. mpstat :
Mpstat is used to check per processor stats. For using mpstat , you have to install a package called sysstat
# mpstat 10 4
Above command will shows statistics 10 seconds apart , 4 times.
For monitoring individual CPU performance,
$ mpstat -P ALL
4. iostat :
For using iostat , you need package called sysstat.
Command : iostat -c 2
The above syntax will monitor CPU usage , -c is for cpu load and 2 is the time interval in seconds between reports.
1. Top:
Top is used for real time monitoring of processor activity so that we can take a look at the machine stats and optimize the same.It displays complete system information and by default displays the processes in the order of CPU usage. While top command is running , Press M in upper case to sort the memory usage.
The screenshot below shows the Output of Top command:
We get different type of information in the different columns:
- PID: Process I.D
- User : Owner of particular processs
- PR : Priority
- NI : Nice value of process
- VIRT : Virtual memory used by the process
- RES : physical memory used from the process
- SHR: Shared memory of the process
- S: Shows the status of the process , S= Sleep , Z= Zombie , R= Running
- %CPU : Percentage of CPU used by a particular process
- %MEM : Percentage of RAM used by the process
- TIME+ : Total time of the activity of this process.
- COMMAND : Name of the process
Sar command is very useful tool to determine CPU Utilization.
Syntax:
$ sar -u 2 5
Screenshot credit
The above command will show the CPU utilization of Linux machine at interval of 2 seconds , 5 times.
3. mpstat :
Mpstat is used to check per processor stats. For using mpstat , you have to install a package called sysstat
# mpstat 10 4
Above command will shows statistics 10 seconds apart , 4 times.
For monitoring individual CPU performance,
$ mpstat -P ALL
4. iostat :
For using iostat , you need package called sysstat.
Command : iostat -c 2
The above syntax will monitor CPU usage , -c is for cpu load and 2 is the time interval in seconds between reports.
0 comments:
Post a Comment