tom | 82d6bde | 2014-09-23 17:33:58 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
tom | 82d6bde | 2014-09-23 17:33:58 -0700 | [diff] [blame] | 3 | # Checks the logs of the remote ONOS instance and makes sure they are clean. |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 82d6bde | 2014-09-23 17:33:58 -0700 | [diff] [blame] | 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | remote=$ONOS_USER@${1:-$OCI} |
| 10 | |
Thomas Vachuska | 77a9a44 | 2015-05-19 17:35:52 -0700 | [diff] [blame^] | 11 | LOG=$ONOS_INSTALL_DIR/log/karaf.log* |
tom | 82d6bde | 2014-09-23 17:33:58 -0700 | [diff] [blame] | 12 | |
Thomas Vachuska | 77a9a44 | 2015-05-19 17:35:52 -0700 | [diff] [blame^] | 13 | aux=/tmp/log.$$ |
| 14 | |
| 15 | if [ "$2" = "old" ]; then |
| 16 | ssh $remote "egrep 'ERROR|Exception|Error' $LOG" |
| 17 | |
| 18 | else |
| 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 | " |
| 60 | fi |