blob: 0022a95d1c7572e39bba878a9589cc0359fc23f8 [file] [log] [blame]
tom5a18e802014-09-18 12:38:15 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom1a2908c2014-09-23 16:37:39 -07003# Monitors remote ONOS log file on the specified node.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom5a18e802014-09-18 12:38:15 -07005
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
Jonathan Hart518e5e72014-10-31 15:28:35 -07008. $ONOS_ROOT/tools/test/bin/find-node.sh
tom5a18e802014-09-18 12:38:15 -07009
Jonathan Hart37226ce2014-10-31 11:08:53 -070010less=0
Jonathan Hart37226ce2014-10-31 11:08:53 -070011[ "$1" = "-l" ] && shift && less=1
12
Jonathan Hart518e5e72014-10-31 15:28:35 -070013remote=$(find_node $1)
14
15remote=$ONOS_USER@${remote:-$OCI}
Thomas Vachuska756fb292014-10-21 20:35:10 -070016instance=$2
tom5a18e802014-09-18 12:38:15 -070017
Thomas Vachuska756fb292014-10-21 20:35:10 -070018[ -n "$instance" ] && \
19 LOG=$ONOS_INSTALL_DIR/$KARAF_DIST/instances/$instance/data/log/karaf.log || \
20 LOG=$ONOS_INSTALL_DIR/log/karaf.log
tom5a18e802014-09-18 12:38:15 -070021
tom1f3805d2014-09-18 19:58:47 -070022
Jonathan Hart37226ce2014-10-31 11:08:53 -070023if [ $less -eq 1 ]; then
24 ssh -t $remote "less $LOG"
25else
Yuta HIGUCHI1a606042014-11-10 11:01:37 -080026 ssh -t $remote "
tom5a18e802014-09-18 12:38:15 -070027 while true; do
tomcaf3bf72014-09-23 13:20:53 -070028 echo ==================================================================
tom5a18e802014-09-18 12:38:15 -070029 [ ! -f $LOG ] && sleep 2 && continue
Thomas Vachuska33bd2302015-02-19 14:53:44 -080030 tail -n 512 --follow=name $LOG --pid \$$ --sleep-interval 2
tom5a18e802014-09-18 12:38:15 -070031 done
Jonathan Hart37226ce2014-10-31 11:08:53 -070032 "
33fi