命令查看linux主机配置

查看cpu:

# 总核数 = 物理CPU个数 X 每颗物理CPU的核数 
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数

# 查看物理CPU个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq

# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"| wc -l

# 查看CPU信息(型号)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

结果:

[root@10 ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
4
[root@10 ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores       : 4
[root@10 ~]# cat /proc/cpuinfo| grep "processor"| wc -l
16
[root@10 ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
     16  Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz

查看cpu实时使用:

top

结果:

top - 09:30:33 up 90 days, 23:30,  4 users,  load average: 2.08, 2.17, 3.02
Tasks: 320 total,   2 running, 318 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.1 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 65808120 total, 12818916 free, 17110548 used, 35878656 buff/cache
KiB Swap:  4063228 total,  4063132 free,       96 used. 47484696 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                       
11580 rocketmq  20   0 32.889g 6.817g 2.430g S   1.7 10.9  17:02.07 java                                                                                                                                          
16181 elk       20   0 8615752 0.977g  18256 S   1.3  1.6 134:42.09 java                                                                                                                                          
13253 rocketmq  20   0 9096544 561388  15500 S   0.3  0.9   1:24.11 java                                                                                                                                          
27256 elk       20   0 11.089g 1.927g 138140 S   0.3  3.1  68:06.31 java                                                                                                                                          
30954 zuul      20   0 12.753g 2.004g  14392 S   0.3  3.2 177:53.75 java                                                                                                                                          
    1 root      20   0  193656   6720   3908 S   0.0  0.0   4:55.84 systemd                                                                                                                                       
    2 root      20   0       0      0      0 S   0.0  0.0   0:02.14 kthreadd                                                                                                                                      
    3 root      20   0       0      0      0 S   0.0  0.0   0:02.54 ksoftirqd/0                                                                              

查看内存:

cat /proc/meminfo

结果:

MemTotal:       65808120 kB
MemFree:        12804772 kB
MemAvailable:   47470588 kB
Buffers:             132 kB
Cached:         34063540 kB
SwapCached:            4 kB
Active:         34338292 kB
Inactive:       14446612 kB
Active(anon):   13535808 kB
Inactive(anon):  1570584 kB
Active(file):   20802484 kB
Inactive(file): 12876028 kB
Unevictable:     1649164 kB
Mlocked:         1649164 kB
SwapTotal:       4063228 kB
SwapFree:        4063132 kB
Dirty:               108 kB
Writeback:             0 kB
AnonPages:      16370448 kB
Mapped:          2841072 kB
Shmem:            258000 kB
Slab:            1815012 kB
SReclaimable:    1595996 kB
SUnreclaim:       219016 kB
KernelStack:       21696 kB
PageTables:        68456 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    36967288 kB
Committed_AS:   26694944 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      257500 kB
VmallocChunk:   34308747260 kB
HardwareCorrupted:     0 kB
AnonHugePages:  14931968 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      307136 kB
DirectMap2M:    28004352 kB
DirectMap1G:    40894464 kB

查看剩余内存:

#-m代表M单位,-g代表G单位
free -m

结果:

[root@10 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          64265       47209         275        3250       16781       13082
Swap:          3967         944        3023

查看硬盘信息:

fdisk -l

结果:

[root@10 ~]# fdisk -l

磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d7a33

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   104857599    51915776   8e  Linux LVM

查看硬盘使用情况:

df -h

结果:

[root@10 ~]# df -h
文件系统             容量  已用  可用 已用% 挂载点
/dev/mapper/cl-root   36G   22G   15G   61% /
devtmpfs              32G     0   32G    0% /dev
tmpfs                 32G   84K   32G    1% /dev/shm
tmpfs                 32G  3.2G   29G   11% /run
tmpfs                 32G     0   32G    0% /sys/fs/cgroup
/dev/sda1            497M  167M  330M   34% /boot

查看磁盘io:

ulimit -a

结果:

[root@10 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256939
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256939
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

查看磁盘实时io:

iostat -x 10

结果:

[root@10 ~]# iostat -x 10
Linux 3.10.0-514.el7.x86_64 (10.1.4.34)         2018年08月31日  _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.35    0.00    0.10    0.03    0.00   99.52

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
fd0               0.00     0.00    0.00    0.00     0.00     0.00     8.00     0.00   51.00   51.00    0.00  51.00   0.00
sda               0.00     0.25    0.01    2.14     0.54    19.79    18.86     0.09   40.32   18.75   40.42  10.47   2.26
sdb               0.00     0.03    0.02    0.38     0.67    30.53   157.34     0.03   81.85   21.18   84.33  24.41   0.97
dm-0              0.00     0.00    0.01    2.33     0.53    19.21    16.86     0.10   43.52   18.65   43.62   9.45   2.21
dm-1              0.00     0.00    0.00    0.02     0.00     0.07     8.00     0.00  101.44   51.71  103.51   0.72   0.00
dm-2              0.00     0.00    0.02    0.46     0.67    31.04   133.44     0.04   81.26   21.28   83.30  21.32   1.01
dm-3              0.00     0.00    0.00    0.00     0.00     0.00    41.44     0.00   60.70    1.44  221.01  52.24   0.00
dm-4              0.00     0.00    0.00    0.00     0.00     0.00    43.26     0.00   63.92    1.49  253.16  55.01   0.00

 

posted @ 2018-08-31 09:39  但行好事-莫问前程  阅读(5559)  评论(0编辑  收藏  举报