sar [options] [-A] [-o file] t [n] 在命令行中, n 和 t 兩個參數組合起來定義採樣間隔和次數, t 爲採樣間隔, 是必須有的參數, n 爲採樣次數,是可選的,默認值是 1, -o file 表示將命令結果以二進制格式存放在文件中, file 在此處不是關鍵字,是文件名。 options 爲命令行選項:ios
-A:全部報告的總和。數組
-u: CPU 利用率bash
-v:進程、節點、文件和鎖表狀態。網絡
-p:像是當前系統中指定 CPU 使用信息。多線程
-d:硬盤使用報告。dom
-r:顯示系統內存的使用狀況。性能
-n: 顯示網絡運行狀態。 參數後面可跟 DEV、 EDEV、 SOCK 和 FULL。 DEV 顯示網絡接口信息, EDEV 顯示網絡錯誤的統計數據, SOCK 顯示套接字信息, FULL 顯示前三參數全部信息。命令行
-q:顯示運行隊列的大小,它與系統當時的平均負載相同線程
-B:內存分頁狀況code
-R:顯示進程在採樣時間內的活動狀況。
-g:串口 I/O 的狀況。
-b:緩衝區使用狀況。
-a:文件讀寫狀況。
-c:系統調用狀況。
-R:進程的活動狀況。
-y:終端設備活動狀況。
-W:系統交換活動。
[root@localhost ~]# sar -n DEV 1 2 Linux 3.10.0-957.el7.x86_64 (localhost.localdomain) 03/02/2019 _x86_64_ (4 CPU) 01:41:13 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 01:41:14 AM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 01:41:14 AM ens33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 01:41:14 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 01:41:15 AM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 01:41:15 AM ens33 0.99 1.98 0.06 0.48 0.00 0.00 0.00 Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Average: ens33 0.50 0.99 0.03 0.24 0.00 0.00 0.00
[root@localhost ~]# ethtool ens33 Settings for ens33: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: off (auto) Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes [root@localhost ~]# mii-tool ens33 ens33: negotiated 1000baseT-FD flow-control, link ok
[root@localhost ~]# ps PID TTY TIME CMD 9941 pts/0 00:00:00 bash 10128 pts/0 00:00:00 ps
[root@localhost ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 125416 3916 ? Ss 01:24 0:07 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 root 2 0.0 0.0 0 0 ? S 01:24 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 01:24 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< 01:24 0:00 [kworker/0:0H] root 6 0.0 0.0 0 0 ? S 01:24 0:02 [kworker/u256:0] root 7 0.0 0.0 0 0 ? S 01:24 0:01 [migration/0] root 8 0.0 0.0 0 0 ? S 01:24 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S 01:24 0:06 [rcu_sched] root 10 0.0 0.0 0 0 ? S< 01:24 0:00 [lru-add-drain]
[root@localhost ~]# ps -elf F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 4 S root 1 0 0 80 0 - 31354 ep_pol 01:24 ? 00:00:07 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 1 S root 2 0 0 80 0 - 0 kthrea 01:24 ? 00:00:00 [kthreadd] 1 S root 3 2 0 80 0 - 0 smpboo 01:24 ? 00:00:00 [ksoftirqd/0] 1 S root 5 2 0 60 -20 - 0 worker 01:24 ? 00:00:00 [kworker/0:0H] 1 S root 6 2 0 80 0 - 0 worker 01:24 ? 00:00:02 [kworker/u256:0] 1 S root 7 2 0 -40 - - 0 smpboo 01:24 ? 00:00:01 [migration/0] 1 S root 8 2 0 80 0 - 0 rcu_gp 01:24 ? 00:00:00 [rcu_bh] 1 S root 9 2 0 80 0 - 0 rcu_gp 01:24 ? 00:00:06 [rcu_sched] 1 S root 10 2 0 60 -20 - 0 rescue 01:24 ? 00:00:00 [lru-add-drain]
[root@localhost ~]# ps -eLf UID PID PPID LWP C NLWP STIME TTY TIME CMD root 1 0 1 0 1 01:24 ? 00:00:07 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 root 2 0 2 0 1 01:24 ? 00:00:00 [kthreadd] root 3 2 3 0 1 01:24 ? 00:00:00 [ksoftirqd/0] root 5 2 5 0 1 01:24 ? 00:00:00 [kworker/0:0H] root 6 2 6 0 1 01:24 ? 00:00:02 [kworker/u256:0] root 7 2 7 0 1 01:24 ? 00:00:01 [migration/0] root 8 2 8 0 1 01:24 ? 00:00:00 [rcu_bh] root 9 2 9 0 1 01:24 ? 00:00:06 [rcu_sched] root 10 2 10 0 1 01:24 ? 00:00:00 [lru-add-drain]