您的位置:首页 > 运维架构

利用DELL的OMSA监控服务器的温度

2014-01-16 18:27 381 查看
http://blog.chinaunix.net/uid-20639775-id-3341468.html服务器换机房以后就涉及到需要对服务器做完整的监控,对服务器温度的监控是一个重要的监控,由服务器的温度可以得知服务器的散热情况是否有问题以及机房的空调是否OK。比如服务器风扇坏了会导致服务器的温度升高,那么我们就可以很快地发现并解决。在网上找到一个工具lm_sensors,很多网友用这个工具来做监控,但是因为我的linux内核版本为2.6.18-194.el5,lm_sensors在该内核版本不支持我的E5504的CPU。总是报Unknown CPU model。只能升级内核版本,对于线上服务器危险系数比较高,因此只有另辟蹊径,咨询DELL的技术人员以后获悉DELL的OMSA(Dell OpenManage Server Administrator)能获得机箱的温度,OMSA是DELL提供的一组集成管理服务,可以对本地和远程的服务器进行管理和监控。接下来就来描述如何通过OMSA获取服务器的温度,并通过cacti和nagios来进行监控。1.安装和使用OMSA 6.5 (centos5.5_64bit)A.安装OMSA 6.5wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bashyum install -y srvadmin-baseyum install -y srvadmin-storageservicesB.禁用OMSA自带的snmp功能/opt/dell/srvadmin/sbin/dcecfg command=disablesnmpC.启动OMSA/opt/dell/srvadmin/sbin/srvadmin-services.sh startD.获取温度的命令/opt/dell/srvadmin/sbin/omreportchassis temps2.使用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.自动配置cacti和nagios使用OMSA监控系统温度脚本将上面的cacti和nagio监控的脚本保存到和下面的脚本在一个目录下,不要更改脚本的名字。使用下面的脚本安装完成OMSA后会自动配置cacti和nagios。
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模板:


cacti_graph_template_monitor_temperature.rar

安装和部署OMSA监控温度的脚本:


monitor_tem.rar
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nagios