3 # This script polls gnunet-stats repeatedly to create statistics plots.
4 # Use 'collect' to collect statistics and 'plot' to plot whats been
5 # collected. All plots will be written to $STATDIR as separate .png files.
7 # WARNING: calling 'collect' will delete all files in $STATDIR.
11 # Note: gnuplot syntax has changed across versions. This
12 # script perhaps will not produce color images with older gnuplots.
13 # The script should work atleast with gnuplot 3.8k patchlevel 1.
20 TMP=/tmp/.gnuplot_error
22 ##########################################################################
35 RELAT=$[$NOW-$STARTTIME]
36 gnunet-statistics | while read KEY VALUE; do
38 # Collect stats of previous round
39 if [ -e "$STATDIR/$KEY.dat" ]; then
40 PREV=`tail --lines=1 "$STATDIR/$KEY.dat" | sed -e "s/.* //g"`
46 echo $RELAT $VALUE >>"$STATDIR/$KEY.dat"
47 echo $RELAT $PREV $VALUE >>"$STATDIR/$KEY.diff"
55 ls -1 $STATDIR/*.dat | while read FILENAME; do
56 BASENAME=`basename "$FILENAME" | sed -e "s/ *\..*//g"`
57 echo "set terminal png;set output '$FILENAME.png';set title '$BASENAME - incr';plot '$FILENAME' using (\$1/60):(\$2) title '' with lines;" | nice gnuplot 2> $TMP
58 EC=`cat $TMP | grep "empty" | grep "Warning" | wc -l`
66 ls -1 $STATDIR/*.diff | while read FILENAME; do
67 BASENAME=`basename "$FILENAME" | sed -e "s/ *\..*//g"`
68 echo "set terminal png;set output '$FILENAME.png';set title '$BASENAME - diff';plot '$FILENAME' using (\$1/60):(\$3-\$2) title '' with lines;" | nice gnuplot 2> $TMP
69 EC=`cat $TMP | grep "empty" | grep "Warning" | wc -l`
78 $IMAGEVIEWER $STATDIR/*.png
81 echo $"Usage: $0 {collect|plot|view}"