Added check for bc
This commit is contained in:
parent
bf1b51c664
commit
662d6622cc
2 changed files with 15 additions and 3 deletions
|
@ -2,9 +2,15 @@
|
||||||
|
|
||||||
Icinga2/Nagios check program for Raspberry Pi temperature
|
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
|
## Arguments
|
||||||
|
|
||||||
- `--warning 50`: Temperature above which the result is warning
|
- `--warning 50`: Temperature above which the result is warning
|
||||||
- `--critical 70`: Temperature above which the result is critical
|
- `--critical 70`: Temperature above which the result is critical
|
||||||
- `--fahrenheit`: All temperatures in Fahrenheit (°F)
|
- `--fahrenheit`: All temperatures in Fahrenheit (°F)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
echoerr() { echo "$@" 1>&2; }
|
echoerr() { echo "$@" 1>&2; }
|
||||||
|
|
||||||
|
if ! $(command -v bc); then
|
||||||
|
echoerr Please install bc
|
||||||
|
exit -2
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
WARN=50
|
WARN=50
|
||||||
CRIT=70
|
CRIT=70
|
||||||
FAHRENHEIT=false
|
FAHRENHEIT=false
|
||||||
|
@ -12,14 +18,14 @@ while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-w|--warn|--warning)
|
-w|--warn|--warning)
|
||||||
case "$2" in
|
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
|
esac
|
||||||
WARN=$2
|
WARN=$2
|
||||||
shift; shift
|
shift; shift
|
||||||
;;
|
;;
|
||||||
-c|--crit|--critical)
|
-c|--crit|--critical)
|
||||||
case "$2" in
|
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
|
esac
|
||||||
CRIT=$2
|
CRIT=$2
|
||||||
shift; shift
|
shift; shift
|
||||||
|
@ -45,7 +51,7 @@ done
|
||||||
|
|
||||||
if [ $CRIT -le $WARN ]; then
|
if [ $CRIT -le $WARN ]; then
|
||||||
echoerr "Critical threshold ($CRIT) has to be greater than Warning threshold ($WARN)"
|
echoerr "Critical threshold ($CRIT) has to be greater than Warning threshold ($WARN)"
|
||||||
exit 1
|
exit -3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue