zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Icinga/Nagios server room temperature

May 5, 2011 by Igor Drobot 6 Comments

After I wrote the posts about your own digital temperature sensor and Nagios/Icinga Traffic-Light its time to combine the two ideas and bring some lights to switch.

We have two working independent components, with a plugin is it possible to get the sensor status. If your temperature is higher then normal you should get a signal (Warning or Critical).

Define the new check command, with name and a plugin with some arguments:

1
2
3
define command{
    command_name    check_digitemp
    command_line    check_temp_state.sh '$HOSTADDRESS

define command{ command_name check_digitemp command_line check_temp_state.sh '$HOSTADDRESS

Define a new service and your warning and critical values which will be separated by a exclamation mark:

1
2
3
4
5
6
7
8
9
define service{
    use                    generic-service
    host_name              mailserver
    service_description    Server room temperature
    check_period           24x7
    max_check_attempts     3
    contact_groups         admins
    check_command          check_digitemp!24!27
    }

define service{ use generic-service host_name mailserver service_description Server room temperature check_period 24x7 max_check_attempts 3 contact_groups admins check_command check_digitemp!24!27 }

This is actually the final plugin to check the state:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
 
DIGITEMP="/usr/bin/digitemp_DS9097"
PARAMS="-q -a -c /etc/digitemp.conf -o %C"
TEMPERATURE=`ssh -q root@$1 $DIGITEMP $PARAMS | cut -f 1 -d"."`
 
 
STATE_OK="0"
STATE_WARNING="1"
STATE_CRITICAL="2"
STATE_UNKNOWN="3"
 
result="OK"
exitstatus=$STATE_OK
 
 
if [ "$TEMPERATURE" = "" ]; then
    result="Unknown"
    exitstatus=$STATE_UNKNOWN
fi
if [ "$2" != "" ]; then
    if [ $TEMPERATURE -ge $2 ]; then
        result="Warning"
        exitstatus=$STATE_WARNING
    fi
fi
if [ "$3" != "" ]; then
    if [ $TEMPERATURE -ge $3 ]; then
        result="Critical"
        exitstatus=$STATE_CRITICAL
    fi
fi
 
echo "$result $TEMPERATURE"
exit $exitstatus

#!/bin/sh DIGITEMP="/usr/bin/digitemp_DS9097" PARAMS="-q -a -c /etc/digitemp.conf -o %C" TEMPERATURE=`ssh -q root@$1 $DIGITEMP $PARAMS | cut -f 1 -d"."` STATE_OK="0" STATE_WARNING="1" STATE_CRITICAL="2" STATE_UNKNOWN="3" result="OK" exitstatus=$STATE_OK if [ "$TEMPERATURE" = "" ]; then result="Unknown" exitstatus=$STATE_UNKNOWN fi if [ "$2" != "" ]; then if [ $TEMPERATURE -ge $2 ]; then result="Warning" exitstatus=$STATE_WARNING fi fi if [ "$3" != "" ]; then if [ $TEMPERATURE -ge $3 ]; then result="Critical" exitstatus=$STATE_CRITICAL fi fi echo "$result $TEMPERATURE" exit $exitstatus

Check result – OK:

Check result – Warning:

Check result – Critical:

1
'$ARG1

'$ARG1

Define a new service and your warning and critical values which will be separated by a exclamation mark:


This is actually the final plugin to check the state:


Check result – OK:

Check result – Warning:

Check result – Critical:

1
'$ARG2

'$ARG2

Define a new service and your warning and critical values which will be separated by a exclamation mark:


This is actually the final plugin to check the state:


Check result – OK:

Check result – Warning:

Check result – Critical:

1
}

}

Define a new service and your warning and critical values which will be separated by a exclamation mark:


This is actually the final plugin to check the state:


Check result – OK:

Check result – Warning:

Check result – Critical:

Filed Under: Bash, Debian, Linux, Monitoring Tagged With: digitemp, Icinga, Monitoring, Nagios, room temerature

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Comments

  1. Yara says

    March 27, 2014 at 15:08

    How do i test it in command line? because i am receiving the following output on my ubuntu:
    icinga@ubuntu:~$ perl /usr/lib/nagios/plugins/check_temp_state.sh -q 10 -a 10 -c 20
    /usr/lib/nagios/plugins/check_temp_state.sh: 5: /usr/lib/nagios/plugins/check_temp_state.sh: ssh -q root@$1 $DIGITEMP $PARAMS | cut -f 1 -d”.”: not found
    /usr/lib/nagios/plugins/check_temp_state.sh: 22: [: -ge: unexpected operator
    Unknown

    Thanks

  2. zeldor says

    July 25, 2012 at 16:46

    I hope you was able to run it?

  3. zeldor says

    July 24, 2012 at 11:45

    Plugin for lm_sensors:
    http://exchange.nagios.org/directory/Plugins/System-Metrics/Environmental/check_lm_sensors/

  4. Damjan says

    July 24, 2012 at 08:37

    I was searching, but didn’t find any for LM sensors for processor temperature and motherboard temperature. Do you have some link?

  5. zeldor says

    July 23, 2012 at 23:03

    Hello Damjan,

    there are already existing plugins to monitor these stuff.

  6. Damjan says

    July 23, 2012 at 15:09

    Hi. Is there possible to make this plugin to work with lm_sensors and hddtemp. So it check processor temperature and hard disk temperature. I don’t know much about programming. If you can do that it will be great.
    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok