w命令:查看cpu负载状况mysql
[root@lgs-01 ~]# w 11:20:20 up 1 min, 1 user, load average: 0.27, 0.18, 0.07 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.87.1 11:20 3.00s 0.09s 0.01s w
关注第一行,load average:表明每1分钟、每5分钟、每10分钟时间段内使用cpu的活动进程个数的平均值。linux
通常与cpu逻辑内核数进行比较,在/proc/cpuinfo 内查看cpu内核数(processor的值),如3为4核。ios
负载值不大于cpu内核数 便可。意思是cpu可以处理进程的请求,不用排队等待。通常多关注1分钟的平均值。git
第一行下面的是用户登陆信息,TTY列:pts为网络登陆,tty为本地登陆。IDEL为cpu空闲时间。sql
w命令的第一行与uptime命令输出结果同样。bash
[root@lgs-01 ~]# w 11:27:17 up 8 min, 1 user, load average: 0.00, 0.05, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.87.1 11:20 5.00s 0.10s 0.01s w [root@lgs-01 ~]# uptime 11:27:19 up 8 min, 1 user, load average: 0.00, 0.05, 0.05
vmstat命令:查看进程、内存、swap、IO、cpu等系统资源的整体状况,一帮可以判断系统瓶颈在哪里网络
vmstat 1:表示1秒钟显示一次,用ctrl+C结束架构
[root@lgs-01 ~]# 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 1 0 0 1079396 2076 204700 0 0 130 9 104 109 0 1 99 0 0 0 0 0 1079380 2076 204732 0 0 0 0 108 100 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 89 83 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 105 97 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 87 81 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 25 133 116 0 1 99 0 0 0 0 0 1079380 2076 204732 0 0 0 0 134 128 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 158 136 0 0 100 0 0 ^C
vmstat 1 8:表示1秒显示一次,显示8次后自动结束ssh
[root@lgs-01 ~]# vmstat 1 8 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 0 1079396 2076 204732 0 0 122 9 101 106 0 1 99 0 0 0 0 0 1079380 2076 204732 0 0 0 0 98 93 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 119 100 0 1 99 0 0 0 0 0 1079380 2076 204732 0 0 0 0 93 88 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 92 81 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 113 103 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 103 91 0 0 100 0 0 0 0 0 1079380 2076 204732 0 0 0 0 90 88 0 0 100 0 0 [root@lgs-01 ~]#
重点关注的信息: r:run,处于run状态的进程数(正在使用cpu、或者在排队等待cpu资源的都算run状态)ide
b:block,被cpu之外的资源堵住的进程的数量(如网络、IO、磁盘等),即在等待其余资源处理的状态
swpd:数值不断变化一会多一会少就要重点关注内存是否不够了,说明swap区与内存在频繁交换数据。
si:多少kb数据进入内存中(从swap区),之内存为参照物
so:多少kb数据从内存出来进入swap区,之内存为参照物
bi:从磁盘出来 到内存的数据量。 读
bo:从内存写入到磁盘的数据量。写
us:用户级别的服务、进程占用cpu的百分比,长期大于50表示系统资源比较紧张
sy:系统级别的服务、进程占用cpu百分比。
id:idel 空闲的cpu资源百分比。
us+sy+id=100
wa:wait 与b相似,等待cpu的进程百分比。数值大表示cpu资源不够分配用。
top命令:查看具体进程使用系统资源(cpu、内存等)的状况,3秒动态刷新显示一次
[root@lgs-01 ~]# top top - 11:47:44 up 29 min, 1 user, load average: 0.00, 0.01, 0.05 Tasks: 98 total, 2 running, 96 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 1867048 total, 1078588 free, 581368 used, 207092 buff/cache KiB Swap: 4194300 total, 4194300 free, 0 used. 1099564 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 128164 6828 4064 S 0.0 0.4 0:01.06 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.24 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:00.11 kworker/u256:0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.06 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:01.67 rcu_sched 10 root rt 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0 11 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/1 12 root rt 0 0 0 0 S 0.0 0.0 0:00.01 migration/1 13 root 20 0 0 0 0 S 0.0 0.0 0:00.07 ksoftirqd/1 15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H
runing:运行状态的进程数
sleeping:在休息等会在运行的进程数
zombie:僵尸进程数,主进程意外死掉了,留下子进程没人管就变成僵尸进程了。
%cpu(s):us+sy+id=100% 。 st:被偷走的cpu,如虚拟化的子机器。
关注us用户服务,60%以上都要当心。
这里的cpu资源使用百分比与w命令中的cpu负载不一样概念。
通常us大,负载确定大。反过来则不必定。
top 默认按%cpu排序,由高到低。
按M:按%Mem排序。
按P:按%cpu排序。
按1:%cpu(s) 变成%cpu0,表示单独查看某个内核的使用状况
按q:退出。
top -c:看进程运行的具体全局命令。
[root@lgs-01 ~]# top -c top - 11:56:23 up 37 min, 1 user, load average: 0.00, 0.01, 0.05 Tasks: 97 total, 1 running, 96 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 1867048 total, 1078540 free, 581352 used, 207156 buff/cache KiB Swap: 4194300 total, 4194300 free, 0 used. 1099548 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 9 root 20 0 0 0 0 S 0.3 0.0 0:01.90 [rcu_sched] 1 root 20 0 128164 6828 4064 S 0.0 0.4 0:01.06 /usr/lib/systemd/systemd --switched-root --system --deserialize 21 2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 [kthreadd] 3 root 20 0 0 0 0 S 0.0 0.0 0:00.24 [ksoftirqd/0] 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:0H
top -bn1:静态显示所有进程信息,在脚本中经常使用。
[root@lgs-01 ~]# top -bn1 top - 11:57:15 up 38 min, 1 user, load average: 0.00, 0.01, 0.05 Tasks: 97 total, 2 running, 95 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 : 1867048 total, 1078788 free, 581104 used, 207156 buff/cache KiB Swap: 4194300 total, 4194300 free, 0 used. 1099796 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 128164 6828 4064 S 0.0 0.4 0:01.06 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.24 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:00.13 kworker/u256:0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.08 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:01.92 rcu_sched 10 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0 11 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/1 12 root rt 0 0 0 0 S 0.0 0.0 0:00.01 migration/1 13 root 20 0 0 0 0 S 0.0 0.0 0:00.09 ksoftirqd/1 15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H 17 root 20 0 0 0 0 S 0.0 0.0 0:00.13 kdevtmpfs 18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns 19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd 20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd 22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd 24 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:02.61 kworker/0:1 30 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0 31 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd 32 root 39 19 0 0 0 S 0.0 0.0 0:00.39 khugepaged 33 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto 41 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld 43 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kmpath_rdacd 44 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused 46 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ipv6_addrconf 66 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 deferwq 98 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kauditd 237 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff 238 root 20 0 0 0 0 S 0.0 0.0 0:00.01 scsi_eh_0 239 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_0 240 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1 241 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_1 243 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 mpt_poll_0 244 root 20 0 0 0 0 S 0.0 0.0 0:00.03 kworker/u256:3 245 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 mpt/0 253 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_2 254 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_2 256 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ttm_swap 286 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset 287 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfsalloc 288 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs_mru_cache 289 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-buf/sda3 290 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-data/sda3 291 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-conv/sda3 292 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-cil/sda3 293 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-reclaim/sda 294 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-log/sda3 295 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-eofblocks/s 296 root 20 0 0 0 0 S 0.0 0.0 0:00.20 xfsaild/sda3 364 root 20 0 36832 2804 2488 S 0.0 0.2 0:00.19 systemd-journal 382 root 20 0 342552 5520 2600 S 0.0 0.3 0:00.00 lvmetad 384 root 20 0 48004 5956 2816 S 0.0 0.3 0:00.43 systemd-udevd 410 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 nfit 495 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-buf/sda1 496 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-data/sda1 497 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-conv/sda1 498 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-cil/sda1 499 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-reclaim/sda 500 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-log/sda1 501 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 xfs-eofblocks/s 503 root 20 0 0 0 0 S 0.0 0.0 0:00.00 xfsaild/sda1 506 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kdmflush 507 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset 534 root 16 -4 55452 892 484 S 0.0 0.0 0:00.00 auditd 557 polkitd 20 0 535088 11128 4876 S 0.0 0.6 0:00.38 polkitd 558 root 20 0 99760 6208 4484 S 0.0 0.3 0:00.35 VGAuthService 559 root 20 0 281924 8148 3340 S 0.0 0.4 0:00.37 rsyslogd 566 root 20 0 305296 6312 4932 S 0.0 0.3 0:03.58 vmtoolsd 568 root 20 0 21620 1284 976 S 0.0 0.1 0:01.12 irqbalance 569 root 20 0 24204 1668 1372 S 0.0 0.1 0:00.07 systemd-logind 570 dbus 20 0 32768 1836 1412 S 0.0 0.1 0:00.36 dbus-daemon 574 chrony 20 0 115640 1776 1312 S 0.0 0.1 0:01.05 chronyd 585 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:1H 591 root 20 0 126232 1644 1024 S 0.0 0.1 0:00.41 crond 609 root 20 0 334236 28980 6888 S 0.0 1.6 0:01.14 firewalld 611 root 20 0 472116 9032 6768 S 0.0 0.5 0:00.29 NetworkManager 667 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:1H 916 root 20 0 105996 4076 3100 S 0.0 0.2 0:00.03 sshd 917 root 20 0 562392 18620 5904 S 0.0 1.0 0:00.67 tuned 956 root 20 0 115388 1700 1392 S 0.0 0.1 0:00.02 mysqld_safe 1193 mysql 20 0 1300776 452356 5856 S 0.0 24.2 0:06.51 mysqld 1257 root 20 0 89544 2088 1072 S 0.0 0.1 0:00.17 master 1258 postfix 20 0 89648 4000 2996 S 0.0 0.2 0:00.12 pickup 1259 postfix 20 0 89716 4032 3020 S 0.0 0.2 0:00.01 qmgr 1271 root 20 0 110044 820 696 S 0.0 0.0 0:00.01 agetty 1376 root 20 0 147844 5376 4072 S 0.0 0.3 0:00.84 sshd 1379 root 20 0 115524 2156 1664 S 0.0 0.1 0:00.15 bash 1408 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/1:2 1413 root 20 0 0 0 0 S 0.0 0.0 0:00.18 kworker/1:0 1414 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:2 1415 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/0:0 1417 root 20 0 157584 2016 1472 R 0.0 0.1 0:00.00 top
RES列:表示已用的内存数,单位kb
PID:进程id,可使用kill pdi杀死进程。
1418 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/1:1 1419 root 20 0 157684 2144 1508 T 0.0 0.1 0:00.01 top 1420 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/0:2 [root@lgs-01 ~]# kill 1419
sar命令:监控系统的状态,用来查看网卡流量比较多。
sar:被称为linux系统的瑞士军刀,功能丰富,安装sysstat包才能使用该命令。
[root@lgs-01 ~]# sar -bash: sar: 未找到命令 [root@lgs-01 ~]# yum install -y sysstat 已加载插件:fastestmirror Determining fastest mirrors 正在解决依赖关系 --> 正在检查事务 ---> 软件包 sysstat.x86_64.0.10.1.5-12.el7 将被 安装 --> 正在处理依赖关系 libsensors.so.4()(64bit),它被软件包 sysstat-10.1.5-12.el7.x86_64 须要 --> 正在检查事务 ---> 软件包 lm_sensors-libs.x86_64.0.3.4.0-4.20160601gitf9185e5.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 =================================================================================================================================================== Package 架构 版本 源 大小 =================================================================================================================================================== 正在安装: sysstat x86_64 10.1.5-12.el7 base 310 k 为依赖而安装: lm_sensors-libs x86_64 3.4.0-4.20160601gitf9185e5.el7 base 41 k 事务概要 =================================================================================================================================================== 安装 1 软件包 (+1 依赖软件包) 总下载量:351 k 安装大小:1.2 M Downloading packages: (1/2): lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64.rpm | 41 kB 00:00:00 (2/2): sysstat-10.1.5-12.el7.x86_64.rpm | 310 kB 00:00:00 --------------------------------------------------------------------------------------------------------------------------------------------------- 总计 437 kB/s | 351 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64 1/2 正在安装 : sysstat-10.1.5-12.el7.x86_64 2/2 验证中 : sysstat-10.1.5-12.el7.x86_64 1/2 验证中 : lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64 2/2 已安装: sysstat.x86_64 0:10.1.5-12.el7 做为依赖被安装: lm_sensors-libs.x86_64 0:3.4.0-4.20160601gitf9185e5.el7 完毕!
sar命令:刚安装好,不加参数运行报错,由于不加参数会调用系统保留的sar历史文件。
[root@lgs-01 ~]# sar 没法打开 /var/log/sa/sa06: 没有那个文件或目录 [root@lgs-01 ~]# ls -l /var/log/sa/ 总用量 0
这个文件是每隔10分钟才会生成的。
sar -n DEV 1 8:查看网卡流量
[root@lgs-01 ~]# sar -n DEV 1 8 Linux 3.10.0-693.el7.x86_64 (lgs-01) 2018年05月06日 _x86_64_ (2 CPU) 12时09分08秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分09秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分09秒 ens33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分09秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分10秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分10秒 ens33 1.00 1.00 0.06 0.40 0.00 0.00 0.00 12时09分10秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分11秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分11秒 ens33 3.00 1.00 0.18 0.40 0.00 0.00 0.00 12时09分11秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分12秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分12秒 ens33 2.00 1.00 0.12 0.40 0.00 0.00 0.00 12时09分12秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分13秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分13秒 ens33 1.00 1.00 0.06 0.40 0.00 0.00 0.00 12时09分13秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分14秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分14秒 ens33 3.96 1.98 0.31 0.45 0.00 0.00 0.00 12时09分14秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分15秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分15秒 ens33 2.00 1.00 0.12 0.40 0.00 0.00 0.00 12时09分15秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12时09分16秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12时09分16秒 ens33 2.00 2.00 0.19 0.46 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 平均时间: ens33 1.87 1.12 0.13 0.36 0.00 0.00 0.00 [root@lgs-01 ~]#
通常关注:rx pck/s 、tx pck/s、rx kb/s、tx kb/s
rx pck/s:接收数据包个数, 1秒多少个。通常几千个算正常,上万就要当心为何了,可能被攻击了。
tx pck/s:发生数据包个数,1秒多少个
rx kb/s:接收数据量,1秒几kb
tx kb/s:发送数据量,1秒几kb
若是接收数据包不少,网络会堵塞,网站就不能正常访问。
带宽跑满也是很危险的(每秒的数据量很大)
rxcmp/s txcmp/s rxmcst/s:压缩数据包、多播数据包。这三个不用关注,通常都是0.00
sar -q 1 5:系统负载,与w同样
[root@lgs-01 ~]# sar -q 1 5 Linux 3.10.0-693.el7.x86_64 (lgs-01) 2018年05月06日 _x86_64_ (2 CPU) 12时19分02秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked 12时19分03秒 1 136 0.00 0.01 0.05 0 12时19分04秒 0 136 0.00 0.01 0.05 0 12时19分05秒 1 136 0.00 0.01 0.05 0 12时19分06秒 1 136 0.00 0.01 0.05 0 12时19分07秒 0 136 0.00 0.01 0.05 0 平均时间: 1 136 0.00 0.01 0.05 0
sar -b 1 5:查看磁盘的读写状况
[root@lgs-01 ~]# sar -b 1 5 Linux 3.10.0-693.el7.x86_64 (lgs-01) 2018年05月06日 _x86_64_ (2 CPU) 12时19分46秒 tps rtps wtps bread/s bwrtn/s 12时19分47秒 0.00 0.00 0.00 0.00 0.00 12时19分48秒 0.00 0.00 0.00 0.00 0.00 12时19分49秒 0.00 0.00 0.00 0.00 0.00 12时19分50秒 0.00 0.00 0.00 0.00 0.00 12时19分51秒 0.00 0.00 0.00 0.00 0.00 平均时间: 0.00 0.00 0.00 0.00 0.00
/var/log/sa/sa06 :二进制文件,不能cat查看。
/var/log/sa/sar06: 能够用cat查看内容。
nload命令:查看网卡流量,动态显示
[root@lgs-01 ~]# nload Device ens33 [192.168.87.130] (1/2): =================================================================================================================================================== Incoming: Curr: 936.00 Bit/s Avg: 1.22 kBit/s Min: 936.00 Bit/s Max: 1.99 kBit/s Ttl: 19.17 MByte Outgoing: Curr: 8.99 kBit/s Avg: 8.97 kBit/s Min: 4.26 kBit/s Max: 9.52 kBit/s Ttl: 1.79 MByte
按 ->:查看第二个网卡
Device lo [127.0.0.1] (2/2): =================================================================================================================================================== Incoming: Curr: 0.00 Bit/s Avg: 0.00 Bit/s Min: 0.00 Bit/s Max: 0.00 Bit/s Ttl: 6.09 kByte Outgoing: Curr: 0.00 Bit/s Avg: 0.00 Bit/s Min: 0.00 Bit/s Max: 0.00 Bit/s Ttl: 6.09 kByte
按q:退出。
通常看出去的带宽,一直处于满的状态就要警戒
若是进来的流量很大,就要查看是否有攻击了。