Committed by
Gerrit Code Review
Util script to collect ONOS logs
Change-Id: I7075efdfa5c22e850dd5ca54fa0dfd51ab46a982
Showing
1 changed file
with
43 additions
and
0 deletions
tools/test/bin/onos-fetch-logs
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------- | ||
| 3 | +# Collect ONOS logs from a single node or the current ONOS cell. | ||
| 4 | +# ----------------------------------------------------------------------------- | ||
| 5 | + | ||
| 6 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
| 7 | +. $ONOS_ROOT/tools/build/envDefaults | ||
| 8 | + | ||
| 9 | +function print_usage { | ||
| 10 | + command_name=`basename $0` | ||
| 11 | + echo "Collect ONOS logs from a single node or the current ONOS cell." | ||
| 12 | + echo | ||
| 13 | + echo "Usage: $command_name <TARGET> " | ||
| 14 | + echo " $command_name [-h | --help]" | ||
| 15 | + echo "Options:" | ||
| 16 | + echo " TARGET The target of the command" | ||
| 17 | + echo " [-h | --help] Print this help" | ||
| 18 | + echo "" | ||
| 19 | + echo "TARGET: <hostname | --cell>" | ||
| 20 | + echo " hostname Execute on the specified host name" | ||
| 21 | + echo " --cell Execute on the current ONOS cell" | ||
| 22 | + echo "" | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +# Print usage | ||
| 26 | +if [ "${1}" = "-h" -o "${1}" = "--help" ]; then | ||
| 27 | + print_usage | ||
| 28 | + exit 0 | ||
| 29 | +fi | ||
| 30 | + | ||
| 31 | +# Select the target | ||
| 32 | +if [ "${1}" = "--cell" ]; then | ||
| 33 | + nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) | ||
| 34 | +else | ||
| 35 | + nodes=${1:-$OCI} | ||
| 36 | +fi | ||
| 37 | + | ||
| 38 | +# Execute the remote commands | ||
| 39 | +for node in $nodes; do | ||
| 40 | + echo "fetching from ${node}..." | ||
| 41 | + mkdir -p ${node} | ||
| 42 | + scp -p $ONOS_USER@${node}:$ONOS_INSTALL_DIR/log/karaf.log* ./${node}/ | ||
| 43 | +done |
-
Please register or login to post a comment