blob: b98fe1bda27df645878f465d71a0e13c28b6a220 [file] [log] [blame]
tom82d6bde2014-09-23 17:33:58 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom82d6bde2014-09-23 17:33:58 -07003# Checks the logs of the remote ONOS instance and makes sure they are clean.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom82d6bde2014-09-23 17:33:58 -07005
Ayaka Koshibebad156d2015-09-18 17:30:14 -07006function __usage() {
7cat << _EOM_
Thomas Vachuska27ece8f2016-11-11 10:03:11 -08008usage: $(basename $0) [--old|--ignore-store-exceptions] [node]
Ayaka Koshibebad156d2015-09-18 17:30:14 -07009
10options:
Thomas Vachuska27ece8f2016-11-11 10:03:11 -080011 --ignore-store-exceptions
12 if specified, any store service exceptions are ignored
13 --old
14 if specified, the entire logs are searched for errors and exceptions;
15 otherwise logs are scanned only from the last server start-up
16
17 node the cluster node whose logs to inspect; default is \$OCI
Ayaka Koshibebad156d2015-09-18 17:30:14 -070018
19summary:
20 Checks the logs of the remote ONOS instance and makes sure they are clean.
21
22_EOM_
23}
24
tom82d6bde2014-09-23 17:33:58 -070025[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
26. $ONOS_ROOT/tools/build/envDefaults
27
Thomas Vachuska27ece8f2016-11-11 10:03:11 -080028# Process options
29while [ -z $opts ] ; do
30 case "$1" in
31 --ignore-store-exceptions) export ise=1; shift;;
32 --old) export allLogs=1; shift;;
33 --*) __usage && exit 1;;
34 -h) __usage && exit 0;;
35 *) export opts=1;;
36 esac
37done
38
tom82d6bde2014-09-23 17:33:58 -070039remote=$ONOS_USER@${1:-$OCI}
40
Thomas Vachuska77a9a442015-05-19 17:35:52 -070041LOG=$ONOS_INSTALL_DIR/log/karaf.log*
tom82d6bde2014-09-23 17:33:58 -070042
Thomas Vachuska77a9a442015-05-19 17:35:52 -070043aux=/tmp/log.$$
44
Thomas Vachuska27ece8f2016-11-11 10:03:11 -080045if [ -n "$allLogs" ]; then
Thomas Vachuska77a9a442015-05-19 17:35:52 -070046 ssh $remote "egrep 'ERROR|Exception|Error' $LOG"
47
48else
49 ssh $remote "
Ayaka Koshibebad156d2015-09-18 17:30:14 -070050 [ "'`uname`'" != "'"Linux"'" ] && alias tac='tail -r'
Thomas Vachuska27ece8f2016-11-11 10:03:11 -080051 tac $LOG | tr -d '\000' | awk -v ignoreStoreExceptions=${ise:-0} '
Thomas Vachuska128cffb2016-10-24 13:04:46 -070052 BEGIN { off = 0; fail = 0; exclusion = 0; trace = \"\";}
Thomas Vachuska77a9a442015-05-19 17:35:52 -070053 / org.apache.karaf.main.lock.SimpleFileLock lock/ {
Thomas Vachuska77a9a442015-05-19 17:35:52 -070054 exit fail;
55 }
56
57 / ERROR / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070058 if (exception && !exclusion) {
59 print \$0;
60 exception = 0;
61 fail = 1;
62 }
63 exclusion = 0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070064 }
65 / WARN / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070066 if (exception && !exclusion) {
Thomas Vachuska77a9a442015-05-19 17:35:52 -070067 print \$0;
Thomas Vachuska128cffb2016-10-24 13:04:46 -070068 exception = 0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070069 }
Thomas Vachuska128cffb2016-10-24 13:04:46 -070070 exclusion = 0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070071 }
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070072 / INFO / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070073 exception = 0;
74 exclusion = 0;
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070075 }
Thomas Vachuska77a9a442015-05-19 17:35:52 -070076
Thomas Vachuska27ece8f2016-11-11 10:03:11 -080077 # Sanctioned exclusions for exceptions in the distributed stores; one pattern per exclusion
78 /org\.onosproject\.store\.service\..*Exception/ { exclusion = ignoreStoreExceptions; }
79
Thomas Vachuska77a9a442015-05-19 17:35:52 -070080 /^[a-zA-Z0-9.]*(Exception|Error)/ {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070081 if (!exclusion) {
82 print trace;
83 print \$0;
84 exception = 1;
85 fail = 1;
86 trace = \"\";
87 }
Thomas Vachuska77a9a442015-05-19 17:35:52 -070088 }
89
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070090 /( at|Caused by:) / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070091 trace = trace \"\n\" \$0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070092 }
Thomas Vachuska128cffb2016-10-24 13:04:46 -070093
94 # Sanctioned exclusions for exceptions in third-party code; one pattern per exclusion
95 /at org\.apache\.felix\.scr\.impl\.ComponentRegistry\.getComponents\(ComponentRegistry\.java:199\)/ { exclusion = 1; }
96 /at org\.apache\.karaf\.service\.guard\.impl\.GuardProxyCatalog.1.run\(GuardProxyCatalog\.java:253\)/ { exclusion = 1; }
97
Thomas Vachuska77a9a442015-05-19 17:35:52 -070098 END { exit fail; }
99 ' > $aux
100 status=\$?
101 tac $aux && rm $aux
102 exit \$status
103 "
104fi