zoukankan      html  css  js  c++  java
  • 利用DELL的OMSA监控服务器的温度

    利用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

    点击(此处)折叠或打开

    1. #!/bin/bash
    2. #Purpose: Monitor the classis's temperature -----cacti
    3. #Author: 飞鸿无痕
    4. #Date: 2012-09-07
    5. #define the path for the executable file
    6. TEMPPATH='/opt/dell/srvadmin/sbin'
    7. #use del omreport tool to get the classis's temperature
    8. TEMP=`$TEMPPATH/omreport chassis temps | grep "Reading" | awk '{print $3}'`
    9. 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

    点击(此处)折叠或打开

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

    6. #define the exist status
    7. STATE_OK=0
    8. STATE_WARNING=1
    9. STATE_CRITICAL=2
    10. STATE_UNKNOWN=3
    11. #define the path for the executable file
    12. TEMPPATH='/opt/dell/srvadmin/sbin'
    13. #use del omreport tool to get the classis's temperature
    14. TEMP=`$TEMPPATH/omreport chassis temps | grep "Reading" |awk -F'[ .]+' '{print $3}'`
    15. if [ $? -ne 0 ];then
    16. echo "Please Check the temperature Plugins"
    17. exit $STATE_UNKNOWN
    18. fi
    19. if [ "$TEMP" -ge 8 -a "$TEMP" -le 42 ];then
    20. echo "Check OK,The classis's temperature is: $TEMP"
    21. exit $STATE_OK
    22. elif [ "$TEMP" -ge 3 -a "$TEMP" -lt 8 -o "$TEMP" -gt 42 -a "$TEMP" -lt 47 ];then
    23. echo "Check WARNING,The classis's temperature is: $TEMP"
    24. exit $STATE_WARNING
    25. else
    26. echo "Check Critical,The classis's temperature is: $TEMP"
    27. exit $STATE_CRITICAL
    28. 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

    点击(此处)折叠或打开

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

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

    监控系统温度的cacti模板:
     cacti_graph_template_monitor_temperature.rar  
    安装和部署OMSA监控温度的脚本:
     monitor_tem.rar  

     

  • 相关阅读:
    分布式与云计算有什么区别?
    多线程学习笔记
    docker解决报错WARNING: IPv4 forwarding is disabled. Networking will not work.
    Docker问题解决:Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: no such host
    docker学习笔记
    linux命令学习
    Xftp5提示要继续使用此程序,您必须应用最新的更新的解决方案
    Springboot学习笔记
    maven学习笔记
    Spring学习笔记(6)
  • 原文地址:https://www.cnblogs.com/feihongwuhen/p/7169787.html
Copyright © 2011-2022 走看看