系统相关
首页 > 系统相关> > 查看Linux系统内存、CPU、磁盘使用率

查看Linux系统内存、CPU、磁盘使用率

作者:互联网

一、查看内存占用

# free -m

以MB为单位显示内存使用情况

[root@localhost ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          11852        1250        8668         410        1934        9873
Swap:          6015           0        6015

# free -h

以GB为单位显示内存使用情况

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            11G        1.2G        8.5G        410M        1.9G        9.6G
Swap:          5.9G          0B        5.9G

# free -t

以总和的形式查询内存的使用信息

[root@localhost ~]# free -t
              total        used        free      shared  buff/cache   available
Mem:       12137332     1285344     8870628      420268     1981360    10105740
Swap:       6160380           0     6160380
Total:     18297712     1285344    15031008

# free -s 5

周期性的查询内存使用信息

每5秒执行一次命令

[root@localhost ~]# free -s 5
              total        used        free      shared  buff/cache   available
Mem:       12137332     1280796     8875008      420268     1981528    10110136
Swap:       6160380           0     6160380

解释:

Mem:内存的使用情况总览表

total:机器总的物理内存

used:用掉的内存

free:空闲的物理内存

注:物理内存(total)=系统看到的用掉的内存(used)+系统看到空闲的内存(free)

二、查看CPU使用情况

# top -d 5

周期性的查询CPU使用信息

每5秒刷新一次

top - 02:37:55 up 4 min,  1 user,  load average: 0.02, 0.10, 0.05
Tasks: 355 total,   1 running, 354 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.0 us,  2.8 sy,  0.0 ni, 94.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1868660 total,  1081340 free,   578388 used,   208932 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  1123992 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                  
  2220 mysql     20   0 1307796 471172   7608 S  0.6 25.2   0:02.31 mysqld                                                                                   
   349 root      20   0       0      0      0 S  0.4  0.0   0:01.14 kworker/0:3                                                                              
   644 root      20   0       0      0      0 S  0.4  0.0   0:00.17 xfsaild/dm-0                                                                             
  3489 root      20   0  146432   2268   1440 R  0.4  0.1   0:00.11 top                                                                                      
     1 root      20   0   44500   7120   2596 S  0.2  0.4   0:01.69 systemd                                                                                  
   283 root      39  19       0      0      0 S  0.2  0.0   0:00.18 khugepaged                                                                               
  2621 root      20   0  141264   5140   3896 S  0.2  0.3   0:00.18 sshd                                                                                     
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd                                                                                 
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.01 ksoftirqd/0                                                                              
     4 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kworker/0: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.02 kworker/u256: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 S  0.0  0.0   0:00.00 rcuob/0                                                                                  
    10 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/1                                                                                  
    11 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/2                                                                                  
    12 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/3                                                                                  
    13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/4                                                                                  
    14 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/5                                                                                  
    15 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/6                                                                                  
    16 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/7                                                                                  
    17 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/8                                                                                  
    18 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/9                                                                                  
    19 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/10                                                                                 
    20 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/11                                                                                 
    21 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/12                                                                                 
    22 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/13                                                                                 
    23 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/14                                                                                 
    24 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/15                                                                                 
    25 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/16                                                                                 
    26 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/17                                                                                 
    27 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/18                                                                                 
    28 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/19                                                                                 
    29 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/20                                                                                 
    30 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/21      

三、查看网络情况

# ifconfig

[root@localhost ~]# ifconfig 
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.80  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::20c:29ff:fe4c:ff47  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:4c:ff:47  txqueuelen 1000  (Ethernet)
        RX packets 7866  bytes 632606 (617.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 215  bytes 31932 (31.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 8  bytes 400 (400.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 400 (400.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ip a

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:4c:ff:47 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.80/24 brd 192.168.2.255 scope global eno16777736
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe4c:ff47/64 scope link 
       valid_lft forever preferred_lft forever

四、查看磁盘以及分区情况

# df -Th

查看分区、挂载情况

[root@localhost ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        15G  2.8G   13G  19% /
devtmpfs                devtmpfs  903M     0  903M   0% /dev
tmpfs                   tmpfs     913M     0  913M   0% /dev/shm
tmpfs                   tmpfs     913M  8.6M  904M   1% /run
tmpfs                   tmpfs     913M     0  913M   0% /sys/fs/cgroup
/dev/sda1               xfs       297M  115M  183M  39% /boot
tmpfs                   tmpfs     183M     0  183M   0% /run/user/0

# lsblk

查看磁盘情况

[root@localhost ~]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  300M  0 part /boot
└─sda2            8:2    0   19G  0 part 
  ├─centos-root 253:0    0   15G  0 lvm  /
  └─centos-swap 253:1    0    4G  0 lvm  [SWAP]
sr0              11:0    1    4G  0 rom  

# fdisk -l

查看详细的硬盘分区情况

[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0004a0a8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448    40478719    19931136   8e  Linux LVM

Disk /dev/mapper/centos-root: 16.1 GB, 16106127360 bytes, 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

end

标签:00.00,20,0.0,bytes,rcuob,Linux,使用率,root,CPU
来源: https://www.cnblogs.com/djlsunshine/p/10833343.html