blob: 8369cb9f559be067b462678c87102deca0b74fcb [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_
8
9usage:
10 $(basename $0) [node] ['old']
11
12options:
13 - [node] : The node whose logs to inspect. The default is \$OCI.
14 - ['old'] : If 'old' is specified, the logs are simply searched for errors
15 and exceptions, and they are displayed.
16
17summary:
18 Checks the logs of the remote ONOS instance and makes sure they are clean.
19
20_EOM_
21}
22
23[ "$1" = "-h" ] && __usage && exit 0
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
28remote=$ONOS_USER@${1:-$OCI}
29
Thomas Vachuska77a9a442015-05-19 17:35:52 -070030LOG=$ONOS_INSTALL_DIR/log/karaf.log*
tom82d6bde2014-09-23 17:33:58 -070031
Thomas Vachuska77a9a442015-05-19 17:35:52 -070032aux=/tmp/log.$$
33
34if [ "$2" = "old" ]; then
35 ssh $remote "egrep 'ERROR|Exception|Error' $LOG"
36
37else
38 ssh $remote "
Ayaka Koshibebad156d2015-09-18 17:30:14 -070039 [ "'`uname`'" != "'"Linux"'" ] && alias tac='tail -r'
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070040 tac $LOG | tr -d '\000' | awk '
Thomas Vachuska128cffb2016-10-24 13:04:46 -070041 BEGIN { off = 0; fail = 0; exclusion = 0; trace = \"\";}
Thomas Vachuska77a9a442015-05-19 17:35:52 -070042 / org.apache.karaf.main.lock.SimpleFileLock lock/ {
Thomas Vachuska77a9a442015-05-19 17:35:52 -070043 exit fail;
44 }
45
46 / ERROR / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070047 if (exception && !exclusion) {
48 print \$0;
49 exception = 0;
50 fail = 1;
51 }
52 exclusion = 0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070053 }
54 / WARN / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070055 if (exception && !exclusion) {
Thomas Vachuska77a9a442015-05-19 17:35:52 -070056 print \$0;
Thomas Vachuska128cffb2016-10-24 13:04:46 -070057 exception = 0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070058 }
Thomas Vachuska128cffb2016-10-24 13:04:46 -070059 exclusion = 0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070060 }
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070061 / INFO / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070062 exception = 0;
63 exclusion = 0;
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070064 }
Thomas Vachuska77a9a442015-05-19 17:35:52 -070065
66 /^[a-zA-Z0-9.]*(Exception|Error)/ {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070067 if (!exclusion) {
68 print trace;
69 print \$0;
70 exception = 1;
71 fail = 1;
72 trace = \"\";
73 }
Thomas Vachuska77a9a442015-05-19 17:35:52 -070074 }
75
Thomas Vachuska2ec5aa92016-08-31 13:30:31 -070076 /( at|Caused by:) / {
Thomas Vachuska128cffb2016-10-24 13:04:46 -070077 trace = trace \"\n\" \$0;
Thomas Vachuska77a9a442015-05-19 17:35:52 -070078 }
Thomas Vachuska128cffb2016-10-24 13:04:46 -070079
80 # Sanctioned exclusions for exceptions in third-party code; one pattern per exclusion
81 /at org\.apache\.felix\.scr\.impl\.ComponentRegistry\.getComponents\(ComponentRegistry\.java:199\)/ { exclusion = 1; }
82 /at org\.apache\.karaf\.service\.guard\.impl\.GuardProxyCatalog.1.run\(GuardProxyCatalog\.java:253\)/ { exclusion = 1; }
83
Thomas Vachuska77a9a442015-05-19 17:35:52 -070084 END { exit fail; }
85 ' > $aux
86 status=\$?
87 tac $aux && rm $aux
88 exit \$status
89 "
90fi