# config csv_file="../data/ping.csv" # space seperates list of SERVER:LABEL where SERVER is the filter for col_server server_list=" \ 127.0.0.1:my_pc \ 0.0.0.0.:still_my_pc \ localhost:my_other_local \ example.com:example \ " # timezone offset in seconds tz=0 # table setup col_time=1 col_server=2 col_packet_loss=3 col_min=4 col_average=5 col_max=6 col_deviation=7 if(exists("TZ")) tz=TZ*3600 # gnuplot does not like spaces in -e so we recreate them here via system call to sed if(exists("SERVERS")) server_list=system("echo '".SERVERS."' | sed 's|;| |g'") if(exists("CSV_FILE")) csv_file=CSV_FILE # helper function server(n) = word(server_list ,n) # csv settings set datafile separator ',' # output settings #set terminal pngcairo size 800,600 enhanced font 'Segoe UI,10' # pngcairo cleaner than png #set output 'ping.png' set encoding utf8 # data settings set xdata time # tells gnuplot the x axis is time data set timefmt "%s" # for iso 8601 use: "%Y-%m-%dT%H:%M:%S%:z" set format x "%d.%m.%y - %H:%M" set key autotitle columnhead # styling ## legend set key box lt rgb "#000000" set key width 1.5 set key height 0.5 set key samplen 0.1 set key center top ## axis set y2tics # enable second axis set ytics nomirror # dont show the tics on that side set y2range [5:100] if (exists("Y_MAX")) set yrange [*:Y_MAX] if (exists("X_MAX")) set xrange [*:X_MAX+tz] if (exists("X_MIN")) set xrange [X_MIN+tz:*] if (exists("X_MIN") && exists("X_MAX")) set xrange [X_MIN+tz:X_MAX+tz] #set format y2 "%s perc" ## labels set xlabel sprintf("Time (UTC: %+03d:00)", tz/3600) set ylabel "Latency (ms)" set y2label "Package Loss (%)" # label for second axis set xtics rotate # rotate labels on the x axis ## grid set style line 100 lt 1 lc rgb "grey" lw 0.5 # linestyle for the grid set grid ls 100 # enable grid with specific linestyle ## lines and points set style line 1 lt rgb "#1e88e5" set style line 2 lt rgb "#43a047" set style line 3 lt rgb "#d81b60" set style line 4 lt rgb "#f57c00" #plot for [server in server_list] csv_file using 1:(stringcolumn(3) eq server[1:strstrt(server, ":")-1] ? column(7) : NaN) ti server # [ping] + [packet loss] + [packet loss border] + [packet loss legend] plot for [i=1:words(server_list)] \ csv_file using (column(col_time) + tz):(stringcolumn(col_server) eq server(i)[1:strstrt(server(i), ":")-1] ? column(col_average) : NaN) \ ti server(i)[strstrt(server(i), ":")+1:*] \ ls i \ pointtype 7 ps 0.5, \ for [i=1:words(server_list)] \ csv_file using (column(col_time) + tz):(stringcolumn(col_server) eq server(i)[1:strstrt(server(i), ":")-1] ? column(col_packet_loss) : NaN) \ notitle \ axis x1y2 \ ls i lt rgb "#000000" \ pointtype 13 lw 0.5, \ for [i=1:words(server_list)] \ csv_file using (column(col_time) + tz):(stringcolumn(col_server) eq server(i)[1:strstrt(server(i), ":")-1] ? column(col_packet_loss) : NaN) \ notitle \ axis x1y2 \ ls i \ pointtype 13 ps 0.65, \ NaN with points pt 12 lc rgb "black" title "Packet Loss"