w uptime vmstat top sar nload系统监控

查看系统基本负载

w命令

[root@izky8mg4viw1laz etc]# w
 12:06:54//当前时间 up 6 days, 23:42//系统运行时间,  2 users,//系统登录用户  load average: 0.05, 0.05, 0.05  //平均负载,:单位时间段内cpu的活动进程数,0.08代表是1分钟内的平均负载值,0.03是5分钟内的平均负载值,0.05是15分钟内的平均负载值;值越大,代表服务器的压力越大,一般情况下,这个值只要不超过服务器的cpu数量就没关系
USER    TTY     FROM     LOGIN@   IDLE   JCPU   PCPU   WHAT  
登录的用户  登录终端  远程主机名  登录时间   空闲了多少时间   该终端连接所有进程所占用的时间    当前进程所占用时间  当前正在执行的命令
root     pts/0    117.136.104.173  10:02    2:01m  0.01s  0.01s -bash 
root     pts/1    117.136.104.173  12:02    6.00s  0.00s  0.00s w
[root@izky8mg4viw1laz etc]#

名称含义
12:06:54时间
up 6 days, 23:42系统运行时间
2 users系统登录的用户数量
load average: 0.08, 0.03, 0.05平均负载:单位时间段内cpu的活动进程数,0.08代表是1分钟内的平均负载值,0.03是5分钟内的平均负载值,0.05是15分钟内的平均负载值;值越大,代表服务器的压力越大,一般情况下,这个值只要不超过服务器的cpu数量就没关系
USER登录的用户
TTY登录终端
FROM远程主机名
LOGIN@登录时间
IDLE空闲了多长时间
JCPU和该终端连接所有进程所占用的时间
PCPU当前进程所占用时间
WHAT当前正在执行的命令

扩展:

uptime命令

uptime命令的结果是w命令的第一行

[root@izky8mg4viw1laz etc]# uptime
 12:25:02 up 7 days, 1 min,  1 user,  load average: 0.00, 0.01, 0.05

vmstat 命令

命令w可以查看系统的负载信息,但是无法判断系统具体是哪儿有压力,所以就用到了vmstat命令,vmstat命令显示的结果主要有6部分:procs、memory、swap、io、system、cpu。具体显示结果如下:

[root@izky8mg4viw1laz etc]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0 526324 142404 628384    0    0     1     3   61   24  1  0 99  0  0
[root@izky8mg4viw1laz etc]#

注:常关注r、b和wa这三列。如果磁盘io压力很大,bi和bo这两列的数值会很高,另外,当bi和bo两列的数值比较高并且不断变化,说明内存不够了,内存中的数据频繁交换到交换分区中,这往往对系统性能有很大的影响。

## 通常使用如下形式查看系统状态 ##
[root@linux-01 ceshi]# vmstat 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
 1  0      0 1514132   2200 192952    0    0     0     0   23   36  0  0 100  0  0
 0  0      0 1514132   2200 192952    0    0     0     0   23   35  0  0 100  0  0
 1  0      0 1514132   2200 192952    0    0     0     0   24   34  0  0 100  0  0
 0  0      0 1514132   2200 192952    0    0     0     0   23   37  0  0 100  0  0
 1  0      0 1514132   2200 192952    0    0     0     0   28   37  0  0 100  0  0

vmstat 1 5 表示vmstat 每隔1秒显示一次,共输出5次。

类型项目含义
procs显示进程的相关信息rrun:表示运行或等待cpu时间片的进程数。
bblock:表示等待资源的进程数,这个资源指的是I/O、内存等
memory显示内存的相关信息swpd表示切换到交换分区中的内存数量,单位是KB。
free表示单前空闲的内存数量,单位是KB。
buff表示(即将写入磁盘的)缓存大小,单位是KB。
cache表示(从磁盘中读取的)缓存大小,单位是KB。
swap显示内存的交换情况si表示由交换分区写入内存的数据量,单位是KB。
so表示由内存写入交换分区的数据量,单位是KB。
io显示硬盘的使用情况bi表示从块设备读取数据的量(读磁盘),单位是KB。
bo表示从块设备写入数据的量(写磁盘),单位是KB。
system显示采集间隔内发生的中断次数in表示在某一时间间隔内观测到的每秒设备的中断次数
cs表示每秒产生的上下文切换次数
cpu显示cpu的使用状态us显示用户下所花费cpu的时间百分比
sy显示系统花费cpu的时间百分比
id表示cpu处理空闲状态的百分比
wa表示I/O等待所占用cpu的时间百分比
st表示被偷走的cpu所占百分比(一般为0,不用关注)

