onos-log 730 Bytes
#!/bin/bash
# -----------------------------------------------------------------------------
# Monitors remote ONOS log file on the specified node.
# -----------------------------------------------------------------------------

[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults

remote=$ONOS_USER@${1:-$OCI}

LOG=$ONOS_INSTALL_DIR/log/karaf.log

trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | xargs kill'" EXIT

ssh $remote "
    while true; do
        echo ==================================================================
        [ ! -f $LOG ] && sleep 2 && continue
        tail -n 512 --follow=name $LOG --sleep-interval 2
    done
"