日常运维(1)w命令,vmstat命令,top命令,sar命令,nload命令

w命令
用于显示已经登陆系统的用户列表,并显示用户正在执行的指令。执行这个命令可得知目前登入系统的用户有那些人,以及他们正在执行的程序。单独执行w命令会显示所有的用户,您也可指定用户名称,仅显示某位用户的相关信息。

例:
[root@ALIYUN ~]# w
08:42:21 up 2 days, 13:09 , 1 user , load average: 0.00, 0.01, 0.05
当前时间 开机时长 当前用户数 系统负载值:1-5-15分钟内的活动进程
当平均负载1分钟内的活动进程数,约等于逻辑cpu数,负载最理想,高于逻辑CPU数表示负载太高,低于太多表示,太空闲,系统空转
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
用户 终端 访问来源 登录时间 cpu的空闲时长 终端占用时间 进程占用时长 当前命令
root pts/0 42.***.190.*** 08:42 5.00s 0.04s 0.00s w
[root@ALIYUN /]# uptime 命令查询结果等于w命令的第一行, 打印系统总运行时间长和平均负载
09:02:41 up 2 days, 13:29, 1 user, load average: 0.00, 0.01, 0.05
[root@ALIYUN /]# cat /proc/cpuinfo 查看CPU信息
processor: 0 逻辑CPU数,0表示只有一个逻辑cpu
vendor_id: GenuineIntel
cpu family: 6
model: 85
model name: Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz

vmstat命令
显示虚拟内存状态(“Viryual Memory Statics”),但是它可以报告关于进程、内存、I/O等系统整体运行状态。

例:
[root@ALIYUN /]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
4 0 0 999128 161824 577812 0 0 2 4 25 119 1 0 99 0 0

run:活动进程数 , block;等待进程数 , swap:虚拟内存数据,物理内存满时有变化 , free可用内存 , buff缓冲大小 , cache缓存大小 , si/so:每秒进出swap的数据量 , bi/bo:从内存进出磁盘的块数 ,, in:每秒中断数,cs:每秒切换数 , us:执行用户进程占比%,sy:执行系统进程占比%,idle:空闲资源% , wa:I/O等待时间% , st:其他子机/虚拟机占用比
[root@ALIYUN /]# vmstat 1 5 每1秒查看一次,连续查询5次
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
3 0 0 999032 161876 577856 0 0 2 4 26 119 1 0 99 0 0
0 0 0 999032 161876 577860 0 0 0 0 266 349 1 0 99 0 0
0 0 0 999032 161876 577860 0 0 0 0 285 375 0 1 99 0 0
0 0 0 999032 161876 577860 0 0 0 0 291 371 1 0 99 0 0
0 0 0 998628 161876 577860 0 0 0 16 310 417 1 1 98 0 0
[root@ALIYUN /]#

top命令
实时动态地查看系统的整体运行情况,是一个综合了多方信息监测系统性能和运行信息的实用工具。通过top命令所提供的互动式界面,用热键可以管理。

top 查看进程使用资源的情况
数字1, 切换所有核CPU和指定CPU使用情况
M 按内存使用量排序
P 按cpu使用量排序
top -c 查看详细的进程信息,具体的进程命令
top -bn1 静态显示所有进程
q 退出