查看CPU相关信息

方法一:
使用cat命令查看/proc/cpuinfo
processor代表本机的cpu核数,如果是2,代表是4核cpu。physical id 是查看本机有几颗物理cpu

[root@izky8mg4viw1laz etc]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 79
model name      : Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
stepping        : 1
microcode       : 0x1
cpu MHz         : 2499.994
cache size      : 40960 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt
bogomips        : 4999.98
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

方法二:使用lscpu查看cpu信息。

## lscpu 也可以查看cpu信息 ##
[root@linux-01 ceshi]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
座:                 1
NUMA 节点:         1
厂商 ID:           GenuineIntel
CPU 系列:          6
型号:              61
型号名称:        Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
步进:              4
CPU MHz:             2294.709
BogoMIPS:            4589.41
超管理器厂商:  VMware
虚拟化类型:     完全
L1d 缓存:          32K
L1i 缓存:          32K
L2 缓存:           256K
L3 缓存:           3072K
NUMA 节点0 CPU:    0
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt arat
[root@linux-01 ceshi]# 


top命令

显示系统进程所占用系统资源

命令w可以查看系统的负载信息,vmstat可以查看系统的信息,如果查看系统某个进程占用cpu率很高,这就涉及到top命令,top命令可以显示出当前系统的进程使用cpu的情况,具体如下。

[root@linux-01 ceshi]# top
top - 02:26:23 up 11 days, 57 min,  2 users,  load average: 0.02, 0.03, 0.05
Tasks: 100 total,   1 running,  99 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1864248 total,  1513388 free,   155220 used,   195640 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  1512100 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                             
  6321 root      20   0  227204   6464   5104 S  0.7  0.3  63:01.43 vmtoolsd                                                            
 17415 root      20   0       0      0      0 S  0.7  0.0   0:38.05 kworker/0:3                                                         
     1 root      20   0  128004   6548   4136 S  0.0  0.4   0:09.28 systemd                                                             
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.11 kthreadd                                                            
     3 root      20   0       0      0      0 S  0.0  0.0   0:45.82 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:35.09 rcu_sched                                                           
    10 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 lru-add-drain                                                       
    11 root      rt   0       0      0      0 S  0.0  0.0   0:20.79 watchdog/0                                                          
    13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs                                                           
    14 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns                                                               
    15 root      20   0       0      0      0 S  0.0  0.0   0:00.58 khungtaskd                                                          
    16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback                                                           
    17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrityd                                                         
    18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset                                                              
    19 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset                                                              
    20 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset                                                              
    21 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kblockd                                                             
    22 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 md          

top命令的第一行和w命令的第一行所显示的内容一样,top命令用于动态监控进程所占用的系统资源,每隔3秒刷新一次。上面top打印出了很多信息,我们需要重点关注的是%CPU 、%MEM 和COMMAND这几项,RES这一项是进程占用系统内存的大小,%MEM为使用内存的百分比。在top状态下,按“M”可以按照内存使用大小排序,按“1”可以列出所有核cpu的使用情况,按“q”可以退出top。

## top -c 可以吧进程的路径显示出来 ##
[readonly@wxbManager ~]$ top -c
top - 20:07:48 up 526 days, 23:35,  1 user,  load average: 0.02, 0.01, 0.00
Tasks: 112 total,   1 running, 111 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  0.5%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   8189864k total,  6244516k used,  1945348k free,   384744k buffers
Swap:        0k total,        0k used,        0k free,  2419092k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 9273 root      20   0 79108 2128 1220 S  0.3  0.0 132:26.23 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
28986 10beiMan  20   0 6888m 2.8g  15m S  0.3 36.2 411:52.18 /usr/java/jdk1.8.0_181/bin/java -Djava.util.logging.config.file=/home/10beiManager/tomcat/conf/logging.properties -Djava.util.l
    1 root      20   0 19340 1116  816 S  0.0  0.0   0:47.48 /sbin/init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.01 [kthreadd]
    3 root      RT   0     0    0    0 S  0.0  0.0   2:06.37 [migration/0]
    4 root      20   0     0    0    0 S  0.0  0.0   4:04.32 [ksoftirqd/0]
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 [stopper/0]
    6 root      RT   0     0    0    0 S  0.0  0.0   0:58.78 [watchdog/0]
    7 root      RT   0     0    0    0 S  0.0  0.0   2:58.54 [migration/1]
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 [stopper/1]
    9 root      20   0     0    0    0 S  0.0  0.0   5:45.23 [ksoftirqd/1]
   10 root      RT   0     0    0    0 S  0.0  0.0   0:52.23 [watchdog/1]
   11 root      20   0     0    0    0 S  0.0  0.0  30:35.79 [events/0]
   12 root      20   0     0    0    0 S  0.0  0.0 139:35.07 [events/1]
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [events/0]
   14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [events/1]
   15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [events_long/0]
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [events_long/1]
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [events_power_ef]
   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [events_power_ef]
   19 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [cgroup]
   20 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [khelper]
   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [netns]
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [async/mgr]
   23 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [pm]
   24 root      20   0     0    0    0 S  0.0  0.0   0:00.00 [xenwatch]

