blob: ec1013ab6011b6ed2049e967605b602e88a0028a [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
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
9remote=$ONOS_USER@${1:-$OCI}
10
Thomas Vachuska77a9a442015-05-19 17:35:52 -070011LOG=$ONOS_INSTALL_DIR/log/karaf.log*
tom82d6bde2014-09-23 17:33:58 -070012
Thomas Vachuska77a9a442015-05-19 17:35:52 -070013aux=/tmp/log.$$
14
15if [ "$2" = "old" ]; then
16 ssh $remote "egrep 'ERROR|Exception|Error' $LOG"
17
18else
19 ssh $remote "
20 tac $LOG | awk '
21 BEGIN { off = 0; fail = 0; }
22 / org.apache.karaf.main.lock.SimpleFileLock lock/ {
23 off = 1;
24 exit fail;
25 }
26
27 / ERROR / {
28 if (!off) {
29 print \$0;
30 exc = 0;
31 fail = 1;
32 }
33 }
34 / WARN / {
35 if (!off && exc) {
36 print \$0;
37 exc = 0;
38 }
39 }
40
41 /^[a-zA-Z0-9.]*(Exception|Error)/ {
42 if (!off) {
43 print \$0;
44 exc = 1;
45 fail = 1;
46 }
47 }
48
49 / at / {
50 if (!off) {
51 print \$0;
52 }
53 }
54 END { exit fail; }
55 ' > $aux
56 status=\$?
57 tac $aux && rm $aux
58 exit \$status
59 "
60fi