例:
[root@ALIYUN ~]# top
top - 10:12:01 up 2 days, 14:38, 2 users, load average: 0.04, 0.04, 0.05
第一行信息和w命令,uptime命令输出一致
Tasks: 87 total, 2 running, 85 sleeping, 0 stopped, 0 zombie
任务s: 87个总共 2个运行中 85个睡眠中 0个已停止 0个僵尸进程
%Cpu(s): 0.3 us , 0.7 sy , 0.0 ni , 99.0 id , 0.0 wa , 0.0 hi, 0.0 si, 0.0 st
CPU占比 us用户占比 sy内核占比 ni用户优先级进程占比 id空闲占比 wa等待进程占比 , hi硬件中断,si软件中断 , st:其他子机/虚拟机占用比
KiB Mem : 1883416 total , 993188 free , 148616 used , 741612 buff/cache
(单位)内存: 总共 空闲 已用 交换总量 缓冲/缓存
KiB Swap : 0 total , 0 free , 0 used . 1562084 avail Mem
(单位)内存: 总共 空闲 已用 可用内存
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
PID进程ID USER进程用户 PR优先级 NI用户优先进程占比:nice值为负值高优先,正值低优先 VIRT=SWAP+RES 进程使用的虚拟内存总量(kb) RES:进程占用内存(kb) SHR:所占共享内存(kb) S:进程状态,D连续睡眠状态,R运行,S睡眠,T跟踪/停止,Z僵尸进程 , %CPU时间占用比% %MEM内存占用比% TIME+COMMAND执行时间,命令名/命令行
810 root 20 0 562760 18716 5880 S 0.3 1.0 0:21.87 tuned
1019 root 20 0 129948 12268 8036 S 0.3 0.7 8:13.28 AliYunDun
1 root 20 0 43488 3936 2508 S 0.0 0.2 0:03.84 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:02.45 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
6 root 20 0 0 0 0 S 0.0 0.0 0:01.65 kworker/u2:0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 R 0.0 0.0 0:10.81 rcu_sched
10 root rt 0 0 0 0 S 0.0 0.0 0:00.75 watchdog/0

