Linux(centos7)上如何查看内存、CPU以及硬盘的使用情况

文章目录

    • 查看内存使用情况
    • 查看CPU
    • 查看硬盘使用情况


查看内存使用情况

命令:top

[root@centos mysdb]# top
top - 10:00:28 up  4:47,  2 users,  load average: 0.00, 0.01, 0.05
Tasks: 130 total,   2 running, 126 sleeping,   2 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 :  1863088 total,  1430004 free,   144384 used,   288700 buff/cache
KiB Swap:  6160376 total,  6160376 free,        0 used.  1518976 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND         
     1 root      20   0  193760   6816   4152 S   0.0  0.4   0:03.57 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:15.32 kworker/0:0     
     4 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H    
     5 root      20   0       0      0      0 S   0.0  0.0   0:00.43 kworker/u256:0  
     6 root      20   0       0      0      0 S   0.0  0.0   0:00.18 ksoftirqd/0     
     7 root      rt   0       0      0      0 S   0.0  0.0   0:00.04 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:03.83 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:00.07 watchdog/0      
    12 root      rt   0       0      0      0 S   0.0  0.0   0:00.06 watchdog/1      
    13 root      rt   0       0      0      0 S   0.0  0.0   0:00.04 migration/1     
    14 root      20   0       0      0      0 S   0.0  0.0   0:00.15 ksoftirqd/1     
    16 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H    
    18 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kdevtmpfs       
    19 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 netns           
    20 root      20   0       0      0      0 S   0.0  0.0   0:00.00 khungtaskd      
    21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 writeback       
    22 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kintegrityd     
    23 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 bioset          
    24 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 bioset          
    25 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 bioset          
    26 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kblockd         
    27 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 md              
    28 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 edac-poller     
    29 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 watchdogd       
    35 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kswapd0
字段 含义
PID 进程id
USER 进程所有者
PR 进程优先级
NI nice值。负值表示高优先级,正值表示低优先级
VIRT 进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES
RES 进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATA
SHR 共享内存大小,单位kb
S 进程状态。D=不可中断的睡眠状态 R=运行 S=睡眠 T=跟踪/停止 Z=僵尸进程
%CPU 上次更新到现在的CPU时间占用百分比
%MEM 进程使用的物理内存百分比
TIME+ 进程使用的CPU时间总计,单位1/100秒
COMMAND 进程名称(命令名/命令行)

查看CPU

命令:cat /proc/cpuinfo

[root@centos ~]# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
stepping	: 9
microcode	: 0x8e
cpu MHz		: 2712.002
cache size	: 3072 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf 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 epb invpcid_single ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp spec_ctrl intel_stibp
bogomips	: 5424.00
clflush size	: 64
cache_alignment	: 64
address sizes	: 42 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
stepping	: 9
microcode	: 0x8e
cpu MHz		: 2712.002
cache size	: 3072 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 2      #CPU的核心数
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf 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 epb invpcid_single ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp spec_ctrl intel_stibp
bogomips	: 5424.00
clflush size	: 64
cache_alignment	: 64
address sizes	: 42 bits physical, 48 bits virtual
power management:

lscpu

[root@centos ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    1
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 142
Model name:            Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Stepping:              9
CPU MHz:               2712.002
BogoMIPS:              5424.00
Hypervisor vendor:     VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0,1
[root@centos ~]# cat /proc/cpuinfo| grep "physical id"|uniq| wc -l
1
[root@centos ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores	: 2
[root@centos ~]# cat /proc/cpuinfo| grep "processor"| wc -l
2
physical id 物理CPU数
cpu cores cpu核数
processor 逻辑CPU数

查看硬盘使用情况

命令:df -h

[root@centos ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   46G  4.5G   42G  10% /
devtmpfs                 893M     0  893M   0% /dev
tmpfs                    910M     0  910M   0% /dev/shm
tmpfs                    910M  9.1M  901M   1% /run
tmpfs                    910M     0  910M   0% /sys/fs/cgroup
/dev/sda1                497M  182M  315M  37% /boot
tmpfs                    182M     0  182M   0% /run/user/0
字段 解释
Filesystem 文件系统
Size 大小
Used 已用
Avail 可用
Use% 已用%
Mounted on 挂载点

你可能感兴趣的:(Linux(centos7)上如何查看内存、CPU以及硬盘的使用情况)