## top -bn1 可以吧进程信息一次性输出来,并非动态信息,多用于脚本 ##
[root@linux-01 ceshi]# top -bn1
top - 02:37:01 up 11 days,  1:08,  2 users,  load average: 0.00, 0.01, 0.05
Tasks: 100 total,   1 running,  99 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 :  1864248 total,  1513364 free,   155252 used,   195632 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  1512080 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
     1 root      20   0  128004   6548   4136 S  0.0  0.4   0:09.28 systemd
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.11 kthreadd
     3 root      20   0       0      0      0 S  0.0  0.0   0:45.86 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:35.12 rcu_sched
    10 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 lru-add-drain
    11 root      rt   0       0      0      0 S  0.0  0.0   0:20.80 watchdog/0
    13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs
    14 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns
    15 root      20   0       0      0      0 S  0.0  0.0   0:00.58 khungtaskd
    16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback
    17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrityd
    18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
    19 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
    20 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
    21 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kblockd
    22 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 md
    23 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 edac-poller
    24 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 watchdogd
    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:07.99 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 kaluad
    45 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kpsmoused
    47 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
    91 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kauditd
  1644 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 nfit
  1666 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 mpt_poll_0
  1670 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 mpt/0
  1671 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 ata_sff
  1716 root      20   0       0      0      0 S  0.0  0.0   0:00.00 scsi_eh_0
  1722 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 scsi_tmf_0
  1747 root      20   0       0      0      0 S  0.0  0.0   0:00.01 scsi_eh_1
  1748 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 scsi_tmf_1
  1750 root      20   0       0      0      0 S  0.0  0.0   0:00.00 scsi_eh_2
  1757 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 scsi_tmf_2
  1899 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 ttm_swap
  1901 root     -51   0       0      0      0 S  0.0  0.0   0:00.00 irq/16-vmwgfx
  2900 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
  2905 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfsalloc
  2910 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs_mru_cache
  2913 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-buf/sda3
  2916 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-data/sda3
  2919 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-conv/sda3
  2920 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-cil/sda3
  2921 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-reclaim/sda
  2922 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-log/sda3
  2923 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-eofblocks/s
  2924 root      20   0       0      0      0 S  0.0  0.0   0:14.38 xfsaild/sda3
  2925 root       0 -20       0      0      0 S  0.0  0.0   0:08.96 kworker/0:1H
  2992 root      20   0   39076   4472   4144 S  0.0  0.2   0:02.26 systemd-journal
  3009 root      20   0  340348   8048   2620 S  0.0  0.4   0:00.01 lvmetad
  3027 root      20   0   48208   5700   2864 S  0.0  0.3   0:00.73 systemd-udevd
  4848 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kdmflush
  4854 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
  4861 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-buf/sda1
  4863 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-data/sda1
  4867 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-conv/sda1
  4868 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-cil/sda1
  4873 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-reclaim/sda
  4878 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-log/sda1
  4879 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 xfs-eofblocks/s
  4882 root      20   0       0      0      0 S  0.0  0.0   0:00.00 xfsaild/sda1
  4966 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/u257:0
  4973 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 hci0
  4975 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 hci0
  4980 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/u257:2
  6161 root      16  -4   62044   1080    496 S  0.0  0.1   0:02.77 auditd
  6309 root      20   0   26376   1752   1440 S  0.0  0.1   0:02.92 systemd-logind
  6312 polkitd   20   0  613000  11908   4920 S  0.0  0.6   0:00.48 polkitd
  6319 root      20   0   99572   6112   4504 S  0.0  0.3   0:00.07 VGAuthService
  6321 root      20   0  227204   6464   5104 S  0.0  0.3  63:03.15 vmtoolsd
  6325 dbus      20   0   66460   2584   1896 S  0.0  0.1   0:02.08 dbus-daemon
  6417 root      20   0  126280   1692   1068 S  0.0  0.1   0:03.74 crond
  6456 root      20   0  110092    860    728 S  0.0  0.0   0:00.01 agetty
  6465 root      20   0  358512  29324   7184 S  0.0  1.6   0:01.21 firewalld
  6519 root      20   0  473892   8616   6648 S  0.0  0.5   0:30.74 NetworkManager
  6965 root      20   0  573820  17112   6036 S  0.0  0.9   3:29.09 tuned
  6967 root      20   0  112756   4352   3328 S  0.0  0.2   0:00.07 sshd
  6968 root      20   0  220612   7824   4444 S  0.0  0.4   2:05.77 rsyslogd
  7260 root      20   0   89544   2180   1148 S  0.0  0.1   0:07.78 master
  7266 postfix   20   0   89716   4092   3088 S  0.0  0.2   0:01.19 qmgr
 12649 root      20   0  158760   5588   4240 S  0.0  0.3   0:11.17 sshd
 12653 root      20   0  116212   3088   1844 S  0.0  0.2   0:04.20 bash
 14479 root      20   0       0      0      0 S  0.0  0.0   0:02.59 kworker/u256:2
 16324 root      20   0       0      0      0 S  0.0  0.0   0:02.04 kworker/u256:0
 16555 root      20   0  158760   5608   4256 S  0.0  0.3   0:01.57 sshd
 16559 root      20   0  116228   2996   1792 S  0.0  0.2   0:00.48 bash
 17415 root      20   0       0      0      0 S  0.0  0.0   0:40.42 kworker/0:3
 17426 postfix   20   0   89648   4068   3068 S  0.0  0.2   0:00.02 pickup
 17474 root      20   0  123260    780    552 S  0.0  0.0   0:00.00 anacron
 17491 root      20   0       0      0      0 S  0.0  0.0   0:00.02 kworker/0:1
 17492 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kworker/0:0
 17500 root      20   0  161880   2108   1548 R  0.0  0.1   0:00.04 top
