sbm

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

commit 1ae573e52083826660e474d33652f1d9b4d9b4a9
parent 0d63fcc8a35813e502941643de2a7579b8091ef7
Author: sin <sin@2f30.org>
Date:   Tue Feb 23 15:00:54 +0000

Add sbm-plot-real for real time plotting

Diffstat:
Makefile | 4+++-
sbm-plot-real | 35+++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile @@ -19,17 +19,19 @@ install: all mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin cp -f sbm-plot $(DESTDIR)$(PREFIX)/bin + cp -f sbm-plot-real $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(MANPREFIX)/man1 cp -f $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1 uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN) rm -f $(DESTDIR)$(PREFIX)/bin/sbm-plot + rm -f $(DESTDIR)$(PREFIX)/bin/sbm-plot-real rm -f $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1 dist: clean mkdir -p sbm-$(VERSION) - cp LICENSE Makefile arg.h sbm-plot sbm.1 sbm.c sbm-$(VERSION) + cp LICENSE Makefile arg.h sbm-plot sbm-plot-real sbm.1 sbm.c sbm-$(VERSION) tar -cf sbm-$(VERSION).tar sbm-$(VERSION) gzip sbm-$(VERSION).tar rm -rf sbm-$(VERSION) diff --git a/sbm-plot-real b/sbm-plot-real @@ -0,0 +1,35 @@ +#!/bin/sh +# See LICENSE file for copyright and license details. + +command -v gnuplot >/dev/null || { + echo gnuplot is not installed 1>&2 + exit 1 +} + +datafile=`mktemp` +plotfile=`mktemp` +trap "rm -f $datafile $plotfile" EXIT +sbm -c 1 -d 500 -t > "$datafile" +( +cat << 'EOF' +set multiplot layout 1, 2 +set autoscale +set grid +set xlabel "time" +set ylabel "Mbps" +datafile=system("echo $DATAFILE") +plot datafile using ($1/1000/1000) with lines title "RX Mbps", \ + datafile using ($2/1000/1000) with lines title "TX Mbps" +set xlabel "time" +set ylabel "pps" +plot datafile using ($3) with lines title "RX pps", \ + datafile using ($4) with lines title "TX pps" +pause 0.50 +reread +EOF +) > "$plotfile" +DATAFILE="$datafile" gnuplot "$plotfile" & + +while :; do + sbm -c 1 -d 500 -t >> "$datafile" +done