blob: 38ff50ceafbd78c74ccc9f3f81cb195859798a9f [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 HIGUCHI7fe161a2014-11-04 20:51:09 -080026 trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | xargs kill'" EXIT
Jonathan Hart37226ce2014-10-31 11:08:53 -070027 ssh $remote "
tom5a18e802014-09-18 12:38:15 -070028 while true; do
tomcaf3bf72014-09-23 13:20:53 -070029 echo ==================================================================
tom5a18e802014-09-18 12:38:15 -070030 [ ! -f $LOG ] && sleep 2 && continue
31 tail -n 512 --follow=name $LOG --sleep-interval 2
32 done
Jonathan Hart37226ce2014-10-31 11:08:53 -070033 "
34fi