您现在的位置:首页 > 系统运维 > Linux运维

centos 查看cpu、内存等系统基本信息

本文以centos7为例。 查看CPU信息 查看内存使用信息: 查看系统是32还是64位:…

本文以centos7为例。

 

查看CPU信息


[root@192 ~]# grep "model name" /proc/cpuinfo
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz

[root@192 ~]# more /proc/cpuinfo | grep "model name"
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz
model name      : Intel(R) Atom(TM) CPU D525   @ 1.80GHz

[root@192 ~]# grep "model name" /proc/cpuinfo | cut -f2 -d:
 Intel(R) Atom(TM) CPU D525   @ 1.80GHz
 Intel(R) Atom(TM) CPU D525   @ 1.80GHz
 Intel(R) Atom(TM) CPU D525   @ 1.80GHz
 Intel(R) Atom(TM) CPU D525   @ 1.80GHz

查看内存使用信息:


[root@192 ~]# grep MemTotal /proc/meminfo
MemTotal:        3869868 kB
[root@192 ~]# 
[root@192 ~]# grep MemTotal /proc/meminfo | cut -f2 -d:
        3869868 kB
[root@192 ~]# free -m |grep "Mem" | awk '{print $2}'
3779
[root@192 ~]# 

查看系统是32还是64位:


[root@192 ~]# getconf LONG_BIT
64
[root@192 ~]# echo $HOSTTYPE
x86_64
[root@192 ~]# 
[root@192 ~]# uname -a
Linux 192.168.50.209 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@192 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core) 

查看硬盘分区:


[root@192 ~]# df -hT
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        50G  5.3G   45G   11% /
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G  9.3M  1.9G    1% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/centos-home xfs        57G   33M   57G    1% /home
/dev/sda1               xfs      1014M  180M  835M   18% /boot
tmpfs                   tmpfs     378M   12K  378M    1% /run/user/42
tmpfs                   tmpfs     378M     0  378M    0% /run/user/0

查看selinux状态:


[root@192 ~]# sestatus
SELinux status:                 disabled
[root@192 ~]# sestatus | cut -f2 -d:
                 disabled
[root@192 ~]# cat /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 


[root@192 ~]# 

使用top命令,查看系统整体状态,包含cpu、内存、登录用户、系统状态、进程占用状态等等


[root@192 ~]# top
top - 15:43:37 up  1:01,  2 users,  load average: 5.33, 5.31, 4.38
Tasks: 215 total,   7 running, 208 sleeping,   0 stopped,   0 zombie
%Cpu(s): 92.5 us,  7.5 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3869868 total,   305072 free,   782956 used,  2781840 buff/cache
KiB Swap:  4063228 total,  4063228 free,        0 used.  2650920 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME  COMMAND                                                
 9362 root      20   0  232684  99124   6960 R  98.7  2.6   0:05.96 cc1plus                                                
 9216 root      20   0  309136 172224  10960 R  97.4  4.5   0:19.25 cc1plus                                                
 9328 root      20   0  289824 150180   6692 R  95.1  3.9   0:09.21 cc1plus                                                
 9423 root      20   0  148548  12168   3604 R  11.3  0.3   0:00.35 cc1plus                                                
 9353 root      20   0  162016   2356   1584 R   1.3  0.1   0:00.15 top                                                    
 2646 root      39  19  119996   2376   1072 S   0.6  0.1   0:04.43 mandb                                                  
 4605 root      20   0  161312   6124   4712 S   0.6  0.2   0:03.24 sshd                                                   
    9 root      20   0       0      0      0 S   0.3  0.0   0:17.44 rcu_sched                                              
 1595 root      20   0       0      0      0 S   0.3  0.0   0:03.09 xfsaild/dm-0                                           
 7189 root      20   0       0      0      0 S   0.3  0.0   0:00.02 kworker/0:0                                            
    1 root      20   0  191384   4364   2652 S   0.0  0.1   0:06.44 systemd                                                
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd                                               
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.11 ksoftirqd/0                                            
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                           
    7 root      rt   0       0      0      0 S   0.0  0.0   0:00.10 migration/0                                            
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh                                                 
   10 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-drain                                          
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.03 watchdog/0                                             
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.04 watchdog/1                                             
   13 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 migration/1                                            
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.21 ksoftirqd/1                                            
   16 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H                                           
   17 root      rt   0       0      0      0 S   0.0  0.0   0:00.04 watchdog/2                                             
   18 root      rt   0       0      0      0 S   0.0  0.0   0:00.51 migration/2                                            
   19 root      20   0       0      0      0 S   0.0  0.0   0:00.09 ksoftirqd/2                                            
   21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/2:0H                                           
   22 root      rt   0       0      0      0 S   0.0  0.0   0:00.03 watchdog/3                                             
   23 root      rt   0       0      0      0 S   0.0  0.0   0:00.16 migration/3  

运行 top 命令后,CPU 使用状态会以全屏的方式显示,并且会处在对话的模式 — 用基于 top的命令,可以控制显示方式等等。退出 top 的命令为 q (在 top 运行中敲 q 键一次)。

top 的全屏对话模式可分为3部分:系统信息栏、命令输入栏、进程列表栏。第一部分 — 最上部的 系统信息栏 :第一行(top):“15:43:37”为系统当前时刻;1:01”为系统启动后到现在的运作时间;“2user”为当前登录到系统的用户,更确切的说是登录到用户的终端数 —同一个用户同一时间对系统多个终端的连接将被视为多个用户连接到系统,这里的用户数也将表现为终端的数目。

第二行(Tasks):“215 total”为当前系统进程总数;“7 running”为当前运行中的进程数;“208 sleeping”为当前处于等待状态中的进程数;“0 stoped”为被停止的系统进程数;“0 zombie”为被复原的进程数。

第三行(Cpus):分别表示了 CPU 当前的使用率;第四行(Mem):分别表示了内存总量、当前使用量、空闲内存量、以及缓冲使用中的内存量;第五行(Swap):表示类别同第四行(Mem),但此处反映着交换分区(Swap)的使用情况。通常,交换分区(Swap)被频繁使用的情况,将被视作物理内存不足而造成的。

第二部分 — 中间部分的内部命令提示栏:top 运行中可以通过 top 的内部命令对进程的显示方式进行控制。第三部分 — 最下部分的进程列表栏:以 PID 区分的进程列表将根据所设定的画面更新时间定期的更新。通过 top 内部命令可以控制此处的显示方式。一般的,我们通过远程监控的方式对服务器进行维护,让服务器本地的终端实时的运行 top,是在服务器本地监视服务器状态的快捷便利之一。

版权所有
侵权必究

上一篇
PXE kickstart.fg无人值守安装linux操作系统
下一篇
centos7 搭建rsync服务 实现文件同步 详细步骤 与常见排错