Skip to content

Instantly share code, notes, and snippets.

@mattintosh4
Last active May 22, 2017 15:28
Show Gist options
  • Save mattintosh4/aa79ee075719e42836c1e397368df9ae to your computer and use it in GitHub Desktop.
Save mattintosh4/aa79ee075719e42836c1e397368df9ae to your computer and use it in GitHub Desktop.
gnuplot
set term svg enhanced size 1280,960 background rgb "white"
set datafile separator "|"
set xdata time
set timefmt "%s"
set output "/dev/null"
plot "< sqlite3 /srv/nfs4/iperf3.sqlite3 'select * from IPERF where TIMESTAMP between strftime(\"%s\",datetime(\"now\",\"-3 days\")) and strftime(\"%s\",datetime(\"now\",\"-2 days\"));'" u ($1+9*60*60):3
x3_min = GPVAL_DATA_X_MIN
x3_max = GPVAL_DATA_X_MAX
plot "< sqlite3 /srv/nfs4/iperf3.sqlite3 'select * from IPERF where TIMESTAMP between strftime(\"%s\",datetime(\"now\",\"-2 days\")) and strftime(\"%s\",datetime(\"now\",\"-1 days\"));'" u ($1+9*60*60):3
x1_min = GPVAL_DATA_X_MIN
x1_max = GPVAL_DATA_X_MAX
plot "< sqlite3 /srv/nfs4/iperf3.sqlite3 'select * from IPERF where TIMESTAMP between strftime(\"%s\",datetime(\"now\",\"-1 days\")) and strftime(\"%s\",datetime(\"now\"));'" u ($1+9*60*60):3
x2_min = GPVAL_DATA_X_MIN
x2_max = GPVAL_DATA_X_MAX
set output "/opt/local/nginx/html/sensors/iperf3.svg"
set grid
set key font "DejaVu Serif,9"
set xtics font "DejaVu Serif,9" 10800 format "%m/%d(%a)\n%H:%M" nomirror
set ytics font "DejaVu Serif,9" format "%g Mpbs" nomirror
set cbtics font "DejaVu Serif,9"
set mxtics 6
set mytics 4
set yr [0:10]
set cbr [0:10]
set palette defined (0 "#ff0000", 1 "#00ff00")
set style data boxes
set style fill solid noborder
set multiplot layout 3, 1 title "TCP Throughput 10.0.100.x -> 10.16.0.152 (by iperf3)" font "DejaVu Serif Bold,18"
set title strftime("%Y-%m-%d %H:%M", x3_min) . " - " . \
strftime("%Y-%m-%d %H:%M", x3_max) font "DejaVu Serif Bold,14"
p [x3_min:x3_max] "< sqlite3 /srv/nfs4/iperf3.sqlite3 'select * from IPERF where TIMESTAMP between strftime(\"%s\",datetime(\"now\",\"-3 days\")) and strftime(\"%s\",datetime(\"now\",\"-2 days\"));'" \
u ($1+9*3600):($3/(2**20)):($3/(2**20)) lc palette title "Client Sent (Mbps)" \
, "" u ($1+9*3600):($3/(2**20)) smooth sbezier lc rgb "#0080ff" lw 2 title ""
set title strftime("%Y-%m-%d %H:%M", x1_min) . " - " . \
strftime("%Y-%m-%d %H:%M", x1_max) font "DejaVu Serif Bold,14"
p [x1_min:x1_max] "< sqlite3 /srv/nfs4/iperf3.sqlite3 'select * from IPERF where TIMESTAMP between strftime(\"%s\",datetime(\"now\",\"-2 days\")) and strftime(\"%s\",datetime(\"now\",\"-1 days\"));'" \
u ($1+9*3600):($3/(2**20)):($3/(2**20)) lc palette title "Client Sent (Mbps)" \
, "" u ($1+9*3600):($3/(2**20)) smooth sbezier lc rgb "#0080ff" lw 2 title ""
set title strftime("%Y-%m-%d %H:%M", x2_min) . " - " . \
strftime("%Y-%m-%d %H:%M", x2_max)
p [x2_min:x2_max] "< sqlite3 /srv/nfs4/iperf3.sqlite3 'select * from IPERF where TIMESTAMP between strftime(\"%s\",datetime(\"now\",\"-1 days\")) and strftime(\"%s\",datetime(\"now\"));'" \
u ($1+9*3600):($3/(2**20)):($3/(2**20)) lc palette title "Client Sent (Mbps)" \
, "" u ($1+9*3600):($3/(2**20)) smooth sbezier lc rgb "#0080ff" lw 2 title ""
set term svg enhanced size 1280,720 background rgb "white" font ",10"
set datafile separator ","
set xdata time
set timefmt "%s"
set output "/dev/null"
p "< echo \"\
set pages 0\n\
set lines 255\n\
set feedback off\n\
set colsep ','\n\
select \
* \
from \
iperf3 \
order by \
TIMESTAMP \
;\" | sqlplus -S scott/tiger@xe" u 1:1
x_min = GPVAL_DATA_X_MIN
x_max = GPVAL_DATA_X_MAX
set key left
set grid
set yrange [0:10]
set y2range [0:100]
set cbrange [0:10]
set xtics 3*3600 format "%m/%d(%a)\n%H:%M" nomirror
set ytics format "%g Mbps" nomirror
set y2tics format "%g Mbps" nomirror
set cbtics format "%g Mbps"
set ylabel "VPN"
set y2label "LAN"
set style data boxes
set style fill solid noborder
set output "/opt/local/nginx/html/sensors/iperf3.svg"
set palette defined (0 "#ff0000", 1 "#ffff00", 2 "#00ff00")
set multiplot layout 3, 1 title "TCP Throughput by iPerf3\n10.0.100.x -> 10.16.0.152" font ",16"
set boxwidth 0.8 relative
set title "TCP Throughput by iPerf3 192.168.1.x -> 10.16.0.152"
unset colorbox
set title strftime("%Y/%m/%d %H:%M", x_max+9*3600-86400*3) . " - " . \
strftime("%Y/%m/%d %H:%M", x_max+9*3600-86400*2) . " (2 days ago)" font ",12"
p [x_max+9*3600-86400*3:x_max+9*3600-86400*2] \
"" u ($1+9*3600):($3/(10**6)):($3/(10**6)) lc palette axis x1y1 title "HOME -> VPN (Mbps)" \
, "" u ($1+9*3600):($3/(10**6)) smooth sbezier lc rgb "#4444ff" lw 2 axis x1y1 title "VPN" \
, "" u ($1+9*3600):($7/(10**6)) smooth sbezier lc rgb "#ff3333" dt "." lw 2 axis x1y2 title "LAN"
set title strftime("%Y/%m/%d %H:%M", x_max+9*3600-86400*2) . " - " . \
strftime("%Y/%m/%d %H:%M", x_max+9*3600-86400*1) . " (1 day ago)" font ",12"
p [x_max+9*3600-86400*2:x_max+9*3600-86400*1] \
"" u ($1+9*3600):($3/(10**6)):($3/(10**6)) lc palette axis x1y1 title "HOME -> VPN (Mbps)" \
, "" u ($1+9*3600):($3/(10**6)) smooth sbezier lc rgb "#4444ff" lw 2 axis x1y1 title "VPN" \
, "" u ($1+9*3600):($7/(10**6)) smooth sbezier lc rgb "#ff3333" dt "." lw 2 axis x1y2 title "LAN"
set title strftime("%Y/%m/%d %H:%M", x_max+9*3600-86400*1) . " - " . \
strftime("%Y/%m/%d %H:%M", x_max+9*3600-86400*0) . " (Today)" font ",12"
p [x_max+9*3600-86400*1:x_max+9*3600] \
"" u ($1+9*3600):($3/(10**6)):($3/(10**6)) lc palette axis x1y1 title "HOME -> VPN (Mbps)" \
, "" u ($1+9*3600):($3/(10**6)) smooth sbezier lc rgb "#4444ff" lw 2 axis x1y1 title "VPN" \
, "" u ($1+9*3600):($7/(10**6)) smooth sbezier lc rgb "#ff3333" dt "." lw 2 axis x1y2 title "LAN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment