| #!/bin/bash |
| # ----------------------------------------------------------------------------- |
| # Checks the logs of the remote ONOS instance and makes sure they are clean. |
| # ----------------------------------------------------------------------------- |
| |
| function __usage() { |
| cat << _EOM_ |
| |
| usage: |
| $(basename $0) [node] ['old'] |
| |
| options: |
| - [node] : The node whose logs to inspect. The default is \$OCI. |
| - ['old'] : If 'old' is specified, the logs are simply searched for errors |
| and exceptions, and they are displayed. |
| |
| summary: |
| Checks the logs of the remote ONOS instance and makes sure they are clean. |
| |
| _EOM_ |
| } |
| |
| [ "$1" = "-h" ] && __usage && exit 0 |
| |
| [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| . $ONOS_ROOT/tools/build/envDefaults |
| |
| remote=$ONOS_USER@${1:-$OCI} |
| |
| LOG=$ONOS_INSTALL_DIR/log/karaf.log* |
| |
| aux=/tmp/log.$$ |
| |
| if [ "$2" = "old" ]; then |
| ssh $remote "egrep 'ERROR|Exception|Error' $LOG" |
| |
| else |
| ssh $remote " |
| [ "'`uname`'" != "'"Linux"'" ] && alias tac='tail -r' |
| tac $LOG | tr -d '\000' | awk ' |
| BEGIN { off = 0; fail = 0; exclusion = 0; trace = \"\";} |
| / org.apache.karaf.main.lock.SimpleFileLock lock/ { |
| exit fail; |
| } |
| |
| / ERROR / { |
| if (exception && !exclusion) { |
| print \$0; |
| exception = 0; |
| fail = 1; |
| } |
| exclusion = 0; |
| } |
| / WARN / { |
| if (exception && !exclusion) { |
| print \$0; |
| exception = 0; |
| } |
| exclusion = 0; |
| } |
| / INFO / { |
| exception = 0; |
| exclusion = 0; |
| } |
| |
| /^[a-zA-Z0-9.]*(Exception|Error)/ { |
| if (!exclusion) { |
| print trace; |
| print \$0; |
| exception = 1; |
| fail = 1; |
| trace = \"\"; |
| } |
| } |
| |
| /( at|Caused by:) / { |
| trace = trace \"\n\" \$0; |
| } |
| |
| # Sanctioned exclusions for exceptions in third-party code; one pattern per exclusion |
| /at org\.apache\.felix\.scr\.impl\.ComponentRegistry\.getComponents\(ComponentRegistry\.java:199\)/ { exclusion = 1; } |
| /at org\.apache\.karaf\.service\.guard\.impl\.GuardProxyCatalog.1.run\(GuardProxyCatalog\.java:253\)/ { exclusion = 1; } |
| |
| END { exit fail; } |
| ' > $aux |
| status=\$? |
| tac $aux && rm $aux |
| exit \$status |
| " |
| fi |