Compare commits
No commits in common. "4bc4fd5c07b586d0f4227d4320d195e2434f762e" and "bf1b51c6644094b6b4b857db971bd2bd9e561d23" have entirely different histories.
4bc4fd5c07
...
bf1b51c664
2 changed files with 6 additions and 18 deletions
|
@ -2,15 +2,9 @@
|
|||
|
||||
Icinga2/Nagios check program for Raspberry Pi temperature
|
||||
|
||||
## Requirements
|
||||
|
||||
- `bc` for floating point calculation
|
||||
- Adding executing user to video group: `sudo adduser nagios video`. Otherwise "VCHI initialization failed"
|
||||
|
||||
## Arguments
|
||||
|
||||
- `--warning 50`: Temperature above which the result is warning
|
||||
- `--critical 70`: Temperature above which the result is critical
|
||||
- `--fahrenheit`: All temperatures in Fahrenheit (°F)
|
||||
|
||||
|
||||
|
|
|
@ -4,12 +4,6 @@
|
|||
|
||||
echoerr() { echo "$@" 1>&2; }
|
||||
|
||||
if ! $(command -v bc); then
|
||||
echoerr Please install bc
|
||||
exit -2
|
||||
fi
|
||||
|
||||
|
||||
WARN=50
|
||||
CRIT=70
|
||||
FAHRENHEIT=false
|
||||
|
@ -18,14 +12,14 @@ while [[ $# -gt 0 ]]; do
|
|||
case $1 in
|
||||
-w|--warn|--warning)
|
||||
case "$2" in
|
||||
''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;;
|
||||
''|*[!0-9]*) echoerr "Argument for \"$1\" has to be a number";;
|
||||
esac
|
||||
WARN=$2
|
||||
shift; shift
|
||||
;;
|
||||
-c|--crit|--critical)
|
||||
case "$2" in
|
||||
''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;;
|
||||
''|*[!0-9]*) echoerr "Argument for \"$1\" has to be a number";;
|
||||
esac
|
||||
CRIT=$2
|
||||
shift; shift
|
||||
|
@ -51,7 +45,7 @@ done
|
|||
|
||||
if [ $CRIT -le $WARN ]; then
|
||||
echoerr "Critical threshold ($CRIT) has to be greater than Warning threshold ($WARN)"
|
||||
exit -3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
@ -74,10 +68,10 @@ fi
|
|||
temp=${output/temp=/}
|
||||
temp=${temp/\'C/}
|
||||
|
||||
unit="'C"
|
||||
unit="°C"
|
||||
if $FAHRENHEIT; then
|
||||
temp=$(bc <<< "scale=1; ($temp * 1.8) + 32")
|
||||
unit="'F"
|
||||
unit="°F"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -91,7 +85,7 @@ elif [ $w -eq 1 ]; then
|
|||
else
|
||||
result="OK"
|
||||
fi
|
||||
echo "$result. $temp$unit | 'temperature'=$temp;$unit;$WARN;$CRIT;-40;85"
|
||||
echo "$result | 'temperature'=$temp;$unit;$WARN;$CRIT;-40;85"
|
||||
|
||||
|
||||
case $result in
|
Loading…
Reference in a new issue