[root@localhost ~]# top -c 查看详细的进程信息,具体的进程命令
top - 13:20:48 up 2:20, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 98 total, 1 running, 97 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1008152 total, 684716 free, 142896 used, 180540 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 685804 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 128164 6820 4052 S 0.0 0.7 0:01.80 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kthreadd]
3 root 20 0 0 0 0 S 0.0 0.0 0:00.09 [ksoftirqd/0]
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:0H]
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 [migration/0]
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_bh]
9 root 20 0 0 0 0 S 0.0 0.0 0:00.59 [rcu_sched]
10 root rt 0 0 0 0 S 0.0 0.0 0:00.13 [watchdog/0]
[root@localhost ~]# top -bn1 一次性静态显示所有进程
top - 13:23:49 up 2:23, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 98 total, 1 running, 97 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1008152 total, 684784 free, 142836 used, 180532 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 685872 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 128164 6820 4052 S 0.0 0.7 0:01.80 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.09 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.59 rcu_sched
10 root rt 0 0 0 0 S 0.0 0.0 0:00.13 watchdog/0
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
13 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
26 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
27 root 39 19 0 0 0 S 0.0 0.0 0:00.08 khugepaged
28 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld
37 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u128:1
38 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kmpath_rdacd
39 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused
41 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ipv6_addrconf
60 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 deferwq
92 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
233 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 mpt_poll_0
235 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 mpt/0
236 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
240 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
241 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_0
242 root 20 0 0 0 0 S 0.0 0.0 0:00.56 kworker/u128:2
243 root 20 0 0 0 0 S 0.0 0.0 0:00.01 scsi_eh_1
246 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_1
250 root 20 0 0 0 0 S 0.0 0.0 0:00.01 scsi_eh_2
252 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_2
254 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ttm_swap
274 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
275 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfsalloc
276 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs_mru_cache
277 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-buf/sda3
278 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-data/sda3
279 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-conv/sda3
280 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-cil/sda3
281 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-reclaim/sda
282 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-log/sda3
283 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-eofblocks/s
284 root 20 0 0 0 0 S 0.0 0.0 0:02.19 xfsaild/sda3
356 root 20 0 34944 3092 2768 S 0.0 0.3 0:00.27 systemd-journal
380 root 20 0 121356 4080 2588 S 0.0 0.4 0:00.00 lvmetad
384 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 rpciod
386 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xprtiod
392 root 20 0 47544 5392 2828 S 0.0 0.5 0:00.15 systemd-udevd
455 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-buf/sda1
457 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-data/sda1
458 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-conv/sda1
460 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-cil/sda1
462 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-reclaim/sda
464 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-log/sda1
466 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-eofblocks/s
468 root 20 0 0 0 0 S 0.0 0.0 0:00.00 xfsaild/sda1
518 root 16 -4 55452 892 488 S 0.0 0.1 0:00.02 auditd
520 root 12 -8 84500 800 744 S 0.0 0.1 0:00.05 audispd
522 root 16 -4 24052 900 716 S 0.0 0.1 0:00.01 sedispatch
543 polkitd 20 0 536056 15280 4864 S 0.0 1.5 0:00.12 polkitd
545 avahi 20 0 28116 1716 1424 S 0.0 0.2 0:00.03 avahi-daemon
546 root 20 0 99612 6076 4472 S 0.0 0.6 0:00.03 VGAuthService
547 root 20 0 305368 6360 4904 S 0.0 0.6 0:16.91 vmtoolsd
549 dbus 20 0 32936 1920 1408 S 0.0 0.2 0:00.21 dbus-daemon
552 avahi 20 0 27988 232 0 S 0.0 0.0 0:00.00 avahi-daemon
560 root 20 0 219480 5668 3852 S 0.0 0.6 0:00.02 abrtd
561 root 20 0 216984 4772 3360 S 0.0 0.5 0:00.05 abrt-watch-log
562 root 20 0 24204 1688 1392 S 0.0 0.2 0:00.10 systemd-logind
565 root 20 0 210232 4056 3220 S 0.0 0.4 0:00.96 rsyslogd
574 chrony 20 0 115640 1776 1312 S 0.0 0.2 0:00.73 chronyd
579 root 20 0 201256 1268 768 S 0.0 0.1 0:00.03 gssproxy
606 root 20 0 334228 28980 6876 S 0.0 2.9 0:00.60 firewalld
618 root 20 0 115256 928 672 S 0.0 0.1 0:00.24 ksmtuned
630 root 20 0 556424 9504 6948 S 0.0 0.9 0:00.16 NetworkManager
655 root 0 -20 0 0 0 S 0.0 0.0 0:00.06 kworker/0:1H
939 root 20 0 105996 4076 3096 S 0.0 0.4 0:00.02 sshd
942 root 20 0 562412 16576 5888 S 0.0 1.6 0:01.87 tuned
946 root 20 0 613152 16968 10764 S 0.0 1.7 0:00.24 libvirtd
955 root 20 0 126236 1668 1032 S 0.0 0.2 0:00.56 crond
964 root 20 0 110044 824 700 S 0.0 0.1 0:00.00 agetty
1112 root 20 0 89544 2184 1144 S 0.0 0.2 0:00.07 master
1119 postfix 20 0 89716 4016 3008 S 0.0 0.4 0:00.02 qmgr
1124 nobody 20 0 15604 896 696 S 0.0 0.1 0:00.00 dnsmasq
1126 root 20 0 15576 192 0 S 0.0 0.0 0:00.00 dnsmasq
1178 root 20 0 145700 5200 3924 S 0.0 0.5 0:00.32 sshd
1182 root 20 0 116324 3124 1788 S 0.0 0.3 0:00.08 bash
2442 postfix 20 0 89648 4000 2992 S 0.0 0.4 0:00.03 pickup
2596 root 20 0 0 0 0 S 0.0 0.0 0:00.96 kworker/0:0
2712 root 20 0 0 0 0 S 0.0 0.0 0:00.44 kworker/0:1
2803 root 20 0 0 0 0 S 0.0 0.0 0:00.14 kworker/0:2
2836 root 20 0 107904 608 516 S 0.0 0.1 0:00.00 sleep
2837 root 20 0 157584 2024 1480 R 0.0 0.2 0:00.00 top
[root@localhost ~]#
sar命令
Linux下系统运行状态统计工具,它将指定的操作系统状态计数器显示到标准输出设备。sar工具将对系统当前的状态进行取样,然后通过计算数据和比例来表达系统的当前运行状态。它的特点是可以连续对系统取样,获得大量的取样数据。取样数据和分析的结果都可以存入文件,使用它时消耗的系统资源很小。

yum install -y sysstat 安装
/var/log/sa 取样分析数据包存放目录

例:
网卡负载
[root@localhost ~]# sar -n DEV 1 5 实时统计网卡数据 ( 每1秒统计1次,共统计5次
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月05日 _x86_64_(1 CPU)
时间 网络接口设备 收发数据包数kb 收发字节数B 收发压缩数据包数 接收的多播数据包
22时41分48秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
22时41分49秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分49秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分49秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分49秒 ens33 1.00 1.00 0.06 0.20 0.00 0.00 0.00

