Site icon VPS Windows

Monitor CPU, RAM, Disk on Linux VPS with Sar command

Set-up-Sar-command-to-monitor-CPU-RAM-Disk-on-VPS-Linux

When managing a Linux VPS, monitoring system resources such as CPU, RAM, Disk and network monitoring is extremely important. This monitoring ensures the server operates stably and efficiently. One of the useful tools to help you track these resources is the sar command. In this article, we will learn how to use the sar command to monitor system resources on a Linux VPS.

What is the Sar Order?

The sar (System Activity Report) command is a powerful tool used on Linux systems to collect and display reports on system performance. This command can monitor many important system factors, including CPU, RAM, Disk, and Network. Sar not only helps you monitor current resource status, but also helps store past performance data for trend analysis.

Main features of Sar command

Benefits of Sar command

The sar command is a powerful tool that helps system administrators maintain stable performance for  server and Linux VPS. At the same time, provides insight into the status of system resources.

Install Sar command on Linux VPS

To use the sar command, you need to install the sysstat package (containing the sar command) on your Linux VPS. Here’s how to install on some popular distributions:

On Ubuntu/Debian:

apt update sudo

sudo apt install sysstat

On CentOS/RHEL:

yum install sysstat

Once installed, you can use the sar command immediately.

How to use Sar command to monitor CPU, RAM, Disk.

Here’s how to use sar to monitor critical system resources on a Linux VPS:

CPU Monitoring:

To monitor CPU usage, use the following command:

sar -u 1 5

In there:

The result of this command will display CPU usage through parameters:

Memory Monitor (RAM):

To monitor RAM memory status, use the command:

sar -r 1 5

In there:

This command will provide information about total memory, used memory and free memory in the system.

Monitor Disk (Drive):

To monitor disk usage status, use the command:

sar -d 1 5

In there:

This command will display information about disk activity. Includes read/write counts per drive and their usage rates.

For example, run the Sar command on an Ubuntu 20.04 VPS and read the results

To better understand how to use the Sar command on a Linux VPS, this article details how to use the Sar command on an USA VPS Ubuntu 20.04  and analyze the results after running the command.

apt update sudo

sudo apt install sysstat

Monitor CPU

sar -u 1 5

The result received after running the command is as shown in the image below.

Result:

  1. %user: CPU time spent on user tasks (user processes). Here it is 0.00, meaning no user processes are consuming CPU.
  2. %nice: CPU time spent on low priority tasks (nice processes). A value of 0.00 indicates that no nice processes are running.
  3. %system: CPU time spent on system tasks (kernel processes). Value 0.00, means the system is not using CPU resources.
  4. %iowait: CPU time waiting for I/O (read/write from disk, device). A value of 0.00 means there is no I/O congestion.
  5. %steal: CPU time “stolen” by the hypervisor (in a virtualized environment). A value of 0.00, means no resources are affected.
  6. %idle: Idle CPU time. Value 99.80 – CPU is hardly used, is in idle state.

Conclude: The machine’s CPU is almost completely idle (%idle is very high). There are no processes consuming significant CPU resources at the time of monitoring.

Monitor RAM

sar -r 1 5

The result received after running the command is as shown in the image below.

Columns in the results:

Example: 180736 (approximately 176MB of free memory).

Example: 457992 (approximately 447MB available).

Example: 218548 (approximately 213MB of used memory).

Example: 24.41% (about 1/4 of total RAM is in use).

Example: 49968 (approximately 48MB used as buffer).

Example: 330228 (approximately 322MB used for cache).

Example: 513104 (approximately 501MB committed).

Example: 18.78% (less than 1/5 of memory has been committed).

Example: 263348 (approximately 257MB active).

Conclude:

Monitor Disk (Drive):

sar -d 1 5

The result received after running the command is as shown in the image below.

The results from the command sar -d 1 5 is used to monitor the activity of disk devices at 1 second intervals and repeat 5 times. Detailed analysis is as follows:

Columns in the results:

Analysis:

Comment:

If this is a normal state, the system may not have any tasks requiring disk access at that time.

If you expect disk activity, this result may suggest that the application is not performing I/O access or that there is an error in the way it checks.

The sar command is a powerful and useful tool for monitoring system performance on a Linux VPS. Helps you monitor CPU, RAM, and Disk, quickly detect performance issues and optimize system resources to ensure your VPS operates stably. If you are managing a Linux VPS, don’t skip installing and using sar to maintain the best performance for your system.

Exit mobile version