Linux sar command usage and code example analysis

Linux sar command usage and code example analysis

1. CPU utilization

sar -p (view all day)
sar -u 1 10 (1: every second, 10: write 10 times)

1.1. CPU output item description

Output Detailed description
CPU all means that the statistics are the average of all CPUs.
%user

Shows the percentage of total CPU time used by applications running at the user level.

%nice

Shows the percentage of total CPU time spent on nice operations at the user level.

%system

The percentage of total CPU time spent running at the kernel level.

%iowait

Shows the percentage of total CPU time spent waiting for I/O operations.

%steal

The percentage of virtual CPUs that the hypervisor was waiting to service another virtual process.

%idle

Displays the percentage of CPU idle time to total CPU time.

2. Memory Utilization

sar -r (view all day)
sar -r 1 10 (1: every second, 10: write 10 times)

2.1. Memory output item description

Output Detailed description
kbmemfree This value is basically the same as the free value in the free command, so it does not include the buffer and cache space.
kbmemused This value is basically the same as the used value in the free command, so it includes the buffer and cache space.
%memused This value is a percentage of kbmemused and the total memory (excluding swap).
kbbuffers and kbcached These two values ​​are buffer and cache in the free command.
kbcommit Ensure the memory required by the current system, that is, the memory required to ensure no overflow (RAM + swap).
%commit This value is a percentage of kbcommit and the total amount of memory (including swap).

3. Disk I/O

sar -d (view all day)
sar -d 1 2 (1: every second, 2: write twice)

3.1. IO output item description

Output Detailed description
await Indicates the average waiting time (in milliseconds) for each device I/O operation.
svctm Indicates the average service time (in milliseconds) for each device I/O operation.
%util Indicates the percentage of time per second that is spent on I/O operations.

4. Network traffic

sar -n DEV (view all day)

sar -n DEV 1 2 (1: every second, 2: write twice)

4.1. DEV output item description

Output Detailed description
IFACE This is the name of the network device.
rxpck/s The number of packets received per second.
txpck/s The number of packets sent per second.
rxkB/s The number of bytes received per second.
txkB/s The number of bytes sent per second.
rxcmp/s The number of compressed packets received per second.
txcmp/s The number of compressed packets sent per second.
rxmcst/s The number of multicast packets received per second.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed Tutorial on Using xargs Command on Linux
  • Use of Linux tr command
  • Use of Linux ipcs command
  • Use of Linux ls command
  • Use of Linux sed command
  • Use of Linux read command
  • Use of Linux usermod command
  • Use of Linux passwd command
  • Detailed explanation of the use of Linux time command
  • Use of Linux ln command
  • Use of Linux telnet command

<<:  A simple and in-depth study of async and await in JavaScript

>>:  Detailed explanation of MySQL redo log (redo log) and rollback log (undo logo)

Recommend

The most common mistakes in HTML tag writing

We better start paying attention, because HTML Po...

Detailed tutorial on building Gitlab server on CentOS8.1

There is no need to say much about the difference...

Multiple ways to calculate age by birthday in MySQL

I didn't use MySQL very often before, and I w...

Examples of 4 methods for inserting large amounts of data in MySQL

Preface This article mainly introduces 4 methods ...

js implements clock component based on canvas

Canvas has always been an indispensable tag eleme...

Django online deployment method of Apache

environment: 1. Windows Server 2016 Datacenter 64...

mysql trigger creation and usage examples

Table of contents What is a trigger Create a trig...

mysql5.7.19 winx64 decompressed version installation and configuration tutorial

Recorded the installation tutorial of mysql 5.7.1...

Vue+el-table realizes merging cells

This article example shares the specific code of ...

How to view the network routing table in Ubuntu

What are Routing and Routing Table in Linux? The ...

How to use domestic image warehouse for Docker

1. Problem description Due to some reasons, the d...

22 Vue optimization tips (project practical)

Table of contents Code Optimization Using key in ...