22时41分49秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
22时41分50秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分50秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分50秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分50秒 ens33 1.01 1.01 0.06 0.59 0.00 0.00 0.00

22时41分50秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
22时41分51秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分51秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分51秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分51秒 ens33 1.01 1.01 0.06 0.59 0.00 0.00 0.00

22时41分51秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
22时41分52秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分52秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分52秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分52秒 ens33 1.00 1.00 0.06 0.59 0.00 0.00 0.00

22时41分52秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
22时41分53秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分53秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分53秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
22时41分53秒 ens33 1.01 1.01 0.06 0.59 0.00 0.00 0.00

平均时间: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 1.01 1.01 0.06 0.51 0.00 0.00 0.00
[root@localhost ~]# ls /var/log/sa 取样分析的数据文件存放目录,最多保存30天
sa05 sa06 sar05 默认以sa+日期做文件名, 其中sar*文件为明文可读文件
[root@localhost ~]# sar -n DEV -f /var/log/sa/sa05 查看网卡历史统计数据
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月05日 _x86_64_ (1 CPU)

00时40分01秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
00时50分02秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 ens33 1.71 1.13 0.23 0.50 0.00 0.00 0.00
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 1.71 1.13 0.23 0.50 0.00 0.00 0.00

11时00分23秒 LINUX RESTART

11时10分01秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
11时20分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
11时20分01秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
11时20分01秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
11时20分01秒 ens33 0.57 0.12 0.04 0.01 0.00 0.00 0.00
[root@localhost ~]# sar -n DEV 查看网卡数据
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月06日 _x86_64_ (1 CPU)

00时00分01秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
00时10分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时10分01秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时10分01秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时10分01秒 ens33 0.62 0.15 0.04 0.01 0.00 0.00 0.00
00时20分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时20分01秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时20分01秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时20分01秒 ens33 0.80 0.26 0.05 0.07 0.00 0.00 0.00
00时30分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时30分01秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时30分01秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时30分01秒 ens33 0.87 0.42 0.06 0.28 0.00 0.00 0.00
00时40分02秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时40分02秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时40分02秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时40分02秒 ens33 0.74 0.42 0.05 0.47 0.00 0.00 0.00
00时50分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分01秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分01秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分01秒 ens33 0.74 0.21 0.05 0.03 0.00 0.00 0.00
01时00分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01时00分01秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01时00分01秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
01时00分01秒 ens33 0.75 0.25 0.05 0.04 0.00 0.00 0.00
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 0.75 0.28 0.05 0.15 0.00 0.00 0.00
系统负载
[root@localhost ~]# sar -q 查看系统负载
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月06日 _x86_64_ (1 CPU)

00时00分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
00时10分01秒 1 137 0.00 0.01 0.05 0
00时20分01秒 2 137 0.00 0.01 0.05 0
00时30分01秒 1 137 0.00 0.01 0.05 0
平均时间: 1 137 0.00 0.01 0.05 0
[root@localhost ~]# sar -q 1 5 实时统计系统负载,每1秒统计1次,共统计5次
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月06日 _x86_64_ (1 CPU)

01时06分05秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
01时06分06秒 0 137 0.00 0.01 0.05 0
01时06分07秒 1 137 0.00 0.01 0.05 0
01时06分08秒 0 137 0.00 0.01 0.05 0
01时06分09秒 0 137 0.00 0.01 0.05 0
01时06分10秒 0 137 0.00 0.01 0.05 0
平均时间: 0 137 0.00 0.01 0.05 0
[root@localhost ~]#

[root@localhost ~]# sar -q -f /var/log/sa/sa05 查看系统负载历史统计数据
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月05日 _x86_64_ (1 CPU)

00时40分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
00时50分02秒 1 140 0.03 0.04 0.05 0
平均时间: 1 140 0.03 0.04 0.05 0

11时00分23秒 LINUX RESTART