[root@linux-01 ceshi]# 


sar命令

监控系统状态

安装sar命令

## 安装sar 命令 ## 
[root@linux-01 ceshi]# yum install  -y sysstat
已加载插件:fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Determining fastest mirrors
epel/x86_64/metalink                                                                                              | 4.7 kB  00:00:00     
 * base: mirrors.163.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.nju.edu.cn
base                                                                                                              | 3.6 kB  00:00:00     
epel                                                                                                              | 4.7 kB  00:00:00     
extras                                                                                                            | 3.4 kB  00:00:00     
updates                                                                                                           | 3.4 kB  00:00:00     
(1/4): epel/x86_64/updateinfo                                                                                     | 986 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                                 | 187 kB  00:00:00     
(3/4): epel/x86_64/primary_db                                                                                     | 6.7 MB  00:00:02     
(4/4): updates/7/x86_64/primary_db                                                                                | 3.4 MB  00:00:02     
正在解决依赖关系
--> 正在检查事务
---> 软件包 sysstat.x86_64.0.10.1.5-17.el7 将被 安装
--> 正在处理依赖关系 libsensors.so.4()(64bit),它被软件包 sysstat-10.1.5-17.el7.x86_64 需要
--> 正在检查事务
---> 软件包 lm_sensors-libs.x86_64.0.3.4.0-6.20160601gitf9185e5.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=========================================================================================================================================
 Package                          架构                    版本                                               源                     大小
=========================================================================================================================================
正在安装:
 sysstat                          x86_64                  10.1.5-17.el7                                      base                  315 k
为依赖而安装:
 lm_sensors-libs                  x86_64                  3.4.0-6.20160601gitf9185e5.el7                     base                   42 k

