blob: 40e3e106c7951bfe569416b4e0e907564075dd29 [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 Vachuska77a9a442015-05-19 17:35:52 -070040 tac $LOG | awk '
41 BEGIN { off = 0; fail = 0; }
42 / org.apache.karaf.main.lock.SimpleFileLock lock/ {
43 off = 1;
44 exit fail;
45 }
46
47 / ERROR / {
48 if (!off) {
49 print \$0;
50 exc = 0;
51 fail = 1;
52 }
53 }
54 / WARN / {
55 if (!off && exc) {
56 print \$0;
57 exc = 0;
58 }
59 }
60
61 /^[a-zA-Z0-9.]*(Exception|Error)/ {
62 if (!off) {
63 print \$0;
64 exc = 1;
65 fail = 1;
66 }
67 }
68
69 / at / {
70 if (!off) {
71 print \$0;
72 }
73 }
74 END { exit fail; }
75 ' > $aux
76 status=\$?
77 tac $aux && rm $aux
78 exit \$status
79 "
80fi