11时10分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
11时20分01秒 1 140 0.00 0.01 0.04 0
11时30分01秒 1 138 0.00 0.01 0.04 0
11时40分01秒 1 137 0.00 0.01 0.04 0
11时50分01秒 1 137 0.00 0.01 0.04 0
12时00分01秒 1 137 0.00 0.01 0.04 0
12时10分02秒 1 137 0.00 0.01 0.04 0
12时20分01秒 1 137 0.00 0.01 0.04 0
12时30分01秒 1 136 0.01 0.05 0.05 0
12时40分01秒 1 136 0.00 0.01 0.05 0
12时50分01秒 1 137 0.00 0.01 0.05 0
13时00分01秒 1 137 0.00 0.01 0.05 0
13时10分01秒 1 136 0.00 0.01 0.05 0
13时20分01秒 1 136 0.00 0.01 0.05 0
13时30分01秒 1 137 0.00 0.01 0.05 0
13时40分01秒 1 137 0.00 0.01 0.05 0
13时50分01秒 1 137 0.00 0.01 0.05 0
平均时间: 1 137 0.00 0.01 0.05 0

15时10分51秒 LINUX RESTART

15时20分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
15时30分01秒 1 135 0.24 0.06 0.02 0
15时40分02秒 1 135 0.00 0.01 0.02 0
15时50分01秒 2 135 0.00 0.01 0.02 0
16时00分01秒 1 135 0.00 0.01 0.02 0
16时10分01秒 1 134 0.05 0.04 0.04 0
16时20分01秒 1 135 0.00 0.01 0.05 0
16时30分01秒 1 135 0.00 0.01 0.05 0
16时40分01秒 1 135 0.02 0.03 0.05 0
16时50分01秒 1 134 0.00 0.01 0.05 0
17时00分01秒 1 135 0.00 0.01 0.05 0
17时10分01秒 1 135 0.00 0.01 0.05 0
17时20分01秒 1 134 0.00 0.01 0.05 0
17时40分01秒 1 135 0.00 0.01 0.05 0
17时50分01秒 1 135 0.00 0.01 0.05 0
18时00分01秒 1 135 0.00 0.01 0.05 0
22时40分01秒 2 135 0.00 0.01 0.05 0
22时50分01秒 1 137 0.00 0.01 0.05 0
23时00分01秒 2 137 0.06 0.03 0.05 0
23时10分01秒 1 137 0.00 0.01 0.05 0

23时10分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
23时20分01秒 1 137 0.00 0.01 0.05 0
23时30分01秒 1 137 0.00 0.02 0.05 0
23时40分01秒 1 137 0.01 0.02 0.05 0
23时50分01秒 1 137 0.00 0.01 0.05 0
平均时间: 1 135 0.02 0.02 0.04 0
磁盘负载
[root@localhost ~]# sar -b 查看磁盘负载
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月06日 _x86_64_ (1 CPU)

00时00分01秒 tps rtps wtps bread/s bwrtn/s
00时10分01秒 0.13 0.01 0.12 0.16 1.56
00时20分01秒 0.09 0.00 0.09 0.00 1.06
00时30分01秒 0.12 0.00 0.12 0.00 1.34
00时40分02秒 0.10 0.00 0.10 0.00 1.26
平均时间: 0.11 0.00 0.11 0.04 1.30
[root@localhost ~]# sar -b -f /var/log/sa/sa05 查看磁盘负载历史统计数据
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月05日 _x86_64_ (1 CPU)

00时40分01秒 tps rtps wtps bread/s bwrtn/s
00时50分02秒 0.53 0.04 0.49 1.33 12.35
平均时间: 0.53 0.04 0.49 1.33 12.35

11时00分23秒 LINUX RESTART

11时10分01秒 tps rtps wtps bread/s bwrtn/s
11时20分01秒 0.09 0.00 0.09 0.05 1.00
11时30分01秒 1.09 0.63 0.46 17.06 11.67
11时40分01秒 0.07 0.00 0.07 0.00 0.84
11时50分01秒 0.09 0.00 0.09 0.11 1.11
12时00分01秒 0.07 0.00 0.07 0.00 0.66
12时10分02秒 0.12 0.00 0.12 0.00 1.50
12时20分01秒 0.03 0.00 0.03 0.00 0.36
12时30分01秒 0.09 0.00 0.09 0.00 0.97
12时40分01秒 0.09 0.00 0.09 0.00 0.95
12时50分01秒 0.04 0.00 0.04 0.00 0.41
13时00分01秒 0.08 0.00 0.08 0.00 0.89
13时10分01秒 0.10 0.00 0.10 0.00 1.11
13时20分01秒 0.04 0.01 0.04 0.11 0.39
13时30分01秒 0.09 0.00 0.08 0.01 0.96
13时40分01秒 0.07 0.00 0.07 0.00 0.76
13时50分01秒 0.06 0.00 0.06 0.00 0.57
平均时间: 0.14 0.04 0.10 1.08 1.51

