CentOS sensors软件监控主板CPU数据
创始人
2024-06-23 10:51:21
0

xx对于电脑使用的玩家的常用软件,然后我就学习及深入的研究xx,在这里和大家一起探讨xx的使用方法,希望对大家有用。用MRTG监测Linux系统CPU温度

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

1. 安装CentOS sensors现在基本上每个Linux都已经有CentOS sensors包了,我们主要安装了就可以了。或者我们也可以通过源文件来自己编译。1)在FC,RH, CENTOS下,用rpm:[root@securitycn ~]# rpm -ivh lm_sensors-2.10.0-3.1.i386.rpm3)编译源文件安装我们可以通过:这里下载源文件这里我们要注意的问题是要先安装libsysfs库,是Sysfsutils,Sysfsutils-devel软件

  1. tar xzvf lm-sensors-xxx.tar.gz  
  2. make user  
  3. make user_install testing 

下面我们就用一些简单的命令来利用CentOS sensors来得到CPU的数据。我们要用root的身份来:sensors-detect,然后它会自动搜索主板上的chipset和相应的driver,我们全部答YES就可以了[root@securitycn ~]# sensors-detect

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

全部默认YES即可。然后我们启动CentOS sensors:

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

我们可以通过lsmod来确定我们需要的driver已经加载了没有

  1. lsmod | grep i2c  
  2. i2c_isa 9153 2 w83627hf,w83781d  
  3. i2c_i801 11341 0   
  4. i2c_dev 12613 0   
  5. i2c_ec 9025 1 sbs  
  6. i2c_core 23745 6 w83627hf,w83781d,i2c_isa,i2c_i801,i2c_dev,i2c_ec 

然后我们用CentOS sensors的命令就可以了:

  1. [root@securitycn ~]# sensors  
  2. w83627hf-isa-0290  
  3. Adapter: ISA adapter  
  4. VCore 1: +3.33 V (min = +0.00 V, max = +0.00 V) ALARM   
  5. VCore 2: +3.36 V (min = +0.00 V, max = +0.00 V) ALARM   
  6. +3.3V: +0.93 V (min = +3.14 V, max = +3.46 V) ALARM   
  7. +5V: +5.11 V (min = +4.73 V, max = +5.24 V)   
  8. +12V: +4.56 V (min = +10.82 V, max = +13.19 V) ALARM   
  9. -12V: -7.10 V (min = -13.18 V, max = -10.88 V) ALARM   
  10. -5V: -1.93 V (min = -5.25 V, max = -4.75 V) ALARM   
  11. V5SB: +5.51 V (min = +4.73 V, max = +5.24 V) ALARM   
  12. VBat: +0.02 V (min = +2.40 V, max = +3.60 V) ALARM   
  13. fan1: 0 RPM (min = 2732 RPM, div = 2) ALARM   
  14. fan2: 0 RPM (min = 0 RPM, div = 2)   
  15. fan3: 0 RPM (min = 0 RPM, div = 2)   
  16. temp1: +38癈 (high = +50癈, hyst = +45癈) sensor = thermistor   
  17. temp2: +33.5癈 (high = +80癈, hyst = +75癈) sensor = thermistor   
  18. temp3: +33.5癈 (high = +80癈, hyst = +75癈) sensor = thermistor   
  19. vid: +0.000 V (VRM Version 10.0)  
  20. alarms:   
  21. beep_enable:  
  22. Sound alarm enabled 

这里我们可以看到温度还没有相对应CPU,我们主要稍微修改一下/etc/sensors.conf就可以了,不过其实都不用我们自己去动手,一般我们都可以从主板生产商那里下载到配置文件。通过CentOS sensors我们就可以得到主板温度,CPU电压,风扇转速这些信息。我们可以根据这些数据来监察系统的运行情况来预防系统的问题。

接下来让它和MRTG整合在一起吧

  1. [root@securitycn ~]# cd /usr/local/mrtg/bin  
  2. [root@securitycn ~]# vi temp.sh  
  3. #内容如下  
  4. #!/bin/bash  
  5. cputemp=`/usr/bin/sensors | grep temp1 |awk '{print $2}'|cut -c 2-4` #这句是说找出有temp1那一行,印出第二个列的2-4个字  
  6. systemp =`/usr/bin/sensors | grep temp2 |awk '{print $2}'|cut -c 2-5` 不用解释了吧  
  7. echo $cputemp  
  8. echo $systemp  
  9. # the uptime  
  10. uptime | sed 's:^.* up \(.*\), [0-9][0-9]* users.*$:\1:'  
  11. # my name  
  12. uname -n 
  1. [root@securitycn ~]# chmod +x temp.sh 改成可执行  
  2. [root@securitycn ~]# ./temp.sh 试试看有没有问题  
  3. 39  
  4. 33.5  
  5. 15:36:19 up 22:28, 1 user, load average: 0.04, 0.09, 0.04  
  6. securitycn 

CentOS sensors再来写下面的文件

  1. [root@securitycn ~]# cd ../etc/  
  2. [root@securitycn ~]# vi temp.cfg  
  1. WorkDir: /data1/usr/apache/htdocs/mrtg/temp/  
  2. Target[index]: `/usr/local/mrtg/bin/temp.sh`  
  3. MaxBytes[index]:80  
  4. Options[index]: gauge, nopercent, growright  
  5. YLegend[index]: Temp (度)  
  6. ShortLegend[index]: 度  
  7. LegendO[index]: 系统温度;  
  8. LegendI[index]: CPU温度;  
  9. Title[index]: 系统温度表  
  10. PageTop[index]: 

    主机温度表

     

[root@securitycn ~]# /usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/temp.cfg执行3次就不报错了然后加入到crontab里面*/5 * * * * /usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/temp.cfgPageTop[index]:

主机温度表

【编辑推荐】

  1. CentOS FastCGI***化性能挥其性能优势
  2. CentOS RoR应用性能优化的实战经验
  3. CentOS WEB缓存服务器程序使用比较灵活
  4. CentOS Oracle测试运行使用root用户修改
  5. CentOS NTFS安装和配置支持所有符合POSIX标准的磁盘操作

相关内容

热门资讯

PHP新手之PHP入门 PHP是一种易于学习和使用的服务器端脚本语言。只需要很少的编程知识你就能使用PHP建立一个真正交互的...
网络中立的未来 网络中立性是什... 《牛津词典》中对“网络中立”的解释是“电信运营商应秉持的一种原则,即不考虑来源地提供所有内容和应用的...
各种千兆交换机的数据接口类型详... 千兆交换机有很多值得学习的地方,这里我们主要介绍各种千兆交换机的数据接口类型,作为局域网的主要连接设...
粉嫩如何诠释霸道 东芝M805... “霸道粉”是个什么玩意东芝M805拿过来的时候,笔者扑哧笑了,不是笑这款笔记本,而是笑这款产品的颜色...
什么是大数据安全 什么是大数据... 在《为什么需要大数据安全分析》一文中,我们已经阐述了一个重要观点,即:安全要素信息呈现出大数据的特征...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
全面诠释网络负载均衡 负载均衡的出现大大缓解了服务器的压力,更是有效的利用了资源,提高了效率。那么我们现在来说一下网络负载...
如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
30分钟搞定iOS自定义相机 最近公司的项目中用到了相机,由于不用系统的相机,UI给的相机切图,必须自定义才可以。就花时间简单研究...
Intel将Moblin社区控... 本周二,非营利机构Linux基金会宣布,他们将担负起Moblin社区的管理工作,而这之前,Mobli...