Last active
July 27, 2023 14:46
-
-
Save hjst/8777903 to your computer and use it in GitHub Desktop.
Generating SVG graphs from mtr reports
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
# Use a stacked column histogram | |
set style data histograms | |
set style histogram rowstacked | |
# Columns are 60% of max width (i.e. not touching, set 1.0 for touching) | |
set boxwidth 0.6 | |
# Define colours - 1:yellow 2:orange 3:red | |
unset style line | |
set style line 1 linetype 1 linecolor rgb "#ffff99" | |
set style line 2 linetype 2 linecolor rgb "#ffdb99" | |
set style line 3 linetype 3 linecolor rgb "#ff9999" | |
set style increment userstyles | |
# Use fill colours with a black border on each segment | |
set style fill solid 1.00 border lt -1 | |
# Print border/axis only on bottom & left | |
unset grid | |
set xtics nomirror out | |
set ytics nomirror | |
set border 3 | |
# Legend in top left, get column titles from input file | |
set key inside left top invert autotitles columnheader | |
set xlabel "Hops" | |
set ylabel "Response time (ms)" | |
# Uncomment next 2 lines to print SVG to standard out | |
#set terminal svg size 600,300 dynamic fname 'Source Sans Pro' fsize 12 butt solid | |
#set output | |
plot "infile" u 2:xticlabel(1), "" u 3, "" u 4 |
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/sh | |
if [ -f $1 ] | |
then | |
REPORT=$1 | |
else | |
echo "Specify an mtr report: $0 path/to/report.txt"; | |
exit 1; | |
fi | |
TMP=$(mktemp) | |
cat $REPORT | tail -n+3 \ | |
| awk 'BEGIN {print "Hop\tBest\tAverage\tWorst";} \ | |
{print NR,"\t",$7,"\t",$6,"\t",$8;}' \ | |
> $TMP | |
gnuplot << EOF | |
set style data histograms | |
set style histogram rowstacked | |
set boxwidth 0.6 | |
unset style line | |
set style line 1 linetype 1 linecolor rgb "#ffff99" | |
set style line 2 linetype 2 linecolor rgb "#ffdb99" | |
set style line 3 linetype 3 linecolor rgb "#ff9999" | |
set style increment userstyles | |
set style fill solid 1.00 border lt -1 | |
unset grid | |
set xtics nomirror out | |
set ytics nomirror | |
set border 3 | |
set key inside left top invert autotitles columnheader | |
set title "$REPORT" | |
set xlabel "Hops" | |
set ylabel "Response time (ms)" | |
set terminal svg size 650,350 dynamic fname 'Source Sans Pro' fsize 12 butt solid | |
set output | |
plot "$TMP" u 2:xticlabel(1), "" u 3, "" u 4 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment