Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
2a500f3339 | |||
56edc7a786 | |||
3c0407dc11 | |||
![]() |
1853626e49 | ||
![]() |
9a3f4cc3a9 | ||
![]() |
b504956f4f | ||
c60b88813a | |||
![]() |
b6241fd46d | ||
b618a2cc8d | |||
d166498290 | |||
![]() |
bb88a0a5af | ||
![]() |
1912395135 | ||
![]() |
8e88c82517 | ||
2286e23d19 | |||
52670df1be | |||
fcb2be369d | |||
![]() |
aa68be9a5a | ||
![]() |
615089a044 | ||
![]() |
75b4a1c6d6 | ||
![]() |
32252b61ea | ||
![]() |
b2e2301067 | ||
dc34595ff0 | |||
![]() |
b8f3e6a283 | ||
![]() |
6b1c3b0d95 | ||
![]() |
664cac6965 | ||
![]() |
bf12a45ab9 | ||
a8382bf6c5 | |||
85be1e7ccd | |||
![]() |
c19869c89f | ||
![]() |
39313dffac | ||
f2acaea98b | |||
41d103ab22 | |||
c594f1768f | |||
![]() |
877d08b166 | ||
![]() |
0fe7e5aa90 | ||
![]() |
6df8362ab0 |
46
HISTORY
Normal file
46
HISTORY
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
Version 0.94:
|
||||||
|
Lots of changes and bugfixes. A huge thank you to Ryan Loudfoot who
|
||||||
|
has fixed bugs and worked out a new way to detect the sensors-program.
|
||||||
|
In 0.94 I removed /etc from the whereis path as it didn't work for me
|
||||||
|
on my setup. It found the config-file for lm-sensors and tried to run
|
||||||
|
it.
|
||||||
|
|
||||||
|
Version 0.95:
|
||||||
|
Changed the Performance Data Field to only contain a label and the
|
||||||
|
actual value in celsius. For example, "temperature=39".
|
||||||
|
|
||||||
|
Version 1.0:
|
||||||
|
Several improvements made by Nikodimos, including:
|
||||||
|
- Added support for multiple sensors
|
||||||
|
- Enriched performance data output. For example, "CPU=34;40;55 MB=32;40;55"
|
||||||
|
- Changed (and improved) the way temperatures are retrieved
|
||||||
|
- Other fixes and touch-ups, such as the help text now shows long options
|
||||||
|
|
||||||
|
Version 1.1:
|
||||||
|
Improvements for Icinga 2, made by Onkobu
|
||||||
|
- order of arguments is irrelevant now, --sensor first ignored following -c & -w
|
||||||
|
- current sensors' multiline output needs sophisticated treatment
|
||||||
|
|
||||||
|
Version 1.2:
|
||||||
|
Improvements for Icinga 2, made by Onkobu
|
||||||
|
- Added the ability to switch between old and new style with an -n option
|
||||||
|
- Fixed multi-sensor with identical thresholds
|
27
README
27
README
@ -5,11 +5,34 @@ 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,
|
Default is to check the CPU temperature but this can be changed to, for example,
|
||||||
the motherboard temperature with a "--sensor" argument.
|
the motherboard temperature with a "--sensor" argument.
|
||||||
The plugin complies with the guidelines, for example uses -w -c -v arguments
|
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.
|
etc. It also does some basic sanity checks and has a exit 3 catch-all.
|
||||||
|
|
||||||
The plugin was submitted to Nagios Exchange in 2011.
|
The plugin was submitted to Nagios Exchange in 2011.
|
||||||
|
|
||||||
Known forks of check_temp:
|
Known forks of check_temp:
|
||||||
There is a very good Perl fork of check_temp written by Chad Columbus. It's
|
There is a very good Perl fork of check_temp written by Chad Columbus. It's
|
||||||
avalible on Nagios Exchange at
|
available on Nagios Exchange at
|
||||||
http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_temp-2Epl/details
|
http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_temp-2Epl/details
|
||||||
|
|
||||||
|
Required:
|
||||||
|
1) Install lm-sensors:
|
||||||
|
a) On Debian/Ubuntu... apt-get install lm-sensors
|
||||||
|
b) On OpenSUSE etc... zypper in sensors
|
||||||
|
|
||||||
|
2) Run sensors-detect:
|
||||||
|
sudo sensors-detect
|
||||||
|
|
||||||
|
Let it check for any sensors that you feel are necessary, or all. You can just
|
||||||
|
press <ENTER> to have it use the default option for each check. There is a
|
||||||
|
warning in the manpages (man sensors-detect) that there are (some rare)
|
||||||
|
hardware sensors that may lock up or even be permanently damaged, so be aware
|
||||||
|
of that.
|
||||||
|
|
||||||
|
**********
|
||||||
|
MAKE SURE YOU TYPE "YES" TO THE LAST OPTION: "Do you want to add these lines automatically to /etc/modules? (yes/NO)"
|
||||||
|
**********
|
||||||
|
|
||||||
|
3) Restart module-init-tools service (On Debian/Ubuntu)
|
||||||
|
a) /etc/init.d/module-init-tools restart
|
||||||
|
or
|
||||||
|
b) service module-init-tools restart
|
||||||
|
7
THANKS
7
THANKS
@ -5,5 +5,8 @@ Some kind people have been contributing by reporting problems, suggesting
|
|||||||
improvements or submitting code.
|
improvements or submitting code.
|
||||||
Here is a list of these kind people.
|
Here is a list of these kind people.
|
||||||
|
|
||||||
Chad Columbus ccolumbu@hotmail.com
|
Chad Columbus ccolumbu@hotmail.com
|
||||||
Ryan Loudfoot elyrith@gmail.com
|
Ryan Loudfoot elyrith@gmail.com
|
||||||
|
Nikodimos kikniknik on Github
|
||||||
|
Shakalandy shakalandy on Github
|
||||||
|
Onkobu Tanaake onkobu on Github
|
||||||
|
267
check_temp.sh
267
check_temp.sh
@ -25,30 +25,32 @@
|
|||||||
# Nagios plugin to monitor CPU and M/B temperature with sensors. #
|
# Nagios plugin to monitor CPU and M/B temperature with sensors. #
|
||||||
# Written in Bash (and uses sed & awk). #
|
# Written in Bash (and uses sed & awk). #
|
||||||
# Latest version of check_temp can be found at the below URL: #
|
# Latest version of check_temp can be found at the below URL: #
|
||||||
# https://bitbucket.org/jackbenny/check_temp #
|
# https://github.com/jackbenny/check_temp #
|
||||||
|
# #
|
||||||
|
# If you are having problems getting it to work, check the instructions in #
|
||||||
|
# the README first. It walks you though install lm-sensors and getting it to #
|
||||||
|
# display sensor data. #
|
||||||
# #
|
# #
|
||||||
# Version 0.2: Line 103, 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 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="Version 0.7"
|
VERSION="Version 1.2"
|
||||||
AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)"
|
AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se), (c) 2020 Onkobu Tanaake (oss@onkobutanaake.de)"
|
||||||
|
|
||||||
# Sensor program
|
# Sensor program
|
||||||
SENSORPROG=/usr/bin/sensors
|
SENSORPROG=$(whereis -b -B /{bin,sbin,usr} /{bin,sbin,usr}/* -f sensors | awk '{print $2}')
|
||||||
|
|
||||||
# Exit codes
|
# Ryan's note: utils.sh is installed with nagios-plugins in with the plugins
|
||||||
STATE_OK=0
|
# Check if utils.sh exists. This lets you use check_domain in a testing environment
|
||||||
STATE_WARNING=1
|
# or outside of Nagios.
|
||||||
STATE_CRITICAL=2
|
if [ -e "$PROGPATH/utils.sh" ]; then
|
||||||
STATE_UNKNOWN=3
|
. "$PROGPATH/utils.sh"
|
||||||
|
else
|
||||||
|
STATE_OK=0
|
||||||
|
STATE_WARNING=1
|
||||||
|
STATE_CRITICAL=2
|
||||||
|
STATE_UNKNOWN=3
|
||||||
|
# STATE_DEPENDENT=4 (Commented because it's unused.)
|
||||||
|
fi
|
||||||
|
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
|
|
||||||
@ -57,32 +59,42 @@ shopt -s extglob
|
|||||||
# Print version information
|
# Print version information
|
||||||
print_version()
|
print_version()
|
||||||
{
|
{
|
||||||
printf "\n\n$0 - $VERSION\n"
|
echo "$0 - $VERSION"
|
||||||
}
|
}
|
||||||
|
|
||||||
#Print help information
|
#Print help information
|
||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
print_version
|
print_version
|
||||||
printf "$AUTHOR\n"
|
echo "$AUTHOR"
|
||||||
printf "Monitor temperature with the use of sensors\n"
|
echo "Monitor temperature with the use of sensors"
|
||||||
/bin/cat <<EOT
|
/bin/cat <<EOT
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h
|
-h, --help
|
||||||
Print detailed help screen
|
Print detailed help screen
|
||||||
-V
|
-V, --version
|
||||||
Print version information
|
Print version information
|
||||||
-v
|
-v, --verbose
|
||||||
Verbose output
|
Verbose output
|
||||||
|
|
||||||
--sensor WORD
|
-s, --sensor <WORD[,DISPLAY_NAME]>
|
||||||
Set what to monitor, for example CPU or MB (or M/B). Check sensors for the
|
Set what to monitor, for example CPU or MB (or M/B). Check sensors for the
|
||||||
correct word. Default is CPU.
|
correct word. Default is CPU. A different display name can be used in output,
|
||||||
-w INTEGER
|
by adding it next to sensor with a comma.
|
||||||
Exit with WARNING status if above INTEGER degres
|
It can be used more than once, with different warning/critical thresholds optionally.
|
||||||
-c INTEGER
|
-w, --warning <INTEGER>
|
||||||
Exit with CRITICAL status if above INTEGER degres
|
Exit with WARNING status if above INTEGER degrees
|
||||||
|
-c, --critical <INTEGER>
|
||||||
|
Exit with CRITICAL status if above INTEGER degrees
|
||||||
|
Warning and critical thresholds must be provided before the corresponding --sensor option.
|
||||||
|
-n
|
||||||
|
Use the new sed based filter in case classic filter yields no temperature.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
./check_temp.sh [-n] -w 65 -c 75 --sensor CPU
|
||||||
|
./check_temp.sh [-n] -w 65 -c 75 --sensor CPU --sensor temp1
|
||||||
|
./check_temp.sh [-n] -w 65 -c 75 --sensor CPU -w 75 -c 85 --sensor temp1,GPU
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,14 +106,92 @@ thresh_warn=
|
|||||||
# Critical threshold
|
# Critical threshold
|
||||||
thresh_crit=
|
thresh_crit=
|
||||||
# Hardware to monitor
|
# Hardware to monitor
|
||||||
sensor=CPU
|
default_sensor="CPU"
|
||||||
|
sensor_declared=false
|
||||||
|
|
||||||
|
STATE=$STATE_OK
|
||||||
|
|
||||||
# See if we have sensors program installed and can execute it
|
# See if we have sensors program installed and can execute it
|
||||||
if [[ ! -x "$SENSORPROG" ]]; then
|
if [[ ! -x "$SENSORPROG" ]]; then
|
||||||
printf "\nIt appears you don't have sensors installed in $SENSORPROG\n"
|
echo "It appears you don't have lm-sensors installed. You may find help in the readme for this script."
|
||||||
exit $STATE_UNKOWN
|
exit $STATE_UNKNOWN
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function set_state {
|
||||||
|
[[ "$STATE" -lt "$1" ]] && STATE=$1
|
||||||
|
}
|
||||||
|
|
||||||
|
function process_sensor {
|
||||||
|
sensor=$(echo $1 | cut -d, -f1)
|
||||||
|
sensor_display=$(echo $1 | cut -d, -f2)
|
||||||
|
# Check if a sensor were specified
|
||||||
|
if [[ -z "$sensor" ]]; then
|
||||||
|
# No sensor to monitor were specified
|
||||||
|
echo "No sensor specified"
|
||||||
|
print_help
|
||||||
|
exit $STATE_UNKNOWN
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the thresholds have been set correctly
|
||||||
|
if [[ -z "$thresh_warn" || -z "$thresh_crit" ]]; then
|
||||||
|
# One or both thresholds were not specified
|
||||||
|
echo "Threshold not set"
|
||||||
|
print_help
|
||||||
|
exit $STATE_UNKNOWN
|
||||||
|
elif [[ "$thresh_crit" -lt "$thresh_warn" ]]; then
|
||||||
|
# The warning threshold must be lower than the critical threshold
|
||||||
|
echo "Warning temperature should be lower than critical"
|
||||||
|
print_help
|
||||||
|
exit $STATE_UNKNOWN
|
||||||
|
fi
|
||||||
|
# Get the temperature
|
||||||
|
# Grep the first float with a plus sign and keep only the integer
|
||||||
|
if [ $CLASSIC_FILTER -eq 1 ]; then
|
||||||
|
WHOLE_TEMP=$(${SENSORPROG} | grep "$sensor" | head -n1 | grep -o "+[0-9]\+\(\.[0-9]\+\)\?[^ \t,()]*" | head -n1)
|
||||||
|
else
|
||||||
|
WHOLE_TEMP=$(${SENSORPROG} -A "$sensor" | sed -n '2 p' | grep -o "+[0-9]\+\(\.[0-9]\+\)\?[^ \t,()]*" | head -n1)
|
||||||
|
fi
|
||||||
|
TEMPF=$(echo "$WHOLE_TEMP" | grep -o "[0-9]\+\(\.[0-9]\+\)\?")
|
||||||
|
TEMP=$(echo "$TEMPF" | cut -d. -f1)
|
||||||
|
|
||||||
|
# Verbose output
|
||||||
|
if [[ "$verbosity" -ge 1 ]]; then
|
||||||
|
/bin/cat <<__EOT
|
||||||
|
Debugging information:
|
||||||
|
Warning threshold: $thresh_warn
|
||||||
|
Critical threshold: $thresh_crit
|
||||||
|
Verbosity level: $verbosity
|
||||||
|
Current $sensor temperature: $TEMP
|
||||||
|
__EOT
|
||||||
|
echo "Temperature lines directly from sensors:"
|
||||||
|
${SENSORPROG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get performance data for Nagios "Performance Data" field
|
||||||
|
PERFDATA="$PERFDATA $sensor_display=$TEMP;$thresh_warn;$thresh_crit"
|
||||||
|
|
||||||
|
# And finally check the temperature against our thresholds
|
||||||
|
if [[ "$TEMP" != +([0-9]) ]]; then
|
||||||
|
# Temperature not found for that sensor
|
||||||
|
OUTPUT_TEXT="$OUTPUT_TEXT, No data found for sensor ($sensor)"
|
||||||
|
set_state $STATE_UNKNOWN
|
||||||
|
elif [[ "$TEMP" -gt "$thresh_crit" ]]; then
|
||||||
|
# Temperature is above critical threshold
|
||||||
|
OUTPUT_TEXT="$OUTPUT_TEXT, $sensor_display has temperature: $WHOLE_TEMP"
|
||||||
|
set_state $STATE_CRITICAL
|
||||||
|
elif [[ "$TEMP" -gt "$thresh_warn" ]]; then
|
||||||
|
# Temperature is above warning threshold
|
||||||
|
OUTPUT_TEXT="$OUTPUT_TEXT, $sensor_display has temperature: $WHOLE_TEMP"
|
||||||
|
set_state $STATE_WARNING
|
||||||
|
else
|
||||||
|
# Temperature is ok
|
||||||
|
OUTPUT_TEXT="$OUTPUT_TEXT, $sensor_display has temperature: $WHOLE_TEMP"
|
||||||
|
set_state $STATE_OK
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASSIC_FILTER=1
|
||||||
|
|
||||||
# Parse command line options
|
# Parse command line options
|
||||||
while [[ -n "$1" ]]; do
|
while [[ -n "$1" ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -124,7 +214,7 @@ while [[ -n "$1" ]]; do
|
|||||||
-w | --warning)
|
-w | --warning)
|
||||||
if [[ -z "$2" ]]; then
|
if [[ -z "$2" ]]; then
|
||||||
# Threshold not provided
|
# Threshold not provided
|
||||||
printf "\nOption $1 requires an argument"
|
echo "Option $1 requires an argument"
|
||||||
print_help
|
print_help
|
||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
elif [[ "$2" = +([0-9]) ]]; then
|
elif [[ "$2" = +([0-9]) ]]; then
|
||||||
@ -132,7 +222,7 @@ while [[ -n "$1" ]]; do
|
|||||||
thresh=$2
|
thresh=$2
|
||||||
else
|
else
|
||||||
# Threshold is not an integer
|
# Threshold is not an integer
|
||||||
printf "\nThreshold must be an integer"
|
echo "Threshold must be an integer"
|
||||||
print_help
|
print_help
|
||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
fi
|
fi
|
||||||
@ -143,7 +233,7 @@ while [[ -n "$1" ]]; do
|
|||||||
-c | --critical)
|
-c | --critical)
|
||||||
if [[ -z "$2" ]]; then
|
if [[ -z "$2" ]]; then
|
||||||
# Threshold not provided
|
# Threshold not provided
|
||||||
printf "\nOption '$1' requires an argument"
|
echo "Option '$1' requires an argument"
|
||||||
print_help
|
print_help
|
||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
elif [[ "$2" = +([0-9]) ]]; then
|
elif [[ "$2" = +([0-9]) ]]; then
|
||||||
@ -151,7 +241,7 @@ while [[ -n "$1" ]]; do
|
|||||||
thresh=$2
|
thresh=$2
|
||||||
else
|
else
|
||||||
# Threshold is not an integer
|
# Threshold is not an integer
|
||||||
printf "\nThreshold must be an integer"
|
echo "Threshold must be an integer"
|
||||||
print_help
|
print_help
|
||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
fi
|
fi
|
||||||
@ -159,94 +249,47 @@ while [[ -n "$1" ]]; do
|
|||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-\?)
|
-s | --sensor)
|
||||||
print_help
|
|
||||||
exit $STATE_OK
|
|
||||||
;;
|
|
||||||
|
|
||||||
--sensor)
|
|
||||||
if [[ -z "$2" ]]; then
|
if [[ -z "$2" ]]; then
|
||||||
printf "\nOption $1 requires an argument"
|
echo "Option $1 requires an argument"
|
||||||
print_help
|
print_help
|
||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
fi
|
fi
|
||||||
sensor=$2
|
sensor_declared=true
|
||||||
|
sensors_to_check="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
-n | --new-filter)
|
||||||
|
CLASSIC_FILTER=0
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
printf "\nInvalid option '$1'"
|
echo "Invalid option '$1'"
|
||||||
print_help
|
print_help
|
||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# argument order is irrelevant, Icinga2 gives no guarantees
|
||||||
|
# as soon as there are enough output is generated
|
||||||
|
if [ ! -z "$thresh_warn" ] && [ ! -z "$thresh_crit" ] && [ ! -z "$sensors_to_check" -o $# -eq 0 ]; then
|
||||||
|
if [ "$sensor_declared" = false ]; then
|
||||||
|
process_sensor "$default_sensor"
|
||||||
|
else
|
||||||
|
process_sensor "$sensors_to_check"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Check if a sensor were specified
|
case "$STATE" in
|
||||||
if [[ -z "$sensor" ]]; then
|
"$STATE_OK") STATE_TEXT="OK" ;;
|
||||||
# No sensor to monitor were specified
|
"$STATE_WARNING") STATE_TEXT="WARNING" ;;
|
||||||
printf "\nNo sensor specified"
|
"$STATE_CRITICAL") STATE_TEXT="CRITICAL" ;;
|
||||||
print_help
|
"$STATE_UNKNOWN") STATE_TEXT="UNKNOWN" ;;
|
||||||
exit $STATE_UNKNOWN
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
|
OUTPUT_TEXT=$(echo $OUTPUT_TEXT | sed -e 's/, //')
|
||||||
#Get the temperature
|
echo "TEMPERATURE $STATE_TEXT - $OUTPUT_TEXT |$PERFDATA"
|
||||||
TEMP=`${SENSORPROG} | grep "$sensor" | cut -d+ -f2 | cut -c1-2 `
|
exit $STATE
|
||||||
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
print_help
|
|
||||||
exit $STATE_UNKNOWN
|
|
||||||
elif [[ "$thresh_crit" -lt "$thresh_warn" ]]; then
|
|
||||||
# The warning threshold must be lower than the critical threshold
|
|
||||||
printf "\nWarning temperature should be lower than critical"
|
|
||||||
print_help
|
|
||||||
exit $STATE_UNKNOWN
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Verbose output
|
|
||||||
if [[ "$verbosity" -ge 1 ]]; then
|
|
||||||
/bin/cat <<__EOT
|
|
||||||
Debugging information:
|
|
||||||
Warning threshold: $thresh_warn
|
|
||||||
Critical threshold: $thresh_crit
|
|
||||||
Verbosity level: $verbosity
|
|
||||||
Current $sensor temperature: $TEMP
|
|
||||||
__EOT
|
|
||||||
printf "\n Temperature lines directly from sensors:\n"
|
|
||||||
${SENSORPROG}
|
|
||||||
printf "\n\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get performance data for Nagios "Performance Data" field
|
|
||||||
PERFDATA=`${SENSORPROG} | grep "$sensor"`
|
|
||||||
|
|
||||||
|
|
||||||
# And finally check the temperature against our thresholds
|
|
||||||
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 | $PERFDATA"
|
|
||||||
exit $STATE_CRITICAL
|
|
||||||
|
|
||||||
elif [[ "$TEMP" -gt "$thresh_warn" ]]; then
|
|
||||||
# Temperature is above warning threshold
|
|
||||||
echo "$sensor WARNING - Temperature is $TEMP | $PERFDATA"
|
|
||||||
exit $STATE_WARNING
|
|
||||||
|
|
||||||
else
|
|
||||||
# Temperature is ok
|
|
||||||
echo "$sensor OK - Temperature is $TEMP | $PERFDATA"
|
|
||||||
exit $STATE_OK
|
|
||||||
fi
|
|
||||||
exit 3
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user