warnings.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. #
  3. # Usage:
  4. # tools/warnings.sh [node]
  5. # Output: for each node outputs its warnings and the number of times that
  6. # warning has ocurred. If the argument node is specified, it only shows
  7. # the warnings of that node.
  8. # Examples: tools/warnings.sh
  9. # tools/warnings.sh 000a
  10. if [ ! -z "$CHUTNEY_PATH" ]; then
  11. cd "$CHUTNEY_PATH"
  12. fi
  13. function show_warnings() {
  14. echo "${GREEN}Node `basename $1`:${NC}"
  15. sed -n 's/^.*\[warn\]//p' $1/info.log | sort | uniq -c | \
  16. sed -e 's/^\s*//' -e "s/\([0-9][0-9]*\) \(.*\)/${YELLOW}Warning:${NC}\2${YELLOW} Number: \1${NC}/"
  17. echo ""
  18. }
  19. function usage() {
  20. echo "Usage: $NAME [node]"
  21. exit 1
  22. }
  23. NC=$(tput sgr0)
  24. YELLOW=$(tput setaf 3)
  25. GREEN=$(tput setaf 2)
  26. CHUTNEY=./chutney
  27. NAME=$(basename "$0")
  28. DEST=net/nodes
  29. [ -d net/nodes ] || { echo "$NAME: no logs available"; exit 1; }
  30. if [ $# -eq 0 ];
  31. then
  32. for dir in $DEST/*;
  33. do
  34. [ -e ${dir}/info.log ] || continue
  35. show_warnings $dir
  36. done
  37. elif [ $# -eq 1 ];
  38. then
  39. [ -e $DEST/$1/info.log ] || { echo "$NAME: no log available"; exit 1; }
  40. show_warnings $DEST/$1
  41. else
  42. usage
  43. fi