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 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 } |
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 |
1 | '$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:
1 | '$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:
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:
Yara says
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
zeldor says
I hope you was able to run it?
zeldor says
Plugin for lm_sensors:
http://exchange.nagios.org/directory/Plugins/System-Metrics/Environmental/check_lm_sensors/
Damjan says
I was searching, but didn’t find any for LM sensors for processor temperature and motherboard temperature. Do you have some link?
zeldor says
Hello Damjan,
there are already existing plugins to monitor these stuff.
Damjan says
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