warnings.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # Label errs as "Warning:", they're infrequent enough it doesn't matter
  16. sed -n -E 's/^.*\[(warn|err)\]//p' $1/info.log | sort | uniq -c | \
  17. sed -e 's/^\s*//' -e "s/ *\([0-9][0-9]*\) *\(.*\)/ ${YELLOW}Warning:${NC} \2${YELLOW} Number: \1${NC}/"
  18. echo ""
  19. }
  20. function usage() {
  21. echo "Usage: $NAME [node]"
  22. exit 1
  23. }
  24. NC=$(tput sgr0)
  25. YELLOW=$(tput setaf 3)
  26. GREEN=$(tput setaf 2)
  27. CHUTNEY=./chutney
  28. NAME=$(basename "$0")
  29. DEST=net/nodes
  30. [ -d net/nodes ] || { echo "$NAME: no logs available"; exit 1; }
  31. if [ $# -eq 0 ];
  32. then
  33. for dir in $DEST/*;
  34. do
  35. [ -e ${dir}/info.log ] || continue
  36. show_warnings $dir
  37. done
  38. elif [ $# -eq 1 ];
  39. then
  40. [ -e $DEST/$1/info.log ] || { echo "$NAME: no log available"; exit 1; }
  41. show_warnings $DEST/$1
  42. else
  43. usage
  44. fi