linux 硬件和性能查看

一、如何查看服务器的CPU
判断依据:
1.具有相同core id的cpu是同一个core的超线程。(Physical id and core id are not necessarily consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.)
2.具有相同physical id的cpu是同一颗cpu封装的线程或者cores。(Any cpu with the same physical id are threads or cores in the same physical socket.)
①物理cpu个数:
[root@localhost ~]# cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l
②每个物理cpu中core的个数(即核数)
[root@localhost ~]# cat /proc/cpuinfo | grep “cpu cores” | uniq cpu cores : 4
这样可以推算出自己服务器的逻辑CPU为物理个数*核数
/proc/cpuinfo 描述中有 6 个条目适用于多内核和超线程(HT)技术检查:processor, vendor id, physical id, siblings, core id 和 cpu cores。
* processor 条目包括这一逻辑处理器的唯一标识符。
* physical id 条目包括每个物理封装的唯一标识符。
* core id 条目保存每个内核的唯一标识符。
* siblings 条目列出了位于相同物理封装中的逻辑处理器的数量。
* cpu cores 条目包含位于相同物理封装中的内核数量。
* 如果处理器为英特尔处理器,则 vendor id 条目中的字符串是 GenuineIntel。
二、查看服务器的内存情况
[root@]# free -m
total used free shared buffers cached
Mem: 64350 12506 51843 0 263 10608
-/+ buffers/cache: 1634 62715
Swap: 11999 0 11999
参数解释:
total 内存总数
used 已经使用的内存数
free 空闲的内存数
shared 多个进程共享的内存总额
buffers Buffer Cache和cached Page Cache 磁盘缓存的大小
-buffers/cache (已用)的内存数:used – buffers – cached
+buffers/cache(可用)的内存数:free + buffers + cached
可用的memory=free memory+buffers+cached
其可使用内存为=51843+263+10608。 Linux的内存使用管理机制是有多少就用多少(特别是在频繁存取文件后),即Linux内存不是拿来看的,是拿来用的。
三、服务器磁盘使用情况
有时感觉硬盘反映很慢,或需要查看日志所在分区时,下列命令可以查看磁盘的使用情况:
[root@]# iostat -x 1 10
Linux 2.6.32-358.el6.x86_64 07/26/2016 _x86_64_ (24 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.18 0.00 0.06 0.58 0.00 99.17
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.28 261.15 0.42 44.21 30.34 2442.90 55.41 0.85 19.02 4.53 20.21
avg-cpu: %user %nice %system %iowait %steal %idle
0.38 0.00 0.13 1.29 0.00 98.21
**********省略
[root@]# iostat -d
Linux 2.6.32-358.el6.x86_64 07/26/2016 _x86_64_ (24 CPU)
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 44.63 30.29 2442.76 3742706 301857704
图解:
Tps 该设备每秒I/O传输的次数(每秒的I/O请求)
Blk_read/s 表求从该设备每秒读的数据块数量
Blk_wrth/s 表示从该设备每秒写的数据块数量
五、查看服务器使用的Linux发行版的名称、版本号及描述信息等
lsb_release -a or root@]# cat /etc/redhat-release
六、查看服务器的平均负载
感觉到系统压力较大时用可top uptime or w 查看下服务器的平均负载。uptime w 的另一个用法是查看你的Linux服务器已经稳定运行多少天没有重启了。
七、查看系统整体性能情况
如果感觉系统比较繁忙,可以用vmstat查看系统整体性能情况。vmstat不仅仅适应于linux系统,它一样适用于FreeBSD等unix系统。
[root@]# vmstat 1 2
procs ———–memory———- —swap– —–io—- –system– —–cpu—–
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 1 0 53079932 270924 10869396 0 0 1 51 4 11 0 0 99 1 0
0 0 0 53079296 270924 10869424 0 0 0 148 404 512 0 0 99 0 0
如果 r经常大于 4 ,且id经常少于40,表示cpu的负荷很重。
如果pi,po 长期不等于0,表示内存不足。
如果disk 经常不等于0, 且在 b中的队列 大于3, 表示 io性能不好。
八、查看系统已载入的相关模块
Linux操作系统的核心具有模块化的特性,应此在编译核心时,务须把全部的功能都放入核心。你可以将这些功能编译成一个个单独的模块,待需要时再分别载入。比如说在安装LVS+Keepalived,下列用法被经常用到:
#检查内核模块,看一下ip_vs是否被加载
lsmod |grep ip_vs ip_vs 77313 0
如果要查看当前系统的已加载模块,直接lsmod。
九、Linux下查找PCI设置
有时需要在Linux下查找PCI设置,可用lspci命令,它可以列出机器中的PCI 设备,比如声卡、显卡、Modem、网卡等,主板集成设备也能列出来。lspci 读取的是hwdata 数据库。有的小伙可能和我一样,最关心的还是网卡型号:
[root@~]# lspci | grep Ethernet
07:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
07:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)