blob: a3364620706db011e0ffcf567dbe9549082230cd [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
8
Jonathan Hart37226ce2014-10-31 11:08:53 -07009less=0
10
11[ "$1" = "-l" ] && shift && less=1
12
tom5a18e802014-09-18 12:38:15 -070013remote=$ONOS_USER@${1:-$OCI}
Thomas Vachuska756fb292014-10-21 20:35:10 -070014instance=$2
tom5a18e802014-09-18 12:38:15 -070015
Thomas Vachuska756fb292014-10-21 20:35:10 -070016[ -n "$instance" ] && \
17 LOG=$ONOS_INSTALL_DIR/$KARAF_DIST/instances/$instance/data/log/karaf.log || \
18 LOG=$ONOS_INSTALL_DIR/log/karaf.log
tom5a18e802014-09-18 12:38:15 -070019
tom1f3805d2014-09-18 19:58:47 -070020trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | xargs kill'" EXIT
21
Jonathan Hart37226ce2014-10-31 11:08:53 -070022if [ $less -eq 1 ]; then
23 ssh -t $remote "less $LOG"
24else
25 ssh $remote "
tom5a18e802014-09-18 12:38:15 -070026 while true; do
tomcaf3bf72014-09-23 13:20:53 -070027 echo ==================================================================
tom5a18e802014-09-18 12:38:15 -070028 [ ! -f $LOG ] && sleep 2 && continue
29 tail -n 512 --follow=name $LOG --sleep-interval 2
30 done
Jonathan Hart37226ce2014-10-31 11:08:53 -070031 "
32fi