Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cloud Computing Development course: operation and maintenance engineer must have skills-- sar

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Today's article is to share with you some cloud computing development tutorials, today is: operation and maintenance engineers must have skills-sar.

SAR is an acronym for system activity report (System Activity Report). As its name suggests, SAR is a command used in Unix and Linux operating systems to collect, report, and save CPU, memory, input and output port usage. The SAR command can generate reports dynamically or save them in a log file.

If you do not have the package installed, you can use the following command to install it.

[root@localhost ~] # yum install sysstat

Start the sadc (system activity data collector) service (sysstat) so that the report is written to the log file "/ var/log/sa/saDD" and existing documents are archived. DD represents the current date.

[root@localhost ~] # systemctl start sysstat

[root@localhost ~] # systemctl enable sysstat

It collects data every 10 minutes and forms a report every day.

Use of the sar command

Common format of sar command

Sar [options] [- A] [- o file] t [n]

Where:

T is the sampling interval, n is the number of samples, and the default value is 1

-o file means to store the result of the command in a file in binary format, where file is the file name.

View CPU usage

Sar-u: information such as cpu usage displayed by default is sar-u

View average load

Sar-Q: view average load

After you specify-Q, you can view the number of processes in the running queue, the process size on the system, the average load, etc. Compared with other commands, it can see how the metrics change over time.

Runq-sz: length of the run queue (number of processes waiting to run)

Plist-sz: number of processes (processes) and threads (threads) in the process list

Ldavg-1: average system load in the last 1 minute ldavg-5: average system load in the past 5 minutes

Ldavg-15: average system load over the past 15 minutes

Network traffic

Sar-n DEV network card

IFACE represents the device name

Number of packets received by rxpck/s per second

Number of packets sent by txpck/s per second

Amount of data received by rxKB/s per second (in KByte 1KB=1000byte=8000bit)

The amount of data sent out by txKB/s per second, in KByte

If the packet loss of the server is very serious, you need to check whether the Nic traffic is abnormal. If the rxpck of the received data part is greater than 4000, or the rxKB is greater than 5000, it is possible to be attacked. The traffic of the normal server network card is not so large. Unless you're copying data.

Calculate the actual speed, take the peak of rxkb or txkb, convert it into KB, such as 686KByte, and then use 686*8/1000=5.4MBit

Bytes bytes, abbreviated to B [smallest unit of computer hard disk]

Bit bit, 1Byte=8bit [smallest unit in the network]

Bps = bit per second bits per second

Pps = package per second packets per second Mb, Gb,10Gb

10Gb=10000Mb [1GB=1024MB in computer, 1Gb=1000Mb in network]

Broadband 10Mb, download speed is 1.25MB, 10Mbpm 10Mbit 10Mbit/8=1.25Mbyte=1.25MB

View memory usage

Sar-r: after you specify-r, you can view the physical memory usage

Kbmemfree: this value is basically the same as the free value in the free command, so it does not include buffer and cache space.

Kbmemused: this value is basically the same as the used value in the free command, so it includes buffer and cache space.

% memused: physical memory usage, which is a percentage of kbmemused and total memory (excluding swap).

Kbbuffers and kbcached: these two values are buffer and cache in the free command.

Kbcommit: guarantee the memory needed by the current system, that is, the memory needed to ensure that it does not overflow (RAM+swap).

% commit: this value is a percentage of kbcommit to total memory (including swap).

View what happened to the page exchange

Sar-W: check what happens to the page exchange

When a page exchange occurs, the throughput of the server will drop significantly; when the server is in poor condition, if you suspect that the page exchange has occurred because of insufficient memory, you can use this command to confirm whether a large number of swaps have taken place.

Pswpin/s: the number of swap pages (swap page) swapped in by the system per second

Pswpout/s: the number of swap pages (swap page) swapped out by the system per second

Comprehensive use of sar

To determine the bottleneck of the system, it sometimes requires a combination of several sar command options

It is suspected that there is a bottleneck in CPU. You can check it with sar-u and sar-Q.

Memory bottleneck is suspected. Check it with sar-B, sar-r, sar-W, etc.

It is suspected that there is a bottleneck in IBG O, which can be checked by sar-b, sar-u and sar-d.

Description of other sar parameters

-A summarizes all the reports

-a report on the use of reading and writing documents

-B reports the use of additional caches

-b report cache usage

-c reports the use of system calls

-d report disk usage

-g report the use of serial port

-h reports statistics on buffer usage

-m reports the usage of IPC message queues and semaphores

-n report on the use of named cache

-p report on the use of paging activities

-Q reports the average length of running queues and switching queues

-R reports on the activities of the process

-r reports unused memory pages and hard disk blocks

-u report the utilization of CPU

-v report process, I node, file and lock table status

-w report the status of system exchange activities

-y report TTY device activity

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report