summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-01 23:41:01 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-01 23:41:01 +0000
commit5d014c83b064bcbe43f035feb575f8af84ea8261 (patch)
tree8b886101cc7d7a104065c8c38e6bc4987ba89a04 /contrib
parent7085aba697d4197ec978e916fd419fa5d34200ba (diff)
-reimport from 0.8
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/visualize_stats.sh86
1 files changed, 86 insertions, 0 deletions
diff --git a/contrib/visualize_stats.sh b/contrib/visualize_stats.sh
new file mode 100755
index 000000000..87d8fc6c4
--- /dev/null
+++ b/contrib/visualize_stats.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+#
+# This script polls gnunet-stats repeatedly to create statistics plots.
+# Use 'collect' to collect statistics and 'plot' to plot whats been
+# collected. All plots will be written to $STATDIR as separate .png files.
+#
+# WARNING: calling 'collect' will delete all files in $STATDIR.
+#
+# Requires: gnuplot
+#
+# Note: gnuplot syntax has changed across versions. This
+# script perhaps will not produce color images with older gnuplots.
+# The script should work atleast with gnuplot 3.8k patchlevel 1.
+#
+
+SLEEP=120
+GNUNET=$HOME/
+STATDIR=$GNUNET/stats
+IMAGEVIEWER='display'
+TMP=/tmp/.gnuplot_error
+
+##########################################################################
+
+mkdir -p $STATDIR
+
+case "$1" in
+ collect)
+ rm -f $STATDIR/*
+
+ STARTTIME=`date +%s`
+ IFS=":"
+
+ while true; do
+ NOW=`date +%s`
+ RELAT=$[$NOW-$STARTTIME]
+ gnunet-statistics | while read KEY VALUE; do
+
+ # Collect stats of previous round
+ if [ -e "$STATDIR/$KEY.dat" ]; then
+ PREV=`tail --lines=1 "$STATDIR/$KEY.dat" | sed -e "s/.* //g"`
+ else
+ PREV=$VALUE
+ fi
+
+ # Write new stats
+ echo $RELAT $VALUE >>"$STATDIR/$KEY.dat"
+ echo $RELAT $PREV $VALUE >>"$STATDIR/$KEY.diff"
+
+ done
+ sleep $SLEEP
+ done
+ ;;
+ plot)
+ # Plot incremental
+ ls -1 $STATDIR/*.dat | while read FILENAME; do
+ BASENAME=`basename "$FILENAME" | sed -e "s/ *\..*//g"`
+ 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
+ EC=`cat $TMP | grep "empty" | grep "Warning" | wc -l`
+ if test $EC -ge 1
+ then
+ rm "$FILENAME.png"
+ fi
+ done
+
+ # Plot diff
+ ls -1 $STATDIR/*.diff | while read FILENAME; do
+ BASENAME=`basename "$FILENAME" | sed -e "s/ *\..*//g"`
+ 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
+ EC=`cat $TMP | grep "empty" | grep "Warning" | wc -l`
+ if test $EC -ge 1
+ then
+ rm "$FILENAME.png"
+ fi
+
+ done
+ ;;
+ view)
+ $IMAGEVIEWER $STATDIR/*.png
+ ;;
+ *)
+ echo $"Usage: $0 {collect|plot|view}"
+ exit 1
+
+esac
+
+