15时10分51秒 LINUX RESTART

15时20分01秒 tps rtps wtps bread/s bwrtn/s
15时30分01秒 0.10 0.00 0.10 0.11 1.56
15时40分02秒 0.08 0.00 0.08 0.00 0.90
15时50分01秒 0.07 0.00 0.07 0.00 0.76
16时00分01秒 0.09 0.00 0.09 0.00 1.10
16时10分01秒 0.09 0.01 0.08 0.15 1.10
16时20分01秒 0.13 0.00 0.13 0.00 1.49
16时30分01秒 0.06 0.00 0.06 0.00 0.69
16时40分01秒 0.09 0.00 0.09 0.00 1.06
16时50分01秒 0.08 0.00 0.08 0.00 0.96
17时00分01秒 0.10 0.00 0.10 0.00 1.04
17时10分01秒 0.11 0.00 0.11 0.00 1.31
17时20分01秒 0.11 0.00 0.11 0.00 1.40
17时40分01秒 0.08 0.00 0.08 0.00 0.91
17时50分01秒 0.08 0.00 0.08 0.00 0.98
18时00分01秒 0.09 0.00 0.09 0.00 1.04
22时40分01秒 0.11 0.00 0.11 0.00 1.19
22时50分01秒 0.37 0.19 0.18 6.63 4.11
23时00分01秒 0.09 0.00 0.09 0.00 0.99
23时10分01秒 0.12 0.00 0.12 0.00 1.27
23时20分01秒 0.08 0.00 0.08 0.00 0.82
23时30分01秒 0.09 0.00 0.09 0.00 1.08
23时40分01秒 0.10 0.00 0.10 0.00 1.10
23时50分01秒 0.08 0.00 0.08 0.00 0.97
平均时间: 0.10 0.01 0.10 0.29 1.20
[root@localhost ~]# sar -b 1 5 实时统计磁盘负载,每1秒统计1次,共统计5次
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月06日 _x86_64_ (1 CPU)

00时42分45秒 tps rtps wtps bread/s bwrtn/s
00时42分46秒 0.00 0.00 0.00 0.00 0.00
00时42分47秒 0.00 0.00 0.00 0.00 0.00
00时42分48秒 0.00 0.00 0.00 0.00 0.00
00时42分49秒 0.00 0.00 0.00 0.00 0.00
00时42分50秒 0.00 0.00 0.00 0.00 0.00
平均时间: 0.00 0.00 0.00 0.00 0.00

查看系统资源的统计文件 ( 包含系统所有资源的历史统计数据【18种资源数据】 )
[root@localhost ~]# cat /var/log/sa/sa r 05 此文件为普通明文文件,可用命令查看
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018-05-05 _x86_64_ (1 CPU)

00时40分01秒 CPU %usr %nice %sys %iowait %steal %irq %soft %guest %gnice %idle
00时50分02秒 all 0.22 0.00 0.25 0.00 0.00 0.00 0.01 0.00 0.00 99.52
00时50分02秒 0 0.22 0.00 0.25 0.00 0.00 0.00 0.01 0.00 0.00 99.52
平均时间: all 0.22 0.00 0.25 0.00 0.00 0.00 0.01 0.00 0.00 99.52
平均时间: 0 0.22 0.00 0.25 0.00 0.00 0.00 0.01 0.00 0.00 99.52

00时40分01秒 proc/s cswch/s
00时50分02秒 0.15 85.54
平均时间: 0.15 85.54

00时40分01秒 pswpin/s pswpout/s
00时50分02秒 0.00 0.00
平均时间: 0.00 0.00

00时40分01秒 pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff
00时50分02秒 0.66 6.17 107.59 0.00 125.12 0.00 0.00 0.00 0.00
平均时间: 0.66 6.17 107.59 0.00 125.12 0.00 0.00 0.00 0.00

