diff --git a/README.md b/README.md index 3f2146a..edb1723 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ Icinga2/Nagios check program for Raspberry Pi temperature +## Requirements + +- `bc` for floating point calculation +- Adding executing user to video group: `sudo adduser nagios video` + ## 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) + diff --git a/check_rpi_temp.sh b/check_rpi_temperature.sh similarity index 87% rename from check_rpi_temp.sh rename to check_rpi_temperature.sh index 18c9b7e..d30df3f 100755 --- a/check_rpi_temp.sh +++ b/check_rpi_temperature.sh @@ -4,6 +4,12 @@ echoerr() { echo "$@" 1>&2; } +if ! $(command -v bc); then + echoerr Please install bc + exit -2 +fi + + WARN=50 CRIT=70 FAHRENHEIT=false @@ -12,14 +18,14 @@ while [[ $# -gt 0 ]]; do case $1 in -w|--warn|--warning) case "$2" in - ''|*[!0-9]*) echoerr "Argument for \"$1\" has to be a number";; + ''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;; esac WARN=$2 shift; shift ;; -c|--crit|--critical) case "$2" in - ''|*[!0-9]*) echoerr "Argument for \"$1\" has to be a number";; + ''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;; esac CRIT=$2 shift; shift @@ -45,7 +51,7 @@ done if [ $CRIT -le $WARN ]; then echoerr "Critical threshold ($CRIT) has to be greater than Warning threshold ($WARN)" - exit 1 + exit -3 fi