Initial commit: homelab configuration and documentation
This commit is contained in:
80
scripts/network_performance_test.sh
Executable file
80
scripts/network_performance_test.sh
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
# network_performance_test.sh - Test network performance between nodes
|
||||
# This script uses iperf3 to measure bandwidth between homelab nodes
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Node IPs
|
||||
NODES=(
|
||||
"192.168.1.81:Ryzen"
|
||||
"192.168.1.57:Proxmox"
|
||||
"192.168.1.196:Manager"
|
||||
"192.168.1.245:Pi4"
|
||||
"192.168.1.62:PiZero"
|
||||
)
|
||||
|
||||
echo "========================================="
|
||||
echo "Network Performance Testing"
|
||||
echo "========================================="
|
||||
|
||||
# Check if iperf3 is installed
|
||||
if ! command -v iperf3 >/dev/null 2>&1; then
|
||||
echo "Installing iperf3..."
|
||||
sudo apt-get update && sudo apt-get install -y iperf3
|
||||
fi
|
||||
|
||||
# Get current node IP
|
||||
CURRENT_IP=$(hostname -I | awk '{print $1}')
|
||||
echo -e "\nTesting from: $CURRENT_IP\n"
|
||||
|
||||
test_node() {
|
||||
local NODE_INFO=$1
|
||||
local IP=$(echo $NODE_INFO | cut -d: -f1)
|
||||
local NAME=$(echo $NODE_INFO | cut -d: -f2)
|
||||
|
||||
if [[ "$IP" == "$CURRENT_IP" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}Testing to $NAME ($IP)...${NC}"
|
||||
|
||||
# Test if iperf3 server is running
|
||||
if timeout 2 nc -z $IP 5201 2>/dev/null; then
|
||||
# Run bandwidth test
|
||||
RESULT=$(iperf3 -c $IP -t 5 -f M 2>/dev/null | grep "receiver" | awk '{print $7, $8}')
|
||||
if [[ -n "$RESULT" ]]; then
|
||||
echo -e "${GREEN} → Bandwidth: $RESULT${NC}"
|
||||
else
|
||||
echo " → Test failed (server may be busy)"
|
||||
fi
|
||||
else
|
||||
echo " → iperf3 server not running on $NAME"
|
||||
echo " → Run on $NAME: iperf3 -s -D"
|
||||
fi
|
||||
}
|
||||
|
||||
# Test all nodes
|
||||
for NODE in "${NODES[@]}"; do
|
||||
test_node "$NODE"
|
||||
done
|
||||
|
||||
echo -e "\n========================================="
|
||||
echo "Test complete"
|
||||
echo "=========================================
|
||||
"
|
||||
|
||||
# Recommendations
|
||||
echo -e "\nRecommendations:"
|
||||
echo "• Expected speeds:"
|
||||
echo " - Ryzen/Proxmox: 2.5 Gb (2500 Mbits/sec)"
|
||||
echo " - Pi 4: 1 Gb (1000 Mbits/sec)"
|
||||
echo " - Pi Zero: 100 Mb (100 Mbits/sec)"
|
||||
echo "• If speeds are lower, check:"
|
||||
echo " - Switch port configuration"
|
||||
echo " - Cable quality (Cat6 for 2.5Gb)"
|
||||
echo " - Network interface settings"
|
||||
Reference in New Issue
Block a user