Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to monitor CPU data of motherboard by CentOS sensors software

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how the CentOS sensors software monitors motherboard CPU data. The content is concise and easy to understand. It can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Under Linux, there is a software called CentOS sensors that can help us to monitor the motherboard, CPU working voltage, fan speed, temperature and other data. These data can usually be seen in the BIOS of the motherboard. When we can monitor the temperature change of the CPU through CentOS sensors at any time while the machine is running, we can prevent the protection from burning out because the CPU is overheated.

1. Install CentOS sensors now basically every Linux already has a CentOS sensors package, we mainly install it. Or we can compile it ourselves through the source file. 1) under FC,RH, CENTOS, use rpm: [root @ securitycn ~] # rpm-ivh lm_sensors-2.10.0-3.1.i386.rpm3) to compile the source file and install it. We can download the source file here. The problem we should pay attention to here is to install the libsysfs library, which is the Sysfsutils,Sysfsutils-devel software.

Tar xzvf lm-sensors-xxx.tar.gz make user make user_install testing

Let's use some simple commands to use CentOS sensors to get CPU data. We need to use the identity of root: sensors-detect, and then it will automatically search for the chipset and the corresponding driver on the motherboard. We can all answer YES. [root@securitycn ~] # sensors-detect

# sensors-detect revision 1.413 (20:28:00 on 2006-01-19) This program will help you determine which I2C/SMBus modules you need to load to use lm_sensors most effectively. You need to have i2c and lm_sensors installed before running this program. Also, you need to be `root', or at least have access to the / dev/i2c-* files, for most things. If you have patched your kernel and have some drivers built in, you can safely answer NO if asked to load some modules. In this case, things may seem a bit confusing, but they will still work. It is generally safe and recommended to accept the default answers to all questions, unless you know what you're doing. We can start with probing for (PCI) I2C or SMBus adapters. You do not need any special privileges for this. Do you want to probe now? (YES/no):

All default YES is fine. Then we start CentOS sensors:

/ etc/init.d/lm_sensors start Starting lm_sensors: [OK]

We can use lsmod to determine whether the driver we need has been loaded.

Lsmod | grep i2c i2c_isa 9153 2 w83627hf i2c_i801 w83781d i2c_i801 11341 0 i2c_dev 12613 0 i2c_ec 9025 1 sbs i2c_core 23745 6 w83627hf law w83781d sbs i2c_core i2coriginisa language i2corigini801 language i2corigindevw2croomec

Then we can use the command of CentOS sensors:

[root@securitycn] # sensors w83627hf-isa-0290 Adapter: ISA adapter VCore 1: + 3.33V (min = + 0.00V, max = + 0.00V) ALARM VCore 2: + 3.36V (min = + 0.00V, max = + 0.00V) ALARM + 3.3V: + 0.93V (min = + 3.14V, max = + 3.46V) ALARM + 5V: + 5.11V (min = + 4.73V, max = + 5.24V) + 12V: + 4.56V (min = + 10.82V) Max = + 13.19V) ALARM-12V:-7.10V (min =-13.18V, max =-10.88V) ALARM-5V:-1.93V (min =-5.25V, max =-4.75V) ALARM V5SB: + 5.51V (min = + 4.73V, max = + 5.24V) ALARM VBat: + 0.02V (min = + 2.40V, max = + 3.60V) ALARM fan1: 0 RPM (min = 2732 RPM) Div = 2) ALARM fan2: 0 RPM (min = 0 RPM, div = 2) fan3: 0 RPM (min = 0 RPM, div = 2) temp1: + 38'(high = + 50', hyst = + 45') sensor = thermistor temp2: + 33. 5'(high = + 80', hyst = + 75') sensor = thermistor temp3: + 33. 5'(high = + 80', hyst = + 75') sensor = thermistor vid: + 0.000 V (VRM Version 10.0) alarms: beep_enable Sound alarm enabled

Here we can see that the temperature does not correspond to the CPU, so we can mainly modify / etc/sensors.conf slightly, but we don't have to do it ourselves. Generally, we can download the configuration file from the motherboard manufacturer. Through CentOS sensors, we can get the information of motherboard temperature, CPU voltage and fan speed. We can use these data to monitor the operation of the system to prevent system problems.

Next, let's integrate it with MRTG.

[root@securitycn ~] # cd / usr/local/mrtg/bin [root@securitycn ~] # vi temp.sh # content is as follows: #! / bin/bash cputemp= `/ usr/bin/sensors | grep temp1 | awk'{print $2}'| cut-c 2-4` # this sentence is to find out the line with temp1 Print 2-4 words of the second column systemp = `/ usr/bin/sensors | grep temp2 | awk'{print $2}'| cut-c 2-5` No need to explain echo $cputemp echo $systemp # the uptime uptime | sed's: ^. * up\ (. *\) [0-9] [0-9] * users.*$:\ 1chmod'# my name uname-n [root@securitycn ~] # chmod + x temp.sh is changed to executable [root@securitycn] #. / temp.sh try to see if there is any problem 39 33.5 15:36:19 up 22:28, 1 user, load average: 0.04,0.09,0.04 securitycn

CentOS sensors, write the following file again.

[root@securitycn ~] # cd.. / etc/ [root@securitycn ~] # vi temp.cfgWorkDir: / data1/usr/apache/htdocs/mrtg/temp/ Target [index]: `/ usr/local/mrtg/bin/ temp.sh` MaxBytes [index]: 80 Options [index]: gauge, nopercent, growright YLegend [index]: Temp (degree) ShortLegend [index]: degree LegendO [index]: system temperature; LegendI [index]: CPU temperature Title [index]: system thermometer PageTop [index]: mainframe thermometer

[root@securitycn ~] # / usr/local/mrtg/bin/mrtg / usr/local/mrtg/etc/temp.cfg execute 3 times and then add it to crontab * / 5 * / usr/local/mrtg/bin/mrtg / usr/local/mrtg/etc/temp.cfgPageTop [index]: host thermometer

The above content is how the CentOS sensors software monitors the motherboard CPU data. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report