#!/bin/sh
#
#
#    Copyright (c) 1996-2002 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    File name:   getTimeLine
#    Module name: diag/scripts
#
#    This script generates a time line of events across the various
#    blades based on the input files.
#
# NAME
#    getTimeLine
#
# SYNOPSIS
#    getTimeLine filelist
#	Example: getTimeLine /var/log/*.log
#		 getTimeLine /var/log/*.sum
#
# AVAILABILITY
#    swt_mfg
#
# DESCRIPTION
#	This script extracts the times stamped entries in each
#	of the specified files into a file in the base directory.
#	It then calls timeLine to create the output cronological
#	output ofthe activities across all the input blades.
#
# OPERANDS
#
#    NONE
#
##########################
if [ "$1" = "" ]
then
     /bin/echo "Usage getTimeLine <list of burnin log files>"
     /bin/echo " Generates a time oriented activity list across the blades during the burnin run."
     /bin/echo ""
     /bin/echo "  Example: getTimeLine /var/log/*.log"
     /bin/echo "  Example: burnincatlog; getTimeLine /var/log/*.sum"
     exit 1
fi

num_subdirs=`/bin/echo $1 | /usr/bin/tr "/" " " | /usr/bin/wc -w | /bin/sed "s/ //g"`
if [ $num_subdirs -eq 1 ]
then
    base_dir=`pwd`
else
    if [ "`/bin/echo $1 | /usr/bin/cut -d '/' -f1`" = "." ]
    then
	base_dir=`pwd`
    else
	base_dir=`/bin/echo $1 | /usr/bin/cut -d "/" -f1-$num_subdirs`
    fi
fi
/bin/rm -f $base_dir/time_log.list $base_dir/time_log
for fil in $*
do
    /bin/grep " UTC " $fil >> $base_dir/time_log.list
done
/bin/echo "Starting to generate time log in $base_dir"
/fabos/sbin/timeLine $base_dir/time_log.list > $base_dir/time_log
/bin/echo "Results are in $base_dir/time_log"
if [ "`/bin/echo $0 | /bin/grep -i show`" != "" ]
then
     /bin/cat $base_dir/time_log
fi
exit 0
