diff options
Diffstat (limited to 'contrib/scripts/visualize_stats.sh')
-rwxr-xr-x | contrib/scripts/visualize_stats.sh | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/contrib/scripts/visualize_stats.sh b/contrib/scripts/visualize_stats.sh index aaa5e657b..b3404b164 100755 --- a/contrib/scripts/visualize_stats.sh +++ b/contrib/scripts/visualize_stats.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # | 2 | # |
3 | # This script polls gnunet-stats repeatedly to create statistics plots. | 3 | # This script polls gnunet-stats repeatedly to create statistics plots. |
4 | # Use 'collect' to collect statistics and 'plot' to plot whats been | 4 | # Use 'collect' to collect statistics and 'plot' to plot what has been |
5 | # collected. All plots will be written to $STATDIR as separate .png files. | 5 | # collected. All plots will be written to $STATDIR as separate .png files. |
6 | # | 6 | # |
7 | # WARNING: calling 'collect' will delete all files in $STATDIR. | 7 | # WARNING: calling 'collect' will delete all files in $STATDIR. |
@@ -10,7 +10,7 @@ | |||
10 | # | 10 | # |
11 | # Note: gnuplot syntax has changed across versions. This | 11 | # Note: gnuplot syntax has changed across versions. This |
12 | # script perhaps will not produce color images with older gnuplots. | 12 | # script perhaps will not produce color images with older gnuplots. |
13 | # The script should work atleast with gnuplot 3.8k patchlevel 1. | 13 | # The script should work at least with gnuplot 3.8k patchlevel 1. |
14 | # | 14 | # |
15 | 15 | ||
16 | SLEEP=120 | 16 | SLEEP=120 |
@@ -26,10 +26,10 @@ mkdir -p $STATDIR | |||
26 | case "$1" in | 26 | case "$1" in |
27 | collect) | 27 | collect) |
28 | rm -f $STATDIR/* | 28 | rm -f $STATDIR/* |
29 | 29 | ||
30 | STARTTIME=`date +%s` | 30 | STARTTIME=`date +%s` |
31 | IFS=":" | 31 | IFS=":" |
32 | 32 | ||
33 | while true; do | 33 | while true; do |
34 | NOW=`date +%s` | 34 | NOW=`date +%s` |
35 | RELAT=$[$NOW-$STARTTIME] | 35 | RELAT=$[$NOW-$STARTTIME] |
@@ -45,7 +45,7 @@ case "$1" in | |||
45 | # Write new stats | 45 | # Write new stats |
46 | echo $RELAT $VALUE >>"$STATDIR/$KEY.dat" | 46 | echo $RELAT $VALUE >>"$STATDIR/$KEY.dat" |
47 | echo $RELAT $PREV $VALUE >>"$STATDIR/$KEY.diff" | 47 | echo $RELAT $PREV $VALUE >>"$STATDIR/$KEY.diff" |
48 | 48 | ||
49 | done | 49 | done |
50 | sleep $SLEEP | 50 | sleep $SLEEP |
51 | done | 51 | done |
@@ -61,13 +61,13 @@ case "$1" in | |||
61 | rm "$FILENAME.png" | 61 | rm "$FILENAME.png" |
62 | fi | 62 | fi |
63 | done | 63 | done |
64 | 64 | ||
65 | # Plot diff | 65 | # Plot diff |
66 | ls -1 $STATDIR/*.diff | while read FILENAME; do | 66 | ls -1 $STATDIR/*.diff | while read FILENAME; do |
67 | BASENAME=`basename "$FILENAME" | sed -e "s/ *\..*//g"` | 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 | 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` | 69 | EC=`cat $TMP | grep "empty" | grep "Warning" | wc -l` |
70 | if test $EC -ge 1 | 70 | if test $EC -ge 1 |
71 | then | 71 | then |
72 | rm "$FILENAME.png" | 72 | rm "$FILENAME.png" |
73 | fi | 73 | fi |
@@ -80,7 +80,5 @@ case "$1" in | |||
80 | *) | 80 | *) |
81 | echo $"Usage: $0 {collect|plot|view}" | 81 | echo $"Usage: $0 {collect|plot|view}" |
82 | exit 1 | 82 | exit 1 |
83 | |||
84 | esac | ||
85 | 83 | ||
86 | 84 | esac | |