blob: c9748a0b8673e2d4a73a7cdd845ae1471fce34d6 [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
9remote=$ONOS_USER@${1:-$OCI}
Thomas Vachuska756fb292014-10-21 20:35:10 -070010instance=$2
tom5a18e802014-09-18 12:38:15 -070011
Thomas Vachuska756fb292014-10-21 20:35:10 -070012[ -n "$instance" ] && \
13 LOG=$ONOS_INSTALL_DIR/$KARAF_DIST/instances/$instance/data/log/karaf.log || \
14 LOG=$ONOS_INSTALL_DIR/log/karaf.log
tom5a18e802014-09-18 12:38:15 -070015
tom1f3805d2014-09-18 19:58:47 -070016trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | xargs kill'" EXIT
17
tom5a18e802014-09-18 12:38:15 -070018ssh $remote "
19 while true; do
tomcaf3bf72014-09-23 13:20:53 -070020 echo ==================================================================
tom5a18e802014-09-18 12:38:15 -070021 [ ! -f $LOG ] && sleep 2 && continue
22 tail -n 512 --follow=name $LOG --sleep-interval 2
23 done
24"