onos-check-logs
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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; }
/ org.apache.karaf.main.lock.SimpleFileLock lock/ {
exit fail;
}
/ ERROR / {
print \$0;
exc = 0;
fail = 1;
}
/ WARN / {
if (exc) {
print \$0;
exc = 0;
}
}
/ INFO / {
exc = 0;
}
/^[a-zA-Z0-9.]*(Exception|Error)/ {
print \$0;
exc = 1;
fail = 1;
}
/( at|Caused by:) / {
print \$0;
}
END { exit fail; }
' > $aux
status=\$?
tac $aux && rm $aux
exit \$status
"
fi