diff --git a/check_iperf3.sh b/check_iperf3.sh index 40c9b83..133211a 100755 --- a/check_iperf3.sh +++ b/check_iperf3.sh @@ -1,5 +1,40 @@ #!/usr/bin/env bash +# +# This script requires an iPerf3 server. +# +# How to set up the server: +# 1. `sudo apt install iperf3` +# 2. `mkdir -p /etc/iperf3` +# 3. Set a username and password (password does not matter, we're going to use key-based authentication): `S_USER=your_username S_PASSWD=your_password` +# 4. Hash your password: `echo -n "{$S_USER}$S_PASSWD" | sha256sum | awk '{ print $1 }'` +# 5. Put the output in /etc/iperf3/users.csv like this: +# mario,bf7a49a846d44b454a5d11e7acfaf13d138bbe0b7483aa3e050879700572709b +# 6. Generate your server key: `openssl genrsa -des3 -out /etc/iperf3/iperf3_server.private.pem 2048` +# 7. Generate your public key: `openssl rsa -in /etc/iperf3/iperf3_server.private.pem -outform PEM -pubout -out /etc/iperf3/iperf3.public.pem` +# 8. Generate the key for iPerf3: `openssl rsa -in /etc/iperf3/iperf3_server.private.pem -out /etc/iperf3/iperf3_client.public.pem -outform PEM` +# 9: Create the systemd service: +# cat > /etc/systemd/system/iperf3.service </dev/null; then + echo "UNKNOWN - iperf3 not found! Please install iperf3" + exit -1 +fi + # Check if required arguments are provided if [[ -z "$SERVER" ]] || [[ -z "$WARNING_LEVEL" ]] || [[ -z "$CRITICAL_LEVEL" ]]; then echo "Usage: $0 --server SERVER --warning WARNING_LEVEL --critical CRITICAL_LEVEL [--rsa-public-key RSA_PUBLIC_KEY] [--username USERNAME] [--password PASSWORD]" @@ -67,7 +107,7 @@ fi # Check if iperf3 command failed if [[ $? -ne 0 ]]; then - echo "UNKNOWN - iperf3 command failed: $OUTPUT" + echo -e "UNKNOWN - iperf3 command failed: $OUTPUT\n" exit -1 fi