free -m 内存信息查询、cat /proc/cpuinfo cpu信息查询

free

[root@VM_0_16_centos ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           996        824        172         10         32        501
-/+ buffers/cache:        289        706 
Swap:            0          0          0 
[root@VM_0_16_centos ~]# 

公式:

  • total1 = used1 + free1 –>996=824+172
  • total1 = used2 + free2 –>996=289+706
  • used1 = buffers1 + cached1 + used2 –>824=32+501+289
  • free2 = buffers1 + cached1 + free1 –>706=32+501+172
    这里第一行用1表示,第二行用2表示;used1=824、used2=289

说明如下:

代码含义
Mem表示物理内存统计
-/+ buffers/cached表示物理内存的缓存统计
Swap表示硬盘上交换分区的使用情况0
total表示物理内存总量996M
used1表示总计分配给缓存(包含buffers 与cache )使用的数量(used2)+缓存并未实际使用(buffer1+cached1)的数量
used2实际使用的buffers 与cache 总量,也是实际使用的内存总量
free1未被分配使用的内存
free2未被使用的buffers与cache 和未被分配的内存之和,这就是系统当前实际可用内存
shared共享内存,一般系统不会用到,这里也不讨论
buffers系统分配但未被使用的buffers 数量
cached系统分配但未被使用的cache 数量

一般而言,可用内存=free+buffers+cached

  • buffer

A buffer is something that has yet to be “written” to disk.

buffer是还没有被写入磁盘的存放数据的缓冲区(写bufffer)。

  • cache

A cache is something that has been “read” from the disk and stored for later use.

cache是从磁盘”读取”并存储起来以备后用的东西(读cache)。

cpu信息查询

  • top -H 查看线程

  • cat /proc/cpuinfo

一、首先要明确物理cpu个数、核数、逻辑cpu数的概念

1.物理cpu数:主板上实际插入的cpu数量,可以数不重复的 physical id 有几个(physical id)

2.cpu核数:单块CPU上面能处理数据的芯片组的数量,如双核、四核等 (cpu cores)

3.逻辑cpu数:一般情况下,逻辑cpu=物理CPU个数×每颗核数,如果不相等的话,则表示服务器的CPU支持超线程技术(HT:简单来说,它可使处理器中的1 颗内核如2 颗内核那样在操作系统中发挥作用。这样一来,操作系统可使用的执行资源扩大了一倍,大幅提高了系统的整体性能,此时逻辑cpu=物理CPU个数×每颗核数x2)(processer 0-n)

二、通过查看/proc/cpuinfo来产看cpu相关信息

1.物理cpu数:[root@server ~]# grep 'physical id' /proc/cpuinfo|sort|uniq|wc -l

2.cpu核数:[root@server ~]# grep 'cpu cores' /proc/cpuinfo|uniq|awk -F ':' '{print $2}'

3.逻辑cpu:[root@server ~]# cat /proc/cpuinfo| grep "processor"|wc -l

4.是否启用超线程:[root@server ~]# cat /proc/cpuinfo| grep -e "cpu cores" -e "siblings" | sort | uniq

cpu cores    : 4
siblings    : 4

假设cpu cores==siblings就代表没有启用

processor    : 0
vendor_id  : GenuineIntel
cpu famil  : 6
model     : 15
model name  : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping   : 7
cpu MHz   : 2666.766
cache size : 4096 KB
physical id    : 0
siblings    : 4
core id    : 0
cpu cores    : 4
fpu      : yes
fpu_exception  : yes
cpuid level   : 10
wp      : yes
flags    : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5338.26
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor    : 1
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 1
siblings    : 4
core id        : 0
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.75
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 2
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 0
siblings    : 4
core id        : 2
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.67
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 3
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 1
siblings    : 4
core id        : 2
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.68
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 4
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 0
siblings    : 4
core id        : 1
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.67
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 5
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 1
siblings    : 4
core id        : 1
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.68
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 6
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 0
siblings    : 4
core id        : 3
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.69
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

processor    : 7
vendor_id    : GenuineIntel
cpu family    : 6
model        : 15
model name    : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping    : 7
cpu MHz        : 2666.766
cache size    : 4096 KB
physical id    : 1
siblings    : 4
core id        : 3
cpu cores    : 4
fpu        : yes
fpu_exception    : yes
cpuid level    : 10
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips    : 5333.68
clflush size    : 64
cache_alignment    : 64
address sizes    : 36 bits physical, 48 bits virtual
power management:

以此为例子,创建文件cpuinfo分析如下:

[root@server ~]# grep 'physical id' cpuinfo|sort|uniq|wc -l
2#物理cpu为2,即主板上插了两颗cpu
[root@server ~]# grep 'cpu cores' cpuinfo|uniq|awk -F ':' '{print $2}'
4#单颗cpu的逻辑cpu为4
[root@server ~]# cat cpuinfo| grep "processor"|wc -l
8#总共的processor为8
[root@server ~]# cat cpuinfo| grep -e "cpu cores"  -e "siblings" | sort | uniq
cpu cores    : 4
siblings    : 4
#cpu cores==siblings,没有启用超线程技术
#那么上面的processor==物理cpu*单颗逻辑cpu
#即③==②*① 在本次输出中成立,并没有启用多线程技术。
[root@server ~]#

参考信息

部分内容参考

部分内容参考

free -m

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值