1. cpu 使用

查看CPU的完整信息:

root@squid ~]# cat /proc/cpuinfo

输出结果如下:

[root@squid ~]# cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
stepping    : 7
cpu MHz     : 3392.294
cache size  : 8192 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 2
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 dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx hypervisor lahf_lm ida arat xsaveopt pln pts dts
bogomips    : 6784.58
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
stepping    : 7
cpu MHz     : 3392.294
cache size  : 8192 KB
physical id : 0
siblings    : 2
core id     : 1
cpu cores   : 2
apicid      : 1
initial apicid  : 1
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 dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx hypervisor lahf_lm ida arat xsaveopt pln pts dts
bogomips    : 6784.58
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

[root@squid ~]#

查看物理CPU的个数:

[root@squid ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
1
[root@squid ~]#

查看每个物理CPU中的core个数(即核数)

[root@squid ~]# cat /proc/cpuinfo | grep "cpu core" | uniq
cpu cores : 2
[root@squid ~]#

查看逻辑CPU的个数:

[root@squid ~]# cat /proc/cpuinfo | grep "processor" | wc -l
2
[root@squid ~]#

2.查看内存

命令如下:

[root@squid ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           996        193        803          0          8         53
-/+ buffers/cache:        130        865
Swap:         3999          0       3999
[root@squid ~]#
total: 内存总数
used: 已经使用的内存数
free: 空闲的内存数
shared: 当前已经废弃不用,总是0
buffers: 缓冲内存数,8M
cache: 缓存内存数, 53M
- buffers/cache: used的内存数,130MB(used-buffers-cache)
- buffers/cache: free的内存数 865MB (free+buffers+cache)