check_iperf3: update docs

This commit is contained in:
Cyberes 2023-06-26 20:06:53 -06:00
parent 668acc3b1b
commit ba92dddeec
1 changed files with 41 additions and 1 deletions

View File

@ -1,5 +1,40 @@
#!/usr/bin/env bash #!/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 <<EOF
# [Unit]
# Description=iperf3 server
# After=syslog.target network.target auditd.service
#
# [Service]
# ExecStart=/usr/bin/iperf3 -s --rsa-private-key-path /etc/iperf3/server.private.pem --authorized-users-path /etc/iperf3/users.csv
#
# [Install]
# WantedBy=multi-user.target
# EOF
#
# 10. systemctl daemon-reload
# 11. systemctl enable --now iperf3
# 12. systemctl status iperf3
# 13. Run the client
#
# Warnng and critical levels are based on your specific network speed.
# Default values # Default values
SERVER="" SERVER=""
WARNING_LEVEL="" WARNING_LEVEL=""
@ -49,6 +84,11 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
if ! command -v iperf3 &>/dev/null; then
echo "UNKNOWN - iperf3 not found! Please install iperf3"
exit -1
fi
# Check if required arguments are provided # Check if required arguments are provided
if [[ -z "$SERVER" ]] || [[ -z "$WARNING_LEVEL" ]] || [[ -z "$CRITICAL_LEVEL" ]]; then 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]" 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 # Check if iperf3 command failed
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "UNKNOWN - iperf3 command failed: $OUTPUT" echo -e "UNKNOWN - iperf3 command failed: $OUTPUT\n"
exit -1 exit -1
fi fi