事务概要
=========================================================================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:356 k
安装大小:1.2 M
Downloading packages:
(1/2): lm_sensors-libs-3.4.0-6.20160601gitf9185e5.el7.x86_64.rpm                                                  |  42 kB  00:00:00     
(2/2): sysstat-10.1.5-17.el7.x86_64.rpm                                                                           | 315 kB  00:00:01     
-----------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                     265 kB/s | 356 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : lm_sensors-libs-3.4.0-6.20160601gitf9185e5.el7.x86_64                                                                1/2 
  正在安装    : sysstat-10.1.5-17.el7.x86_64                                                                                         2/2 
  验证中      : lm_sensors-libs-3.4.0-6.20160601gitf9185e5.el7.x86_64                                                                1/2 
  验证中      : sysstat-10.1.5-17.el7.x86_64                                                                                         2/2 

已安装:
  sysstat.x86_64 0:10.1.5-17.el7                                                                                                         

作为依赖被安装:
  lm_sensors-libs.x86_64 0:3.4.0-6.20160601gitf9185e5.el7                                                                                

完毕!
[root@linux-01 ceshi]# 

## sar命令安装好后,发现会报错,其实是因为sar没有历史记录导致的报错,不影响,可以加参数既可使用。 ##
[root@linux-01 ceshi]# sar
无法打开 /var/log/sa/sa13: 没有那个文件或目录


sar -n DEV 查看网卡历史流量

在这里插入图片描述

字段含义
12:30:00时间
IFACE网卡设备名称
rxpck/s每秒钟接受的数据包
txpck/s每秒钟发送的数据库
rxkB/s每秒钟接受的数据包大小,单位为KB
txkB/s每秒钟发送的数据包大小,单位为KB
rxcmp/s每秒钟接受的压缩数据包
txcmp/s每秒钟发送的压缩包
rxmcst/s每秒钟接收的多播数据包

sar -n DEV 5 3 查看网卡实时流量

在这里插入图片描述

sar -n DEV -f 查看某一天的网卡历史流量

在这里插入图片描述

sar -q 查看历史负载

在这里插入图片描述

查看磁盘的读和写

在这里插入图片描述

/var/log/sa/ 下的文件sa17于sar17区别

sa17是二进制文件,我们无法使用cat查看;
sar17文件可以使用cat查看。

在这里插入图片描述

nload 命令查看网卡流量

安装nload命令包,安装之前先安装epel-release

[root@linux-01 ceshi]# yum install -y nload
已加载插件:fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.nju.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 nload.x86_64.0.0.7.4-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=========================================================================================================================================
 Package                        架构                            版本                                 源                             大小
=========================================================================================================================================
正在安装:
 nload                          x86_64                          0.7.4-4.el7                          epel                           70 k

事务概要
=========================================================================================================================================
安装  1 软件包

总下载量:70 k
安装大小:176 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/epel/packages/nload-0.7.4-4.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY00:00:00 ETA 
nload-0.7.4-4.el7.x86_64.rpm 的公钥尚未安装
nload-0.7.4-4.el7.x86_64.rpm                                                                                      |  70 kB  00:00:01     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
 用户ID     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 指纹       : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 软件包     : epel-release-7-11.noarch (@extras)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : nload-0.7.4-4.el7.x86_64                                                                                             1/1 
  验证中      : nload-0.7.4-4.el7.x86_64                                                                                             1/1 

已安装:
  nload.x86_64 0:0.7.4-4.el7                                                                                                             

完毕!
[root@linux-01 ceshi]# 


nload 实时显示网卡信息

在使用nload命令时,我们需要注意的是curr哪行的数据,incoming为进入网卡的流量,outgoing为网卡出去的流量。

[root@linux-01 ceshi]# nload
Device ens33 [192.168.141.128] (1/2):
=========================================================================================================================================
Incoming:







                                                                                             Curr: 872.00 Bit/s
                                                                                             Avg: 960.00 Bit/s
                                                                                             Min: 872.00 Bit/s
                                                                                             Max: 1.73 kBit/s
                                                                                             Ttl: 32.87 MByte
Outgoing:







                                                                                             Curr: 8.15 kBit/s
                                                                                             Avg: 7.73 kBit/s
                                                                                             Min: 3.98 kBit/s
                                                                                             Max: 8.16 kBit/s
                                                                                             Ttl: 6.61 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: 0.00 Byte
Outgoing:







                                                                                             Curr: 0.00 Bit/s
                                                                                             Avg: 0.00 Bit/s
                                                                                             Min: 0.00 Bit/s
                                                                                             Max: 0.00 Bit/s
                                                                                             Ttl: 0.00 Byte
## 按q退出 ##

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值