系统信息&&硬件信息查看


系统信息&&硬件信息查看

一系统信息查看


(一)查看系统版本信息

[root@centos7 ~]# cat  /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@centos61 ~]# cat  /etc/redhat-release 
CentOS release 6.8 (Final)

(二)查看系统内核版本

[root@centos7 ~]# uname 
Linux
[root@centos7 ~]# uname  -r
3.10.0-957.el7.x86_64 [root@centos7 ~]# uname -a Linux centos7.com 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@centos61 ~]# uname -r
2.6.32-642.el6.x86_64 [root@centos61 ~]# uname -a Linux centos61.com 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

二查看硬件信息

(一)CPU

cpu对应文件

[root@centos61 ~]#  cat  /proc/cpuinfo 
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6 model : 142 model name : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz stepping : 9 microcode : 48 cpu MHz : 2903.998 cache size : 4096 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 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 mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc up arch_perfmon xtopology tsc_reliable nonstop_tsc unfair_spinlock 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 arat xsaveopt fsgsbase bmi1 avx2 smep bmi2 invpcid rdseed adx bogomips : 5807.99 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management:

注意权限只读

[root@centos7 ~]# ll  /proc/cpuinfo 
-r--r--r-- 1 root root 0 Dec  6 15:25 /proc/cpuinfo

cpu的重要参数——physical id

physical id:0    表示服务器上CPU的ID号,目前是1颗CPU,ID为0

对CPU处理

 

计算服务器上CPU颗数


physical id:0
physical id:0
physical id:1
physical id:1

上面显示4次合并就是2颗CPU

[root@centos7 ~]# cat  /proc/cpuinfo | grep  phy
physical id    : 0 address sizes : 43 bits physical, 48 bits virtual physical id : 0 address sizes : 43 bits physical, 48 bits virtual physical id : 1 address sizes : 43 bits physical, 48 bits virtual physical id : 1 address sizes : 43 bits physical, 48 bits virtual [root@centos7 ~]# 

快速统计CPU的颗数

[root@centos7 ~]# grep "physical id"  /proc/cpuinfo |  uniq | wc -l 2

查看每颗CPU核心数

cpu cores:2

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

每颗CPU核心数法2

[root@centos7 ~]# lscpu  |  grep  "socket"
Core(s) per socket:    2

服务器CPU总的核心数

[root@centos7 ~]# cat  /proc/cpuinfo | grep  "processor" processor : 0 processor : 1 processor : 2 processor : 3

服务器CPU总的核心数法2

[root@centos7 ~]# lscpu  |  grep  "CPU(s)"
CPU(s):                4 On-line CPU(s) list: 0-3 NUMA node0 CPU(s): 0-3

注意/proc目录中的信息不让改动,目录中的所有数据都存储在内存里面,即使可以修改也不能永久保存。

包含数据内存存储信息、系统信息、内核信息、服务进程信息。

(二)内存

MemTotal:         995924 kB    服务器总的内存容量
MemFree:          772912 kB    服务器内存空闲容量,可能被其他占用了
MemAvailable:     746652 kB 服务器可用内容容量,只要关注这个
Buffers:            2076 kB    缓冲(加快写入数据)
Cached: 78476 kB 缓存(加快读取数据)
[root@centos7 ~]# cat /proc/meminfo 
MemTotal:         995924 kB    服务器总的内存容量
MemFree:          772912 kB    服务器内存空闲容量,可能被其他占用了 MemAvailable: 746652 kB 服务器可用内容容量,只要关注这个 Buffers: 2076 kB Cached: 78476 kB SwapCached: 0 kB Active: 64164 kB Inactive: 62348 kB Active(anon): 46372 kB Inactive(anon): 7380 kB Active(file): 17792 kB Inactive(file): 54968 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 1572860 kB SwapFree: 1572860 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 46036 kB Mapped: 23720 kB Shmem: 7792 kB Slab: 44956 kB SReclaimable: 17504 kB SUnreclaim: 27452 kB KernelStack: 4144 kB PageTables: 4408 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2070820 kB Committed_AS: 225284 kB VmallocTotal: 34359738367 kB VmallocUsed: 178292 kB VmallocChunk: 34359310332 kB HardwareCorrupted: 0 kB AnonHugePages: 8192 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 73600 kB DirectMap2M: 974848 kB DirectMap1G: 0 kB

(三)磁盘


查看挂载信息:/proc/mounts

[root@centos7 ~]# tail -n2   /proc/mounts 
/dev/sda1 /boot xfs rw,relatime,attr2,inode64,noquota 0 0
tmpfs /run/user/0 tmpfs rw,nosuid,nodev,relatime,size=99596k,mode=700 0 0

注意不能达到100%,如果日志文件无法写入那么服务就会出现问题

[root@centos7 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        40G  1.8G   39G   5% / devtmpfs 476M 0 476M 0% /dev tmpfs 487M 0 487M 0% /dev/shm tmpfs 487M 7.7M 479M 2% /run tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda1 197M 105M 93M 54% /boot tmpfs 98M 0 98M 0% /run/user/0

模拟占用内存

在企业里面内存不够用就要找领导添加内存了,下面就是证据

[root@centos7 ~]# free  -h
              total        used        free      shared  buff/cache   available
Mem:           972M         95M        754M        7.6M 122M 729M Swap: 1.5G 0B 1.5G [root@centos7 ~]# dd if=/dev/zero of=/dev/null bs=1G count=1 1+0 records in 1+0 records out 1073741824 bytes (1.1 GB) copied, 7.93657 s, 135 MB/s [root@centos7 ~]# free -h total used free shared buff/cache available Mem: 972M 54M 856M 1.3M 61M 803M Swap: 1.5G 49M 1.5G

(四)系统负载情况

CPU压力=系統负载

CPU负载文件

[root@centos7 ~]# cat  /proc/loadavg 
0.08 0.05 0.05 1/131 6942

0.08 0.05 0.05

1分钟平均负载  5分钟平均负载     15分钟平均负载

负载数值 <= 总的CPU核心,服务器的核数有很多,比如有128核

因为xshell显示页面太小了

[root@centos7 ~]# w
w: 34 column window is too narrow
[root@centos7 ~]# w
w: 34 column window is too narrow [root@centos7 ~]# w w: 34 column window is too narrow

命令行查看系统负载情况

最简单的命令

[root@centos7 ~]# w
 12:23:06 up 45 min,  2 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 10.0.0.1 11:37 5:22 0.19s 0.19s -bash root pts/1 10.0.0.1 11:37 2.00s 0.02s 0.00s w

猜你喜欢

转载自www.cnblogs.com/wang618/p/11996634.html