00时40分01秒 tps rtps wtps bread/s bwrtn/s
00时50分02秒 0.53 0.04 0.49 1.33 12.35
平均时间: 0.53 0.04 0.49 1.33 12.35

00时40分01秒 frmpg/s bufpg/s campg/s
00时50分02秒 -2.21 0.00 0.15
平均时间: -2.21 0.00 0.15

00时40分01秒 kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty
00时50分02秒 484884 523268 51.90 2084 302236 571484 18.40 243556 145192 4
平均时间: 484884 523268 51.90 2084 302236 571484 18.40 243556 145192 4

00时40分01秒 kbswpfree kbswpused %swpused kbswpcad %swpcad
00时50分02秒 2097148 0 0.00 0 0.00
平均时间: 2097148 0 0.00 0 0.00

00时40分01秒 kbhugfree kbhugused %hugused
00时50分02秒 0 0 0.00
平均时间: 0 0 0.00

00时40分01秒 dentunusd file-nr inode-nr pty-nr
00时50分02秒 58753 1536 23749 1
平均时间: 58753 1536 23749 1

00时40分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
00时50分02秒 1 140 0.03 0.04 0.05 0
平均时间: 1 140 0.03 0.04 0.05 0

00时40分01秒 TTY rcvin/s xmtin/s framerr/s prtyerr/s brk/s ovrun/s
00时50分02秒 0 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 1 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: 0 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: 1 0.00 0.00 0.00 0.00 0.00 0.00

00时40分01秒 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
00时50分02秒 dev8-0 0.53 1.33 12.35 25.90 0.00 0.95 0.26 0.01
平均时间: dev8-0 0.53 1.33 12.35 25.90 0.00 0.95 0.26 0.01

00时40分01秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
00时50分02秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 ens33 1.71 1.13 0.23 0.50 0.00 0.00 0.00
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 1.71 1.13 0.23 0.50 0.00 0.00 0.00

00时40分01秒 IFACE rxerr/s txerr/s coll/s rxdrop/s txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s
00时50分02秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时50分02秒 ens33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: virbr0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

00时40分01秒 call/s retrans/s read/s write/s access/s getatt/s
00时50分02秒 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: 0.00 0.00 0.00 0.00 0.00 0.00

00时40分01秒 scall/s badcall/s packet/s udp/s tcp/s hit/s miss/s sread/s swrite/s saccess/s sgetatt/s
00时50分02秒 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

00时40分01秒 totsck tcpsck udpsck rawsck ip-frag tcp-tw
00时50分02秒 431 5 5 0 0 0
平均时间: 431 5 5 0 0 0

11时00分23秒 LINUX RESTART
以下为分时统计,在这里做忽略
~~~~~~~
~~~~~~~
~~~~~~~

nload命令
在命令行界面监控网络吞吐量,实时监控网络流量和带宽使用的控制台应用程序,使用两个图表可视化地展示接收和发送的流量,并提供诸如数据交换总量、最小/最大网络带宽使用量等附加信息。

yum install -y epel-release 安装扩展库
yum install -y nload 安装nload
← → 或者 Enter/Tab 键在设备间切换。
按 F2 显示选项窗口。
按 F5 将当前设置保存到用户配置文件。
按 F6 从配置文件重新加载设置。
按 q 或者 Ctrl+C 退出 nload。
用法
nload -u h|H|b|B|k|K|m|M|g|G
nload -U h|H|b|B|k|K|m|M|g|G
nload -u h
nload -u G
nload -U G
  • 小写选项 -u: h 意为自动格式化为人类易读的单位,b 意为 Bit/s,k 意为 kBit/s,m 意为 MBit/s,g 意为 GBit/s。大写字母意为使用 Byte 替代 Bit。默认为 k。
  • 大写选项 -U 与小写选项 -u 非常相似,不同之处在于它展示的是数据量,比如 Bit, kByte, GBit 等等。(没有 "/s")。默认值是 M。

例:
[root@localhost ~]# nload 查看网卡负载
curr当前负载,avg平均负载,min最小负载,max最大负载,Ttl总数据量

猜你喜欢

转载自blog.csdn.net/langyue919/article/details/80202388