sbm

simple bandwidth monitor
git clone git://git.2f30.org/sbm
Log | Files | Refs | LICENSE

sbm-rt-plot (778B)


      1 #!/bin/sh
      2 # See LICENSE file for copyright and license details.
      3 
      4 command -v gnuplot >/dev/null || {
      5 	echo gnuplot is not installed 1>&2
      6 	exit 1
      7 }
      8 
      9 datafile=`mktemp`
     10 plotfile=`mktemp`
     11 trap "rm -f $datafile $plotfile" EXIT
     12 sbm -c 1 -t > "$datafile"
     13 (
     14 cat << 'EOF'
     15 set multiplot layout 1, 2
     16 set autoscale
     17 set grid
     18 set xlabel "time / s"
     19 set ylabel "Mbps"
     20 datafile=system("echo $DATAFILE")
     21 plot datafile using ($1/1000/1000) with lines title "Rx", \
     22      datafile using ($2/1000/1000) with lines title "Tx"
     23 set xlabel "time / s"
     24 set ylabel "pps"
     25 plot datafile using ($3) with lines title "Rx", \
     26      datafile using ($4) with lines title "Tx"
     27 unset multiplot
     28 pause 1
     29 reread
     30 EOF
     31 ) > "$plotfile"
     32 DATAFILE="$datafile" gnuplot "$plotfile" &
     33 
     34 while :; do
     35 	sbm -c 1 -t >> "$datafile"
     36 done