check_iperf3.sh: add perfdata

This commit is contained in:
Cyberes 2023-06-07 18:01:20 -06:00
parent 9b043801df
commit cbc7e8e9b4
Signed by: cyberes
GPG Key ID: 6B4A33836A9500FE
1 changed files with 41 additions and 38 deletions

View File

@ -13,39 +13,39 @@ while [[ $# -gt 0 ]]; do
key="$1" key="$1"
case $key in case $key in
--server) --server)
SERVER="$2" SERVER="$2"
shift shift
shift shift
;; ;;
--warning) --warning)
WARNING_LEVEL="$2" WARNING_LEVEL="$2"
shift shift
shift shift
;; ;;
--critical) --critical)
CRITICAL_LEVEL="$2" CRITICAL_LEVEL="$2"
shift shift
shift shift
;; ;;
--rsa-public-key) --rsa-public-key)
RSA_PUBLIC_KEY="$2" RSA_PUBLIC_KEY="$2"
shift shift
shift shift
;; ;;
--username) --username)
USERNAME="$2" USERNAME="$2"
shift shift
shift shift
;; ;;
--password) --password)
PASSWORD="$2" PASSWORD="$2"
shift shift
shift shift
;; ;;
*) *)
shift shift
;; ;;
esac esac
done done
@ -74,14 +74,17 @@ fi
# Extract the receiver bitrate # Extract the receiver bitrate
RECEIVER_BITRATE=$(echo "$OUTPUT" | grep -Eo '[0-9]+(\.[0-9]+)? Mbits/sec' | tail -1 | awk '{print $1}') RECEIVER_BITRATE=$(echo "$OUTPUT" | grep -Eo '[0-9]+(\.[0-9]+)? Mbits/sec' | tail -1 | awk '{print $1}')
# Prepare performance data
PERFDATA="receiver_bitrate=${RECEIVER_BITRATE}mb;${WARNING_LEVEL};${CRITICAL_LEVEL};0;"
# Check the receiver bitrate against warning and critical levels # Check the receiver bitrate against warning and critical levels
if (( $(echo "$RECEIVER_BITRATE < $CRITICAL_LEVEL" | bc -l) )); then if (($(echo "$RECEIVER_BITRATE < $CRITICAL_LEVEL" | bc -l))); then
echo "CRITICAL - Receiver Bitrate: $RECEIVER_BITRATE Mbits/sec" echo "CRITICAL - Receiver Bitrate: $RECEIVER_BITRATE Mbits/sec | $PERFDATA"
exit 2 exit 2
elif (( $(echo "$RECEIVER_BITRATE < $WARNING_LEVEL" | bc -l) )); then elif (($(echo "$RECEIVER_BITRATE < $WARNING_LEVEL" | bc -l))); then
echo "WARNING - Receiver Bitrate: $RECEIVER_BITRATE Mbits/sec" echo "WARNING - Receiver Bitrate: $RECEIVER_BITRATE Mbits/sec | $PERFDATA"
exit 1 exit 1
else else
echo "OK - Receiver Bitrate: $RECEIVER_BITRATE Mbits/sec" echo "OK - Receiver Bitrate: $RECEIVER_BITRATE Mbits/sec | $PERFDATA"
exit 0 exit 0
fi fi