Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2acaea98b | |||
| 41d103ab22 | |||
| c594f1768f | |||
|
|
877d08b166 | ||
|
|
0fe7e5aa90 | ||
| e9c10b3f54 | |||
|
|
6df8362ab0 | ||
| 95a7d33142 | |||
|
|
92a9b70125 | ||
|
|
7e33e13abc | ||
| 3223933494 | |||
|
|
add8a481c7 | ||
| 37b8e9db82 | |||
|
|
e4228c22e5 | ||
|
|
3c8ab0cdc2 |
19
HISTORY
Normal file
19
HISTORY
Normal file
@@ -0,0 +1,19 @@
|
||||
Version 0.2:
|
||||
Line 103, fixed the missing "-n" option (Thanks to Chad who pointed this out
|
||||
this out for me). Also added a "shopt -s extglob". (Thx to Chad)
|
||||
|
||||
Version 0.5:
|
||||
Line 168, fixed a typo (EXIT_UNKNOWN to STATE_UNKNOWN)
|
||||
|
||||
Version 0.7:
|
||||
Line 193, modified sensor parsing to cut after the first '+' since all
|
||||
positive temperatures are preceded by a '+'
|
||||
Line 211, reduced "verbosity" needed to see verbose info (was 2: -v -v)
|
||||
Line 229-232, now checks to see if no sensor data was found and
|
||||
exits with STATE_UNKNOWN
|
||||
|
||||
Version 0.8:
|
||||
Line 196 and 230, added 'head -n1' to only fetch the first result from
|
||||
sensors output. On some machine you get two Core0 and two Core1 temps.
|
||||
Moved version history to it's own file, HISTORY
|
||||
|
||||
6
README
Normal file → Executable file
6
README
Normal file → Executable file
@@ -1,13 +1,13 @@
|
||||
check_temp
|
||||
|
||||
A small Nagios plugin that checks the CPU (or M/B) temperature with lm-sensors.
|
||||
It's written in Bash and uses some sed & awk.
|
||||
Default is to check the CPU temperature but this can be changed to for example
|
||||
It's written in Bash and uses *nix "sensors" and some sed & awk.
|
||||
Default is to check the CPU temperature but this can be changed to, for example,
|
||||
the motherboard temperature with a "--sensor" argument.
|
||||
The plugin complies with the guidelines, for example uses -w -c -v arguments
|
||||
etc. It also does some basic sanity checks and has a exit 3 catchall.
|
||||
|
||||
The plugin were submitted to Nagios Exchange in 2011.
|
||||
The plugin was submitted to Nagios Exchange in 2011.
|
||||
|
||||
Known forks of check_temp:
|
||||
There is a very good Perl fork of check_temp written by Chad Columbus. It's
|
||||
|
||||
4
THANKS
Normal file → Executable file
4
THANKS
Normal file → Executable file
@@ -1,9 +1,9 @@
|
||||
check_temp THANKS file
|
||||
|
||||
check_temp was originally written by Jack-Benny Persson.
|
||||
Some kind people has been contributing by reporting problems, suggesting
|
||||
Some kind people have been contributing by reporting problems, suggesting
|
||||
improvements or submitting code.
|
||||
Here is a list of these kind people.
|
||||
|
||||
Chad Columbus ccolumbu@hotmail.com
|
||||
|
||||
Ryan Loudfoot elyrith@gmail.com
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
# #
|
||||
# Nagios plugin to monitor CPU and M/B temperature with sensors. #
|
||||
# Written in Bash (and uses sed & awk). #
|
||||
# Version 0.2: Line 98, fixed the missing "-n" option (Thanks to Chad who #
|
||||
# pointed this out for me). Also added a "shopt -s extglob". (Thx to Chad) #
|
||||
# Version 0.5: Line 162, fixed a typo (EXIT_UNKNOWN to STATE_UNKNOWN) #
|
||||
# Latest version of check_temp can be found at the below URL: #
|
||||
# https://bitbucket.org/jackbenny/check_temp #
|
||||
# #
|
||||
###############################################################################
|
||||
|
||||
VERSION="Version 0.6"
|
||||
VERSION="Version 0.8"
|
||||
AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)"
|
||||
|
||||
# Sensor program
|
||||
@@ -56,7 +56,7 @@ print_help()
|
||||
{
|
||||
print_version
|
||||
printf "$AUTHOR\n"
|
||||
printf "Monitor temperatur with the use of sensors\n"
|
||||
printf "Monitor temperature with the use of sensors\n"
|
||||
/bin/cat <<EOT
|
||||
|
||||
Options:
|
||||
@@ -184,10 +184,12 @@ fi
|
||||
|
||||
|
||||
#Get the temperature
|
||||
TEMP=`${SENSORPROG} | grep "$sensor Temp" | awk '{print $3}' | cut -c2-3`
|
||||
TEMP=`${SENSORPROG} | grep "$sensor" | cut -d+ -f2 | cut -c1-2 | head -n1`
|
||||
#Old way - Get the temperature
|
||||
#TEMP=`${SENSORPROG} | grep "$sensor" | awk '{print $3}' | cut -c2-3 | head -n1`
|
||||
|
||||
|
||||
# Check if the tresholds has been set correctly
|
||||
# Check if the thresholds have been set correctly
|
||||
if [[ -z "$thresh_warn" || -z "$thresh_crit" ]]; then
|
||||
# One or both thresholds were not specified
|
||||
printf "\nThreshold not set"
|
||||
@@ -202,7 +204,7 @@ fi
|
||||
|
||||
|
||||
# Verbose output
|
||||
if [[ "$verbosity" -ge 2 ]]; then
|
||||
if [[ "$verbosity" -ge 1 ]]; then
|
||||
/bin/cat <<__EOT
|
||||
Debugging information:
|
||||
Warning threshold: $thresh_warn
|
||||
@@ -211,25 +213,33 @@ Debugging information:
|
||||
Current $sensor temperature: $TEMP
|
||||
__EOT
|
||||
printf "\n Temperature lines directly from sensors:\n"
|
||||
${SENSORPROG} | grep "Temp"
|
||||
${SENSORPROG}
|
||||
printf "\n\n"
|
||||
fi
|
||||
|
||||
# Get performance data for Nagios "Performance Data" field
|
||||
PERFDATA=`${SENSORPROG} | grep "$sensor" | head -n1`
|
||||
|
||||
|
||||
# And finally check the temperature against our thresholds
|
||||
if [[ "$TEMP" -gt "$thresh_crit" ]]; then
|
||||
if [[ "$TEMP" != +([0-9]) ]]; then
|
||||
# Temperature not found for that sensor
|
||||
printf "No data found for that sensor ($sensor)\n"
|
||||
exit $STATE_UNKNOWN
|
||||
|
||||
elif [[ "$TEMP" -gt "$thresh_crit" ]]; then
|
||||
# Temperature is above critical threshold
|
||||
echo "$sensor CRITICAL - Temperature is $TEMP"
|
||||
echo "$sensor CRITICAL - Temperature is $TEMP | $PERFDATA"
|
||||
exit $STATE_CRITICAL
|
||||
|
||||
elif [[ "$TEMP" -gt "$thresh_warn" ]]; then
|
||||
# Temperature is above warning threshold
|
||||
echo "$sensor WARNING - Temperature is $TEMP"
|
||||
echo "$sensor WARNING - Temperature is $TEMP | $PERFDATA"
|
||||
exit $STATE_WARNING
|
||||
|
||||
else
|
||||
# Temperature is ok
|
||||
echo "$sensor OK - Temperature is $TEMP"
|
||||
echo "$sensor OK - Temperature is $TEMP | $PERFDATA"
|
||||
exit $STATE_OK
|
||||
fi
|
||||
exit 3
|
||||
|
||||
Reference in New Issue
Block a user