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

Semantics, writing, and best practices of link A

The semantics, writing style, and best practices ...

A brief analysis of how to use border and display attributes in CSS

Introduction to border properties border property...

Using JS to implement a small game of aircraft war

This article example shares the specific code of ...

innerHTML Application

Blank's blog: http://www.planabc.net/ The use...

MySQL REVOKE to delete user permissions

In MySQL, you can use the REVOKE statement to rem...

Sample code for highlighting search keywords in WeChat mini program

1. Introduction When you encounter a requirement ...

How to use Javascript to generate smooth curves

Table of contents Preface Introduction to Bezier ...

WeChat applet records user movement trajectory

Table of contents Add Configuration json configur...

Detailed explanation of Linux index node inode

1. Introduction to inode To understand inode, we ...

MYSQL uses Union to merge the data of two tables and display them

Using the UNION Operator union : Used to connect ...

Sample code for modifying the input prompt text style in html

On many websites, we have seen the input box disp...

How to implement mobile web page size adaptation

I finally finished the project at hand, and the m...

Understand CSS3 FlexBox elastic layout in 10 minutes

Basic Introduction Features Flexbox is a CSS disp...

MYSQL slow query and log settings and testing

1. Introduction By enabling the slow query log, M...