一、需求说明

  因为疫情原因长时间居家办公,系统运行在公司的服务器上,系统相关服务都有监控,领导想知道服务器运行的物理状态如何,比如CPU温度是否过高。为了满足领导要求,觉得检查服务器的CPU温度是否正常。博文环境:

  • Dell物理机
  • 操作系统:centos 7.6
  • sensors版本:3.4.0
      实际上sensors命令只是读取了/sys/class/hwmon/目录下关于CPU等传感器温度参数并直观的展示给我们,我们不安装lm_sensors模块下也可以查看CPU温度。

二、lm_sensors简介

  lm_sensors是一款linux的硬件监控的软件,可以帮助我们来监控主板,CPU的工作电压,风扇转速、温度等数据。这些数据我们通常在主板的 BIOS也可以看到。当我们可以在机器运行的时候通过lm_sensors随时来监测着CPU的温度变化,可以预防和保护因为CPU过热而会烧掉。

三、sensors命令安装及使用

1、yum安装lm_sensors

在这里插入图片描述

[root@s146 yum.repos.d]# yum install -y lm_sensors
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

Installed:
lm_sensors.x86_64 0:3.4.0-8.20160601gitf9185e5.el7

Dependency Installed:
lm_sensors-libs.x86_64 0:3.4.0-8.20160601gitf9185e5.el7

Complete!

2、查看sensors版本

[root@s146 opt]# sensors -v
sensors version 3.4.0 with libsensors version 3.4.0

3、传感器探测

在这里插入图片描述

[root@s146 opt]# sensors-detect
# sensors-detect revision 3.4.0-8 (2016-06-01)
# System: QEMU Standard PC (i440FX + PIIX, 1996) [pc-i440fx-6.0]
# Kernel: 3.10.0-957.el7.x86_64 x86_64
# Processor: Common KVM processor (15/6/1)

Sorry, no sensors were detected.
Either your system has no sensors, or they are not supported, or
they are connected to an I2C or SMBus adapter that is not
supported. If you find out what chips are on your board, check
https://hwmon.wiki.kernel.org/device_support_status for driver status.
#如上是虚拟机传感器探测结果,找不到传感器

4、查看温度

在这里插入图片描述

(base) [root@test yum.repos.d]# sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +105.0°C)
temp2: +29.8°C (crit = +105.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +56.0°C (high = +80.0°C, crit = +100.0°C)
Core 0: +56.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +48.0°C (high = +80.0°C, crit = +100.0°C)

四、不安装lm_sensors模块下直接查看温度

1、查看cpu1温度

在这里插入图片描述

2、CPU温度值存储路径

在这里插入图片描述

3、命令查看和sys参数查看对比

在这里插入图片描述

五、QA

1、虚拟机执行sensors命令报错No sensors found!

  • 报错信息:
    在这里插入图片描述

  • 报错原因:因为找不到传感器

  • 解决方案:可以使用sensors-detect命令探测,如果是虚拟机不存在直接连接传感器,无法查看温度信息。

2、kmod-coretemp安装

关于kmod-coretemp的安全要求,实际上如果是centos7,我们并不需要安装此模块,因为操作系统已经安装了kmod-20-28.el7.x86_64、kmod-libs-20-23.el7.x86_64。
在这里插入图片描述

#centos6安装kmod-coretemp软件包
#wget http://www.pperry.f2s.com/linux/coretemp/kmod-coretemp-1.1-2.el5.x86_64.rpm
#rpm -ivh kmod-coretemp-1.1-2.el5.x86_64.rpm

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