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

A brief discussion on Linux virtual memory

Table of contents origin Virtual Memory Paging an...

Monitor the size change of a DOM element through iframe

A common problem encountered during the developme...

Detailed explanation of writing multiple conditions of CSS: not

The :not pseudo-class selector can filter element...

Nine advanced methods for deduplicating JS arrays (proven and effective)

Preface The general methods are not listed here, ...

MySQL green decompression version installation and configuration steps

Steps: 1. Install MySQL database 1. Download the ...

vue+echarts realizes the flow effect of China map (detailed steps)

@vue+echarts realizes the flow effect of China ma...

Solution to Navicat Premier remote connection to MySQL error 10038

Remote connection to MySQL fails, there may be th...

Nginx Linux installation and deployment detailed tutorial

1. Introduction to Nginx Nginx is a web server th...

MySQL foreign key constraint (FOREIGN KEY) case explanation

MySQL foreign key constraint (FOREIGN KEY) is a s...

How to view the execution time of SQL statements in MySQL

Table of contents 1. Initial SQL Preparation 2. M...

A brief analysis of MySQL parallel replication

01 The concept of parallel replication In the mas...

About the selection of time date type and string type in MySQL

Table of contents 1. Usage of DATETIME and TIMEST...