利用DELLOMSA监控服务器的温度

服务器换机房以后就涉及到需要对服务器做完整的监控,对服务器温度的监控是一个重要的监控,由服务器的温度可以得知服务器的散热情况是否有问题以及机房的空调是否OK。比如服务器风扇坏了会导致服务器的温度升高,那么我们就可以很快地发现并解决。

在网上找到一个工具lm_sensors,很多网友用这个工具来做监控,但是因为我的linux内核版本为2.6.18-194.el5lm_sensors在该内核版本不支持我的E5504CPU。总是报Unknown CPU model。只能升级内核版本,对于线上服务器危险系数比较高,因此只有另辟蹊径,咨询DELL的技术人员以后获悉DELLOMSA(Dell OpenManage Server Administrator)能获得机箱的温度,OMSADELL提供的一组集成管理服务,可以对本地和远程的服务器进行管理和监控。

接下来就来描述如何通过OMSA获取服务器的温度,并通过cactinagios来进行监控。

1.   安装和使用OMSA 6.5 (centos5.5_64bit)

A.  安装OMSA 6.5

wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash

yum install -y srvadmin-base

yum install -y srvadmin-storageservices

B.   禁用OMSA自带的snmp功能

/opt/dell/srvadmin/sbin/dcecfg command=disablesnmp

C.   启动OMSA

/opt/dell/srvadmin/sbin/srvadmin-services.sh start

D.   获取温度的命令

/opt/dell/srvadmin/sbin/omreport  chassis temps

2.   使用cacti监控系统温度

下面是使用cacti来调用OMSA监控系统温度的脚本

cat /etc/snmp/monitor_tem_cacti.sh

点击(此处)折叠或打开

  • #!/bin/bash
  • #Purpose: Monitor the classis's temperature -----cacti
  • #Author: 飞鸿无痕
  • #Date: 2012-09-07
  • #define the path for the executable file
  • TEMPPATH='/opt/dell/srvadmin/sbin'
  • #use del omreport tool to get the classis's temperature
  • TEMP=`$TEMPPATH/omreport chassis temps | grep "Reading" | awk '{print $3}'`
  • echo $TEMP
  • 脚本内容保存以后还需要更改/etc/snmp/snmpd.conf配置文件,添加如下一行:

    extend .1.3.6.1.4.1.2021.25 monitor_temperature /bin/bash /etc/snmp/monitor_tem_cacti.sh

    然后重启snmp服务

    /etc/rc.d/init.d/snmpd restart

    然后直接在cacti端添加数据模板、图形模板然后添加到主机中就可以了,附件附上自己监控的cacti图形模板。

    3.   使用Nagios监控系统温度

    下面是使用nagios调用OMSA监控系统温度的脚本

    cat /usr/local/nagios/libexec/monitor_tem_nagios.sh

    点击(此处)折叠或打开

  • #!/bin/bash
  • #Purpose: Monitor the classis's temperature -----nagios
  • #Author: 飞鸿无痕
  • #Date: 2012-09-07
  • #Status OK: the temperature greater than or equal 8 and less than or equal 42

  • #define the exist status
  • STATE_OK=0
  • STATE_WARNING=1
  • STATE_CRITICAL=2
  • STATE_UNKNOWN=3
  • #define the path for the executable file
  • TEMPPATH='/opt/dell/srvadmin/sbin'
  • #use del omreport tool to get the classis's temperature
  • TEMP=`$TEMPPATH/omreport chassis temps | grep "Reading" |awk -F'[ .]+' '{print $3}'`
  • if [ $? -ne 0 ];then
  • echo "Please Check the temperature Plugins"
  • exit $STATE_UNKNOWN
  • fi
  • if [ "$TEMP" -ge 8 -a "$TEMP" -le 42 ];then
  • echo "Check OK,The classis's temperature is: $TEMP"
  • exit $STATE_OK
  • elif [ "$TEMP" -ge 3 -a "$TEMP" -lt 8 -o "$TEMP" -gt 42 -a "$TEMP" -lt 47 ];then
  • echo "Check WARNING,The classis's temperature is: $TEMP"
  • exit $STATE_WARNING
  • else
  • echo "Check Critical,The classis's temperature is: $TEMP"
  • exit $STATE_CRITICAL
  • fi
  • 这个脚本会在系统的温度小于8度或者高于47度的时候自动通过nagios报警。设置完这个脚本还需要更改/usr/local/nagios/etc/nrpe.cfg配置文件,添加如下内容:

    command[check_temperature]=/usr/local/nagios/libexec/monitor_tem_nagios.sh

    然后在nagios服务器端添加check_temperature的监控即可。

    4.   自动配置cactinagios使用OMSA监控系统温度脚本

    将上面的cactinagio监控的脚本保存到和下面的脚本在一个目录下,不要更改脚本的名字。使用下面的脚本安装完成OMSA后会自动配置cactinagios

    cat monitor_tem_install.sh

    点击(此处)折叠或打开

  • #!/bin/bash
  • #Purpose: install Dell OpenManage Server Administrator tool(OMSA) and configure cacti and nagios client
  • #Author: 飞鸿无痕
  • #Date: 2012-09-07

  • #download the file and install
  • wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash
  • yum install -y srvadmin-base srvadmin-storageservices
  • #disable the omsa's snmp
  • /opt/dell/srvadmin/sbin/dcecfg command=disablesnmp
  • #start amsa
  • /opt/dell/srvadmin/sbin/srvadmin-services.sh start
  • #add monitor script to snmp directory
  • cp monitor_tem_cacti.sh /etc/snmp/
  • chmod +x /etc/snmp/monitor_tem_cacti.sh
  • echo "extend .1.3.6.1.4.1.2021.25 monitor_temperature /bin/bash /etc/snmp/monitor_tem_cacti.sh" >> /etc/snmp/snmpd.conf
  • /etc/rc.d/init.d/snmpd restart
  • #add monitor script to nagios directory
  • cp monitor_tem_nagios.sh /usr/local/nagios/libexec/
  • echo "command[check_temperature]=/usr/local/nagios/libexec/monitor_tem_nagios.sh" >> /usr/local/nagios/etc/nrpe.cfg
  • kill -9 $(ps -ef | grep nrpe | grep -v grep | awk '{print $2}')
  • /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

  • 监控系统温度的cacti模板:
    利用DELL的OMSA监控服务器的温度 cacti_graph_template_monitor_temperature.rar  
    安装和部署OMSA监控温度的脚本:
    利用DELL的OMSA监控服务器的温度 monitor_tem.rar  

     

    相关文章:

    • 2022-12-23
    • 2021-11-27
    • 2021-11-28
    • 2022-12-23
    • 2021-08-13
    猜你喜欢
    • 2022-01-20
    • 2021-04-11
    • 2021-11-27
    • 2022-01-18
    • 2021-08-14
    • 2021-11-07
    • 2021-09-07
    相关资源
    相似解决方案