mirror of
https://github.com/larsen0815/check_rasp_temp.git
synced 2024-11-24 03:13:50 +01:00
Possibility to check for low temperatures
This commit is contained in:
parent
43a7d5b638
commit
1fff8f14c4
@ -12,10 +12,11 @@ usage() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: check_rasp_temp [-h?] -w warning -c critical"
|
echo "Usage: check_rasp_temp [-hl?] -w warning -c critical"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -w warning threshold"
|
echo " -w warning threshold"
|
||||||
echo " -c critical threshold"
|
echo " -c critical threshold"
|
||||||
|
echo " -l check for low temperatures"
|
||||||
echo " -h, -? this help message"
|
echo " -h, -? this help message"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@ -46,11 +47,12 @@ check_prog bc
|
|||||||
|
|
||||||
|
|
||||||
# process command line options
|
# process command line options
|
||||||
while getopts "h?c:w:" opt; do
|
while getopts "hl?c:w:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
c ) CRITICAL=$OPTARG; ;;
|
c ) CRITICAL=$OPTARG; ;;
|
||||||
h | \? ) usage ; exit 3; ;;
|
h | \? ) usage ; exit 3; ;;
|
||||||
w ) WARNING=$OPTARG; ;;
|
w ) WARNING=$OPTARG; ;;
|
||||||
|
l ) LOW=true; ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
@ -79,16 +81,30 @@ fi
|
|||||||
TEMP=`$VCGENCMD measure_temp | awk -F"=" '{print $2}' | awk -F"'" '{print $1}'`
|
TEMP=`$VCGENCMD measure_temp | awk -F"=" '{print $2}' | awk -F"'" '{print $1}'`
|
||||||
PERF="temp=${TEMP};${WARNING};${CRITICAL};;"
|
PERF="temp=${TEMP};${WARNING};${CRITICAL};;"
|
||||||
|
|
||||||
COMPARISON=`echo "if($TEMP>=$CRITICAL) 1 else 0;" | bc`
|
if [ "$LOW" == true ] ; then
|
||||||
if [ $COMPARISON -eq 1 ] ; then
|
COMPARISON=`echo "if($TEMP<=$CRITICAL) 1 else 0;" | bc`
|
||||||
echo "TEMPERATURE CRITICAL: $TEMP | $PERF"
|
if [ $COMPARISON -eq 1 ] ; then
|
||||||
exit 2
|
echo "TEMPERATURE CRITICAL: $TEMP | $PERF"
|
||||||
fi
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
COMPARISON=`echo "if($TEMP>=$WARNING) 1 else 0;" | bc`
|
COMPARISON=`echo "if($TEMP<=$WARNING) 1 else 0;" | bc`
|
||||||
if [ $COMPARISON -eq 1 ] ; then
|
if [ $COMPARISON -eq 1 ] ; then
|
||||||
echo "TEMPERATURE WARNING: $TEMP | $PERF"
|
echo "TEMPERATURE WARNING: $TEMP | $PERF"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
COMPARISON=`echo "if($TEMP>=$CRITICAL) 1 else 0;" | bc`
|
||||||
|
if [ $COMPARISON -eq 1 ] ; then
|
||||||
|
echo "TEMPERATURE CRITICAL: $TEMP | $PERF"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPARISON=`echo "if($TEMP>=$WARNING) 1 else 0;" | bc`
|
||||||
|
if [ $COMPARISON -eq 1 ] ; then
|
||||||
|
echo "TEMPERATURE WARNING: $TEMP | $PERF"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "TEMPERATURE OK: $TEMP | $PERF"
|
echo "TEMPERATURE OK: $TEMP | $PERF"
|
||||||
|
Loading…
Reference in New Issue
Block a user