[tor-commits] [chutney/master] Add new script tools/warnings.sh

nickm at torproject.org nickm at torproject.org
Mon Dec 29 15:48:56 UTC 2014


commit d4817424da704ca29d058337446b516c44ddc6a2
Author: Ignacio Gago <igago at ucm.es>
Date:   Wed Dec 17 20:55:50 2014 +0100

    Add new script tools/warnings.sh
---
 tools/warnings.sh |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tools/warnings.sh b/tools/warnings.sh
new file mode 100755
index 0000000..b99623b
--- /dev/null
+++ b/tools/warnings.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Usage:
+#    cd YOUR-CHUTNEY-DIRECTORY
+#    tools/warnings.sh [node]
+# Output: for each node outputs its warnings and the number of times that
+# warning has ocurred. If the argument node is specified, it only shows
+# the warnings of that node.
+# Examples: tools/warnings.sh 
+#           tools/warnings.sh 000a
+
+function show_warnings() {
+    echo "${GREEN}Node `basename $1`:${NC}"
+    sed -n 's/^.*\[warn\]//p' $1/info.log | uniq -c | \
+    sed -e 's/^\s*//' -e "s/\([0-9][0-9]*\) \(.*\)/${YELLOW}Warning:${NC}\2${YELLOW} Number: \1${NC}/"
+    echo ""
+}
+
+function usage() {
+    echo "Usage: $NAME [node]"
+    exit 1
+}
+
+NC=$(tput sgr0)
+YELLOW=$(tput setaf 3)
+GREEN=$(tput setaf 2)
+CHUTNEY=./chutney
+NAME=$(basename "$0")
+DEST=net/nodes
+
+[ -d net/nodes ] || { echo "$NAME: no logs available"; exit 1; }
+if [ $# -eq 0 ]; 
+then    
+    for dir in $DEST/*;
+    do
+        [ -e ${dir}/info.log ] || continue
+        show_warnings $dir 
+    done
+elif [ $# -eq 1 ];
+then 
+    [ -e $DEST/$1/info.log ] || { echo "$NAME: no log available"; exit 1; }
+    show_warnings $DEST/$1
+else
+    usage
+fi





More information about the tor-commits mailing list