sbm

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

sbm-plot (809B)


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