123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #!/bin/sh
- if [ ! -d "$CHUTNEY_PATH" -o ! -x "$CHUTNEY_PATH/chutney" ]; then
-
- TOOLS_PATH=`dirname "$0"`
- export CHUTNEY_PATH=`dirname "$TOOLS_PATH"`
- fi
- if [ -d "$PWD/$CHUTNEY_PATH" -a -x "$PWD/$CHUTNEY_PATH/chutney" ]; then
-
- export CHUTNEY_PATH="$PWD/$CHUTNEY_PATH"
- fi
- if [ ! -d "$CHUTNEY_DATA_DIR" ]; then
-
- export CHUTNEY_DATA_DIR="$CHUTNEY_PATH/net"
- fi
- if [ -d "$PWD/$CHUTNEY_DATA_DIR" ]; then
-
- export CHUTNEY_DATA_DIR="$PWD/$CHUTNEY_DATA_DIR"
- fi
- show_warnings() {
-
- if [ "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
- FILE="$1/*/$LOG_FILE"
- else
- FILE="$1/$LOG_FILE"
- fi
- if [ "$CHUTNEY_WARNINGS_IGNORE_EXPECTED" = true -a \
- -e "$IGNORE_FILE" ]; then
- CAT="grep -v -f"
- else
- CAT=cat
- IGNORE_FILE=
- fi
-
-
- if [ `$CAT $IGNORE_FILE $FILE | $SED_E "$FILTER" | wc -c` -eq 0 -a \
- "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
- ECHO_Q=true
- ECHO_A=true
- else
-
- ECHO_A=echo
- fi
-
- if [ "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
- $ECHO_Q "${GREEN}Summary: `basename $1`${NC}"
- else
- $ECHO_Q "${GREEN}Node: `basename $1`${NC}"
- fi
- if [ "$CHUTNEY_WARNINGS_IGNORE_EXPECTED" = true -a \
- -e "$IGNORE_FILE" ]; then
- PERMANENT_DIR=`readlink -n "$1" || echo "$1"`
- $ECHO_A "${GREEN}Detail: chutney/tools/warnings.sh $PERMANENT_DIR${NC}"
- fi
-
-
- $CAT $IGNORE_FILE $FILE | $SED_E "$FILTER" | sort | uniq -c | \
- sed -e 's/^\s*//' -e "s/ *\([0-9][0-9]*\) *\(.*\)/${YELLOW}Warning:${NC} \2${YELLOW} Number: \1${NC}/"
- if [ "$CHUTNEY_WARNINGS_SUMMARY" != true ]; then
- $ECHO_Q ""
- fi
- }
- usage() {
- echo "Usage: $NAME [node]"
- exit 1
- }
- if [ -t 1 ]; then
- NC=$(tput sgr0)
- YELLOW=$(tput setaf 3)
- GREEN=$(tput setaf 2)
- fi
- CHUTNEY="$CHUTNEY_PATH/chutney"
- NAME=$(basename "$0")
- DEST="$CHUTNEY_DATA_DIR/nodes"
- LOG_FILE=info.log
- CHUTNEY_WARNINGS_IGNORE_EXPECTED=${CHUTNEY_WARNINGS_IGNORE_EXPECTED:-0}
- IGNORE_FILE="$CHUTNEY_PATH/tools/ignore.warnings"
- CHUTNEY_WARNINGS_SUMMARY=${CHUTNEY_WARNINGS_SUMMARY:-0}
- SED_E='sed -n -E'
- FILTER='s/^.*\[(warn|err)\]//p'
- ECHO_Q=${ECHO:-"echo"}
- [ -d "$DEST" ] || { echo "$NAME: no logs available"; exit 1; }
- if [ $# -eq 0 ];
- then
- if [ "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
- show_warnings "$DEST"
- exit 0
- fi
- for dir in "$DEST"/*;
- do
- [ -e "${dir}/$LOG_FILE" ] || continue
- show_warnings "$dir"
- done
- elif [ $# -eq 1 ];
- then
- [ -e "$DEST/$1/$LOG_FILE" ] || \
- { echo "$NAME: no log available"; exit 1; }
- show_warnings "$DEST/$1"
- else
- usage
- fi
|