16 Commits
v0.8 ... v0.94

Author SHA1 Message Date
52670df1be Removed /etc from whereis-path 2014-09-20 10:47:26 +02:00
fcb2be369d Merge pull request #3 from Elyrith/master
A lot of changes
2014-09-20 10:10:36 +02:00
Ryan Loudfoot
aa68be9a5a Add more acceptable paths to whereis command, as per further testing. 2014-09-06 17:46:11 -04:00
Ryan Loudfoot
615089a044 Now use whereis to find the sensors program instead of assuming a path. Also mention help in the readme if the program is not found. 2014-09-06 16:36:21 -04:00
Ryan Loudfoot
75b4a1c6d6 Run through shellcheck.net. Converted all printf to echo since it's easier, may convert back later if given good reason. 2013-11-02 13:18:46 -04:00
Ryan Loudfoot
32252b61ea Add utils.sh checking code. 2013-11-02 12:38:43 -04:00
Ryan Loudfoot
b2e2301067 Forgot to update version number last update. Fixed. 2013-11-02 12:30:25 -04:00
dc34595ff0 Merge pull request #2 from Elyrith/0.9
Fixed some typos, including one that created a bug
2013-10-06 00:51:56 -07:00
Elyrith
b8f3e6a283 Merge branches 'master' and '0.9' 2013-10-05 23:39:52 -04:00
Elyrith
6b1c3b0d95 Fix typo: If lm-sensors is not installed, it would exit with OK instead of UNKNOWN. 2013-10-05 23:39:34 -04:00
Elyrith
664cac6965 Typo and changed 'sensors' to 'lm-sensors' in message if it's not installed. 2013-10-05 23:37:59 -04:00
Elyrith
bf12a45ab9 README and THANKS updates. 2013-10-05 23:33:19 -04:00
a8382bf6c5 Added instructions for OpenSUSE 2013-06-08 14:23:39 +02:00
85be1e7ccd Merge pull request #1 from Elyrith/master
Added some instructions to install lm-sensors
2013-06-06 20:40:09 -07:00
Elyrith
c19869c89f Update repo link. 2013-06-04 17:30:16 -04:00
Elyrith
39313dffac Add help instructions and where to find them. 2013-06-04 17:27:50 -04:00
4 changed files with 70 additions and 30 deletions

View File

@@ -17,3 +17,9 @@ Version 0.8:
sensors output. On some machine you get two Core0 and two Core1 temps. sensors output. On some machine you get two Core0 and two Core1 temps.
Moved version history to it's own file, HISTORY 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.

27
README Executable file → Normal file
View File

@@ -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

0
THANKS Executable file → Normal file
View File

View File

@@ -25,21 +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="Version 0.8" VERSION="Version 0.94"
AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)" AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)"
# 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
# Check if utils.sh exists. This lets you use check_domain in a testing environment
# or outside of Nagios.
if [ -e "$PROGPATH/utils.sh" ]; then
. "$PROGPATH/utils.sh"
else
STATE_OK=0 STATE_OK=0
STATE_WARNING=1 STATE_WARNING=1
STATE_CRITICAL=2 STATE_CRITICAL=2
STATE_UNKNOWN=3 STATE_UNKNOWN=3
# STATE_DEPENDENT=4 (Commented because it's unused.)
fi
shopt -s extglob shopt -s extglob
@@ -48,15 +59,15 @@ 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:
@@ -71,9 +82,9 @@ Options:
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.
-w INTEGER -w INTEGER
Exit with WARNING status if above INTEGER degres Exit with WARNING status if above INTEGER degrees
-c INTEGER -c INTEGER
Exit with CRITICAL status if above INTEGER degres Exit with CRITICAL status if above INTEGER degrees
EOT EOT
} }
@@ -89,8 +100,8 @@ sensor=CPU
# 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
# Parse command line options # Parse command line options
@@ -115,7 +126,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
@@ -123,7 +134,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
@@ -134,7 +145,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
@@ -142,7 +153,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
@@ -157,7 +168,7 @@ while [[ -n "$1" ]]; do
--sensor) --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
@@ -166,7 +177,7 @@ while [[ -n "$1" ]]; do
;; ;;
*) *)
printf "\nInvalid option '$1'" echo "Invalid option '$1'"
print_help print_help
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
;; ;;
@@ -177,7 +188,7 @@ done
# Check if a sensor were specified # Check if a sensor were specified
if [[ -z "$sensor" ]]; then if [[ -z "$sensor" ]]; then
# No sensor to monitor were specified # No sensor to monitor were specified
printf "\nNo sensor specified" echo "No sensor specified"
print_help print_help
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
fi fi
@@ -192,12 +203,12 @@ TEMP=`${SENSORPROG} | grep "$sensor" | cut -d+ -f2 | cut -c1-2 | head -n1`
# Check if the thresholds have been set correctly # Check if the thresholds have been set correctly
if [[ -z "$thresh_warn" || -z "$thresh_crit" ]]; then if [[ -z "$thresh_warn" || -z "$thresh_crit" ]]; then
# One or both thresholds were not specified # One or both thresholds were not specified
printf "\nThreshold not set" echo "Threshold not set"
print_help print_help
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
elif [[ "$thresh_crit" -lt "$thresh_warn" ]]; then elif [[ "$thresh_crit" -lt "$thresh_warn" ]]; then
# The warning threshold must be lower than the critical threshold # The warning threshold must be lower than the critical threshold
printf "\nWarning temperature should be lower than critical" echo "Warning temperature should be lower than critical"
print_help print_help
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
fi fi
@@ -212,9 +223,8 @@ Debugging information:
Verbosity level: $verbosity Verbosity level: $verbosity
Current $sensor temperature: $TEMP Current $sensor temperature: $TEMP
__EOT __EOT
printf "\n Temperature lines directly from sensors:\n" echo "Temperature lines directly from sensors:"
${SENSORPROG} ${SENSORPROG}
printf "\n\n"
fi fi
# Get performance data for Nagios "Performance Data" field # Get performance data for Nagios "Performance Data" field
@@ -224,7 +234,7 @@ PERFDATA=`${SENSORPROG} | grep "$sensor" | head -n1`
# And finally check the temperature against our thresholds # And finally check the temperature against our thresholds
if [[ "$TEMP" != +([0-9]) ]]; then if [[ "$TEMP" != +([0-9]) ]]; then
# Temperature not found for that sensor # Temperature not found for that sensor
printf "No data found for that sensor ($sensor)\n" echo "No data found for that sensor ($sensor) | $PERFDATA"
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
elif [[ "$TEMP" -gt "$thresh_crit" ]]; then elif [[ "$TEMP" -gt "$thresh_crit" ]]; then
@@ -242,4 +252,5 @@ if [[ "$TEMP" != +([0-9]) ]]; then
echo "$sensor OK - Temperature is $TEMP | $PERFDATA" echo "$sensor OK - Temperature is $TEMP | $PERFDATA"
exit $STATE_OK exit $STATE_OK
fi fi
exit 3
exit $STATE_UNKNOWN