sar command
linux의 sar
명령어(CLI)는 Linux 서브시스템의 성능을 모니터링 할 수 있는 명령어 입니다.
기본 사용법
$> sar -V
sysstat version 12.7.4
(C) Sebastien Godard (sysstat <at> orange.fr)
# CPU 코어 0을 1초 단위로 1번 수집하기
$> sar -P 0 1 1
Linux 6.5.5-1-MANJARO (geeksaga) 11/02/2023 _x86_64_ (16 CPU)
03:49:45 PM CPU %user %nice %system %iowait %steal %idle
03:49:46 PM 0 3.06 0.00 1.02 0.00 0.00 95.92
Average: 0 3.06 0.00 1.02 0.00 0.00 95.92
# 모든 CPU를 2초 단위로 3번 수집하기
$> sar -u 2 3
Linux 6.5.5-1-MANJARO (geeksaga) 11/02/2023 _x86_64_ (16 CPU)
03:53:50 PM CPU %user %nice %system %iowait %steal %idle
03:53:52 PM all 1.63 0.00 1.79 0.06 0.00 96.52
03:53:54 PM all 3.75 0.06 3.63 0.19 0.00 92.37
03:53:56 PM all 2.36 0.03 1.73 0.06 0.00 95.81
Average: all 2.58 0.03 2.38 0.11 0.00 94.91
sar help
$> sar --help
Usage: sar [ options ] [ <interval> [ <count> ] ]
Main options and reports (report name between square brackets):
-B Paging statistics [A_PAGE]
-b I/O and transfer rate statistics [A_IO]
-d Block devices statistics [A_DISK]
-F [ MOUNT ]
Filesystems statistics [A_FS]
-H Hugepages utilization statistics [A_HUGE]
-I [ SUM | ALL ]
Interrupts statistics [A_IRQ]
-m { <keyword> [,...] | ALL }
Power management statistics [A_PWR_...]
Keywords are:
BAT Batteries capacity
CPU CPU instantaneous clock frequency
FAN Fans speed
FREQ CPU average clock frequency
IN Voltage inputs
TEMP Devices temperature
USB USB devices plugged into the system
-n { <keyword> [,...] | ALL }
Network statistics [A_NET_...]
Keywords are:
DEV Network interfaces
EDEV Network interfaces (errors)
NFS NFS client
NFSD NFS server
SOCK Sockets (v4)
IP IP traffic (v4)
EIP IP traffic (v4) (errors)
ICMP ICMP traffic (v4)
EICMP ICMP traffic (v4) (errors)
TCP TCP traffic (v4)
ETCP TCP traffic (v4) (errors)
UDP UDP traffic (v4)
SOCK6 Sockets (v6)
IP6 IP traffic (v6)
EIP6 IP traffic (v6) (errors)
ICMP6 ICMP traffic (v6)
EICMP6 ICMP traffic (v6) (errors)
UDP6 UDP traffic (v6)
FC Fibre channel HBAs
SOFT Software-based network processing
-q [ <keyword> [,...] | PSI | ALL ]
System load and pressure-stall statistics
Keywords are:
LOAD Queue length and load average statistics [A_QUEUE]
CPU Pressure-stall CPU statistics [A_PSI_CPU]
IO Pressure-stall I/O statistics [A_PSI_IO]
MEM Pressure-stall memory statistics [A_PSI_MEM]
-r [ ALL ]
Memory utilization statistics [A_MEMORY]
-S Swap space utilization statistics [A_MEMORY]
-u [ ALL ]
CPU utilization statistics [A_CPU]
-v Kernel tables statistics [A_KTABLES]
-W Swapping statistics [A_SWAP]
-w Task creation and system switching statistics [A_PCSW]
-y TTY devices statistics [A_SERIAL]
TLDR
$> tldr sar
sar
Monitor performance of various Linux subsystems.
More information: https://manned.org/sar.
- Report I/O and transfer rate issued to physical devices, one per second (press CTRL+C to quit):
sar -b 1
- Report a total of 10 network device statistics, one per 2 seconds:
sar -n DEV 2 10
- Report CPU utilization, one per 2 seconds:
sar -u ALL 2
- Report a total of 20 memory utilization statistics, one per second:
sar -r ALL 1 20
- Report the run queue length and load averages, one per second:
sar -q 1
- Report paging statistics, one per 5 seconds:
sar -B 5