CentOS nagios monitoring data center temperature
In the IDC of your company, the air conditioner is badly used, and there is no linkage, no power-on and self-starting. Experienced the circuit switching locks at night. When you know it, it's just a boiler room.
This method uses the Switch Temperature to determine whether the air conditioner is powered off.
1. temperature value of the secondary CT interactive login Switch
[root@nagios opt]# cat 123.exp#!/usr/bin/expect -fset user userset passwd passwordspawn telnet 192.168.0.254expect "Username:"send -- "$user\r"expect "Password:"send -- "$passwd\r"expect ""send -- "dis env\r"expect ""send -- "quit\r"expect eof
2. Add a nagios monitoring script
[root@nagios opt]# cat /usr/local/nagios/libexec/check_temp#!/bin/bashexpect /opt/123.exp >/opt/123.logtemp=`awk '/hotspot/ {print $3}' /opt/123.log`STATE_OK=0STATE_WARNING=1STATE_CRITICAL=2STATE_UNKNOWN=3if [ "$#" == "4" ]then#Set variablesarg=${4}w=$2c=$4if [ $temp -ge $w -a $temp -lt $c ]thenecho "Warning :Room temperature $temp°C "exitstatus=$STATE_WARNINGelif [ $temp -ge $c ]thenecho "Critical :Room temperature $temp°C"exitstatus=$STATE_CRITICALelseecho "OK :Room temperature $temp°C."exitstatus=$STATE_OKfifiexit $exitstatus
3. Add command
[root@nagios opt]# tail -5 /usr/local/nagios/etc/objects/commands.cfg# 'check_temp' command definitiondefine command{command_name check_tempcommand_line $USER1$/check_temp -w $ARG1$ -c $ARG2$}
4. Modify nrpe. cfg
[root@nagios opt]# grep "temp" /usr/local/nagios/etc/nrpe.cfgcommand[check_temp]=/usr/local/nagios/libexec/check_temp -w 30 -c 33
5. Add a Monitoring Project
[root@nagios opt]# tail -6 /usr/local/nagios/etc/objects/localhost.cfgdefine service{use generic-servicehost_name localhostservice_description check_tempcheck_command check_nrpe!check_temp}
<A data-cke-saved-href = "http://www.xmydlinux.org/wp-content/uploads/2014/02/11.jpg" href = "http://www.xmydlinux.org/wp-content/uploads/2014/02/11.jpg" class = "cboxElement" rel = "example4" 773 "=" "style =" text-decoration: none; color: rgb (1,150,227); ">