blob: fe89f6dd85df960476305ea277e9ca1af7b51123 [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 Vachuskaaa226b12015-04-22 14:40:55 -070018pattern=$3
19
20[ -n "$instance" -a "$instance" != "-" ] && \
Thomas Vachuska756fb292014-10-21 20:35:10 -070021 LOG=$ONOS_INSTALL_DIR/$KARAF_DIST/instances/$instance/data/log/karaf.log || \
22 LOG=$ONOS_INSTALL_DIR/log/karaf.log
tom5a18e802014-09-18 12:38:15 -070023
tom1f3805d2014-09-18 19:58:47 -070024
Jonathan Hart37226ce2014-10-31 11:08:53 -070025if [ $less -eq 1 ]; then
26 ssh -t $remote "less $LOG"
Thomas Vachuskaaa226b12015-04-22 14:40:55 -070027elif [ -n "$pattern" ]; then
28 ssh $remote "grep $LOG -Ee \"$pattern\""
Jonathan Hart37226ce2014-10-31 11:08:53 -070029else
Yuta HIGUCHI1a606042014-11-10 11:01:37 -080030 ssh -t $remote "
tom5a18e802014-09-18 12:38:15 -070031 while true; do
tomcaf3bf72014-09-23 13:20:53 -070032 echo ==================================================================
tom5a18e802014-09-18 12:38:15 -070033 [ ! -f $LOG ] && sleep 2 && continue
Thomas Vachuska34309842015-04-23 15:06:14 -070034 [ \$(uname) = "Darwin" ] && tail -n 512 -f -F $LOG ||
35 tail -n 512 --follow=name $LOG --pid \$$ --sleep-interval 2
tom5a18e802014-09-18 12:38:15 -070036 done
Jonathan Hart37226ce2014-10-31 11:08:53 -070037 "
38fi