top 監控整體
top裡按1,看每個cpu使用狀況 top裡按2,看每個node使用狀況
//如果是centos,以下須先安裝 yum -y install sysstat
iostat 監控 cpu 及 block 設備(及分割槽) io
# iostat -xz 1 Linux 2.6.32-696.el6.x86_64 (DX_JQ_2) 12/07/2018 _x86_64_ (32 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.05 0.00 0.07 0.01 0.00 99.87 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 3.29 0.02 1.13 1.28 35.30 31.88 0.02 20.90 7.84 21.13 5.19 0.60 dm-0 0.00 0.00 0.02 4.41 1.27 35.29 8.25 0.07 14.68 8.78 14.70 1.34 0.60 avg-cpu: %user %nice %system %iowait %steal %idle 0.06 0.00 0.06 0.00 0.00 99.87
iostat [參數] [間隔秒][次數] iostat -x 1 10 //監控詳細信息,間隔1秒,共10次 iostat -C iostat -dk -C 显示 CPU 使用情况 -d 显示磁盘使用情况 -k 以 KB 为单位显示 -m 以 M 为单位显示 -N 显示磁盘阵列(LVM) 信息 -n 显示 NFS 使用情况 -p[磁盘] 显示磁盘和分区的情况 -t 显示终端和 CPU 的信息 -x 显示详细信息 -V 显示版本信息 監控cpu的屬性 %user CPU 处在用户模式下的时间百分比 %nice CPU 处在带 NICE 值的用户模式下的时间百分比 %system CPU 处在系统模式下的时间百分比 %iowait CPU 等待输入输出完成时间的百分比 %steal 管理程序维护另一个虚拟处理器时,虚拟 CPU 的无意识等待时间百分比 %idle CPU 空闲时间百分比 監控disk的屬性 Device 监测设备名称 rrqm/s 每秒需要读取需求的数量 wrqm/s 每秒需要写入需求的数量 r/s 每秒实际读取需求的数量 w/s 每秒实际写入需求的数量 rsec/s 每秒读取区段的数量 wsec/s 每秒写入区段的数量 rkB/s 每秒实际读取的大小,单位为 KB wkB/s 每秒实际写入的大小,单位为 KB rMB/s 每秒实际读取的大小,单位为 MB wMB/s 每秒实际写入的大小,单位为 MB avgrq-sz 需求的平均大小区段 avgqu-sz 需求的平均队列长度 await 等待 I/O 平均的时间(milliseconds) svctm I/O 需求完成的平均时间 %util 被 I/O 需求消耗的 CPU 百分比 tps屬性 tps 该设备每秒的传输次数 kB_read/s 每秒从设备读取的数据量 kB_wrtn/s 每秒向设备写入的数据量 kB_read 读取的总数据量 kB_wrtn 写入的总数据量
mpstat 監控cpu
mpstat -A //監控所有狀態 mpstat -P 0/1/ALL // 指定cpu編號 mpstat -P ALL 2 3 //每兩秒產生一次所有cpu資料,共3次 範例 mpstat -P All 2 11時38分44秒 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 11時38分46秒 all 55.25 0.00 1.00 0.75 0.00 0.25 0.00 0.00 0.00 42.75 11時38分46秒 0 10.10 0.00 1.52 1.52 0.00 0.00 0.00 0.00 0.00 86.87 11時38分46秒 1 100.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 %user 在internal时间段里,用户态的CPU时间(%),不包含nice值为负进程 (usr/total)*100 %nice 在internal时间段里,nice值为负进程的CPU时间(%) (nice/total)*100 %sys 在internal时间段里,内核时间(%) (system/total)*100 %iowait 在internal时间段里,硬盘IO等待时间(%) (iowait/total)*100 %irq 在internal时间段里,硬中断时间(%) (irq/total)*100 %soft 在internal时间段里,软中断时间(%) (softirq/total)*100 %idle 在internal时间段里,CPU除去等待磁盘IO操作外的因为任何原因而空闲的时间闲置时间(%) (idle/total)*100
sar 監控cpu,mem,i/o,net io
sar -P All 1 2 //監控所有cpu狀態,間隔1秒,共2次 sar -u 2 3 //監控所有cpu狀態,間隔2秒,共3次 sar -r //記憶體使用統計 sar -R //記憶體整體統計 sar -W //swap統計 sar -b //I/O及傳輸率統計 sar -d //block device statistics. //block device is a kind of file, //which represents a device of some kind, with data //that can be read or written to it in block. //可用block形式讀寫資料的裝置(linux中都當成檔案) -b I/O and transfer rate statistics -B Paging statistics -d Block device statistics -F [ MOUNT ] Filesystems statistics -H Hugepages utilization statistics -I {| SUM | ALL | XALL } Interrupts statistics -m {[,...] | ALL } Power management statistics Keywords are: 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 {[,...] | ALL } Network statistics 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) -q Queue length and load average statistics -r Memory utilization statistics -R Memory statistics -S Swap space utilization statistics -u [ ALL ] CPU utilization statistics -v Kernel table statistics -w Task creation and system switching statistics -W Swapping statistics -y TTY device statistics
uptime
檢視服務器負載狀況
uptime
22:37:31 up 65 days, 3:15, 1 user, load average: 40.00, 25.01, 10.05
檢視當前服務器1min, 5min, 15min 平均負載
是cpu負載、IO負載的整體評估
如果1min 的值大於 15min的值,表示負載越來越高。
dmesg
檢視資訊
$ dmesg |tail [ 2567.534310] IPv6: ADDRCONF(NETDEV_UP): em3: link is not ready [ 2570.386536] tg3 0000:02:00.0 em3: Link is up at 1000 Mbps, full duplex [ 2570.386550] tg3 0000:02:00.0 em3: Flow control is off for TX and off for RX [ 2570.386555] tg3 0000:02:00.0 em3: EEE is disabled [ 2570.386584] IPv6: ADDRCONF(NETDEV_CHANGE): em3: link becomes ready [20907.774686] perf: interrupt took too long (2502 > 2500), lowering kernel.perf_event_max_sample_rate to 79000 [50276.167405] perf: interrupt took too long (3173 > 3127), lowering kernel.perf_event_max_sample_rate to 63000 [96662.454537] perf: interrupt took too long (4010 > 3966), lowering kernel.perf_event_max_sample_rate to 49000 [143249.558510] perf: interrupt took too long (5025 > 5012), lowering kernel.perf_event_max_sample_rate to 39000 [204028.503117] perf: interrupt took too long (6286 > 6281), lowering kernel.perf_event_max_sample_rate to 31000
vmstat
檢視虛擬記憶體狀況
記憶體、分頁、IO、cpu
$ vmstat 1 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 3082644 2076 4156120 0 0 1 210 12 9 1 0 99 0 0 0 0 0 3083180 2076 4156112 0 0 0 473 2231 2420 1 0 99 0 0 0 0 0 3083212 2076 4156112 0 0 0 12510 3946 3945 1 2 97 0 0 0 0 0 3083684 2076 4156096 0 0 0 1403 2333 1725 1 0 99 0 0 1 0 0 3082868 2076 4156388 0 0 0 505 2307 1795 4 1 95 0 0 0 0 0 3083508 2076 4156040 0 0 0 475 1888 1570 1 1 99 0 0 0 0 0 3083152 2076 4156040 0 0 0 8090 1694 1910 1 1 99 0 0
procs
r:在cpu上執行和等待執行的程式數量
b:阻塞的程式
memory
swpd:虛擬記憶體使用大小
free:空閒的記憶體大小
buffer:用作 buffer 的記憶體大小
cache:用作 cache 的記憶體大小
swap
si:每秒從交換區寫道記憶體的大小
so:每秒寫入到交換區的大小
IO
bi:block device 每秒接收的 block 數量
bo:block device 每秒傳送的 block 數量
system
in:每秒 cpu 中斷次數
cs:每秒 content 切換次數(越小越好)
CPU
us:使用者的 cpu 時間
sy:系統核心執行 cpu 時間
id:空閒的 cpu 時間
wa:等待 IO 的時間
st:從虛擬機中偷走的時間?
free
檢視系統整體記憶體
$ free -h total used free shared buff/cache available Mem: 7.6G 697M 3.0G 23M 3.9G 6.5G Swap: 8.0G 0B 8.0G
buffer cache 是block device 的記憶體快取
page cache 是檔案資料的快取
沒有留言:
張貼留言