iostat 查看CPU及輸入/輸出設備狀態信息
iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
實例
[root@zabbix shell]# iostat
Linux 3.10.0-514.el7.x86_64 (zabbix) 2017年12月04日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.13 0.00 0.27 0.00 0.00 99.60
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 0.04 0.22 1.25 225037 1287896
- 第一段 系統內核 當前時間 系統版本
- 第二段 CPU狀態
- 第三段 硬盤狀態
- iostat 1 5 ,每秒顯示一次,一共5秒
iostate可顯示CPU和硬盤狀態,但是無法追蹤到具體進程
iotop 監控系統I/O狀態
iotop - simple top-like I/O monitor
iotop可監視I/O狀況,並追蹤到進程
實例
Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s
Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
64743 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.09 % [kworker/0:2]
1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % systemd --switched-root --system --deserialize 21
2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd]
3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0]
6 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/u128:0]
7 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0]
8 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_bh]
9 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [rcu_sched]
10 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/0]
12 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khelper]
13 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kdevtmpfs]
14 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [netns]
15 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khungtaskd]
16 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [writeback]
17 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kintegrityd]
18 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [bioset]
19 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kblockd]
20 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [md]
478 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % NetworkManager --no-daemon [gmain]
26 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kswapd0]
27 be/5 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksmd]
28 be/7 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khugepaged]
29 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [fsnotify_mark]
30 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [crypto]
38 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthrotld]
40 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kmpath_rdacd]
41 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kpsmoused]
43 be/0 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ipv6_addrconf]
1069 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % rsyslogd -n [in:imjournal]
1070 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % rsyslogd -n [rs:main Q:Reg]
- iotop是動態顯示I/O狀態,按Q鍵或Ctrl+C組合鍵退出
- iotop可追蹤到進程,查看具體具體某個I/O異常的進程信息
ps 報告系統當前進程信息
ps - report a snapshot of the current processes
- 常用命令 ps aux ,通常與管道符搭配使用
[root@zabbix ~]# ps aux |grep ssh root 1163 0.0 0.0 82960 1392 ? Ss 11月22 0:00 /usr/sbin/sshd root 64564 0.0 0.3 146016 5680 ? Ss 14:48 0:00 sshd: root@pts/1 root 64689 0.0 0.3 146152 5676 ? Ss 15:20 0:00 sshd: root@pts/0 root 64795 0.0 0.0 112680 976 pts/0 R+ 15:52 0:00 grep --color=auto ssh
STAT狀態說明
- D 不能中斷的進程
- R run狀態的進程
- S sleep狀態的進程
- T 暫停狀態的進程
- Z 殭屍進程
- < 高優先級進程
- N 低優先級進程
- L 內存中被鎖的內存分列
- s 主進程
-
l 多線程進程
netstat 顯示網絡連接狀態,路由表,接口狀態
netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
常用命令
- netstat -lnp 顯示監控中的網絡連接端口及socket
- netstat -lntp 僅顯示網絡連接TCP端口
- netstat -luntp 顯示所有網絡連接端口(tcp及udp)
[root@zabbix ~]# netstat -luntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:14322 0.0.0.0:* LISTEN 1163/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1824/master tcp6 0 0 :::3306 :::* LISTEN 1421/mysqld tcp6 0 0 :::14322 :::* LISTEN 1163/sshd tcp6 0 0 ::1:25 :::* LISTEN 1824/master udp 0 0 127.0.0.1:323 0.0.0.0:* 455/chronyd udp6 0 0 ::1:323 :::* 455/chronyd
命令總結
- iostate 查看系統及IO設備狀態
- iotop查看系統IO狀態及相關進程
- ps 查看系統進程
- netstat 查看系統監控中的網絡連接端口