Created
June 19, 2019 07:35
-
-
Save hughsaunders/2daab95beaabb414a27ddec9133df54b to your computer and use it in GitHub Desktop.
IPerf network performance/throughput trend plot graph script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xeu | |
# ENV Vars with defaults | |
IPERF_HOST="${IPERF_HOST:-mercury}" | |
IPERF_LOG="${IPERF_LOG:-iperf.10145.log}" | |
SPEED_CSV="${SPEED_CSV:-speed2.csv}" | |
OUTPUT_PNG="${OUTPUT_PNG:-throughput2.png}" | |
OUTPUT_SIZE="${OUTPUT_SIZE:-1000,500}" | |
INTERVAL="${INTERVAL:-60}" | |
# Constants | |
TIMEFMT="%Y-%m-%d %H:%M:%S" | |
# Plot function, requires gnuplot to be installed | |
plot(){ | |
gnuplot <<PLOT | |
set xdata time | |
set timefmt "${TIMEFMT}" | |
#set xrange ["2019-05-29 09:44":"2019-05-31 10:00"] | |
set format x "%m/%d %H:%M" | |
set datafile separator "," | |
set xlabel "Date/Time" | |
set ylabel "MBits/s" | |
set terminal png large size ${OUTPUT_SIZE} | |
set output "${OUTPUT_PNG}" | |
plot "${SPEED_CSV}" using 1:2 title "IPerf to local machine across Gigabit switch" | |
PLOT | |
} | |
# Main loop | |
while :; do | |
iperf -c ${IPERF_HOST} \ | |
|ts "${TIMEFMT}" \ | |
|tee -a ${IPERF_LOG} | |
awk '/Mbits/{print $1,$2","$9}' ${IPERF_LOG} > ${SPEED_CSV} | |
plot | |
sleep ${INTERVAL} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment