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

@ -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