warnings.sh 1.1 KB

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