From b8f3e6a283aafefbc88ca2a60848a5182c9e9108 Mon Sep 17 00:00:00 2001 From: Elyrith Date: Sat, 5 Oct 2013 23:39:52 -0400 Subject: [PATCH 1/6] Merge branches 'master' and '0.9' From b2e230106770f7ce72cb00ff0e4be7446cb7df87 Mon Sep 17 00:00:00 2001 From: Ryan Loudfoot Date: Sat, 2 Nov 2013 12:30:25 -0400 Subject: [PATCH 2/6] Forgot to update version number last update. Fixed. --- check_temp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_temp.sh b/check_temp.sh index 5f779a1..a9e617b 100755 --- a/check_temp.sh +++ b/check_temp.sh @@ -33,7 +33,7 @@ # # ############################################################################### -VERSION="Version 0.8" +VERSION="Version 0.9" AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)" # Sensor program From 32252b61ea66929d63f4e5fabb883ca447db9941 Mon Sep 17 00:00:00 2001 From: Ryan Loudfoot Date: Sat, 2 Nov 2013 12:38:43 -0400 Subject: [PATCH 3/6] Add utils.sh checking code. --- check_temp.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/check_temp.sh b/check_temp.sh index a9e617b..3533d45 100755 --- a/check_temp.sh +++ b/check_temp.sh @@ -33,17 +33,24 @@ # # ############################################################################### -VERSION="Version 0.9" +VERSION="Version 0.91" AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)" # Sensor program SENSORPROG=/usr/bin/sensors -# Exit codes -STATE_OK=0 -STATE_WARNING=1 -STATE_CRITICAL=2 -STATE_UNKNOWN=3 +# 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_WARNING=1 + STATE_CRITICAL=2 + STATE_UNKNOWN=3 +# STATE_DEPENDENT=4 (Commented because it's unused.) +fi shopt -s extglob From 75b4a1c6d616df9c86fa7f20cce3d39f13b039fc Mon Sep 17 00:00:00 2001 From: Ryan Loudfoot Date: Sat, 2 Nov 2013 13:18:46 -0400 Subject: [PATCH 4/6] Run through shellcheck.net. Converted all printf to echo since it's easier, may convert back later if given good reason. --- check_temp.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/check_temp.sh b/check_temp.sh index 3533d45..339daf8 100755 --- a/check_temp.sh +++ b/check_temp.sh @@ -33,7 +33,7 @@ # # ############################################################################### -VERSION="Version 0.91" +VERSION="Version 0.92" AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)" # Sensor program @@ -59,15 +59,15 @@ shopt -s extglob # Print version information print_version() { - printf "\n\n$0 - $VERSION\n" + echo "$0 - $VERSION" } #Print help information print_help() { print_version - printf "$AUTHOR\n" - printf "Monitor temperature with the use of sensors\n" + echo "$AUTHOR" + echo "Monitor temperature with the use of sensors" /bin/cat < Date: Sat, 6 Sep 2014 16:36:21 -0400 Subject: [PATCH 5/6] 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. --- check_temp.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check_temp.sh b/check_temp.sh index 339daf8..e7ec9e3 100755 --- a/check_temp.sh +++ b/check_temp.sh @@ -33,11 +33,11 @@ # # ############################################################################### -VERSION="Version 0.92" +VERSION="Version 0.93" AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)" # Sensor program -SENSORPROG=/usr/bin/sensors +SENSORPROG=$(whereis -b -B /{bin,usr,etc}/* -f sensors | awk '{print $2}') # 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 @@ -100,7 +100,7 @@ sensor=CPU # See if we have sensors program installed and can execute it if [[ ! -x "$SENSORPROG" ]]; then - echo "It appears you don't have lm-sensors installed in $SENSORPROG" + echo "It appears you don't have lm-sensors installed. You may find help in the readme for this script." exit $STATE_UNKNOWN fi From aa68be9a5a86dddc853c4cd6c211de8912699f60 Mon Sep 17 00:00:00 2001 From: Ryan Loudfoot Date: Sat, 6 Sep 2014 17:46:11 -0400 Subject: [PATCH 6/6] Add more acceptable paths to whereis command, as per further testing. --- check_temp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_temp.sh b/check_temp.sh index e7ec9e3..d6f7868 100755 --- a/check_temp.sh +++ b/check_temp.sh @@ -37,7 +37,7 @@ VERSION="Version 0.93" AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)" # Sensor program -SENSORPROG=$(whereis -b -B /{bin,usr,etc}/* -f sensors | awk '{print $2}') +SENSORPROG=$(whereis -b -B /{bin,sbin,usr,etc} /{bin,sbin,usr,etc}/* -f sensors | awk '{print $2}') # 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