#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_srlg - show commands for show tech-support srlg 
#                     spawned by show_tech_fast
#
# February 2010, Prashant Savani 
#
# Copyright (c) 2010, 2014, 2017-2018 by cisco Systems, Inc.
# All rights reserved.
# --------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

__cardtype="unspecified"

# Parse the arguments to the script.
while [ "$#" -gt "0" ]; do
    case "$1" in
        -t) __cardtype="$2"; shift 2;;
        *)  default_parser_function "$@"; shift $#;;
    esac
done

if [ "$__filename" = "unspecified" ]; then
    echo "show_tech_srlg: output file not specified"
    exit
fi

if [ "$__cardtype" == "unspecified" ]; then
    __cardtype=`node_type`
fi

# ***********************************************************
#  Show commands to be run by the show tech-support commands
# ***********************************************************

cmd="ls /pkg/bin/instcmd 2>/dev/null"
eval $cmd
plat=$?

# Commands that run on once per system
sys_exec[1]="show running-config"
sys__ksh[1]='nvgen -c -l 1 -t 1 -i1 -o 1'
if [[ $plat -eq 0 ]]
then
    sys_exec[2]="show version"                       # takes  90 secs on 4+4
    sys__ksh[2]='show_version'
else
    sys_exec[2]="show version"
    sys__ksh[2]='ng_show_version'
fi
if [[ $plat -eq 0 ]]
then
    sys_exec[3]='show install active summary'
    sys__ksh[3]='instcmd show install active summary'
else
    sys_exec[3]='show install active'
    sys__ksh[3]='sdr_instcmd show install active'
fi
sys_exec[4]="show redundancy"
sys__ksh[4]='redcon_show'
sys_exec[5]="show logging"
sys__ksh[5]='show_logging'
sys__ksh[6]=''

#############################################################
# Commands that run on all LCs
lc_exec[1]="show process rsi_agent"
lc__ksh[1]='sysmgr_show -o -p rsi_agent'
lc__ksh[2]=''

#############################################################
# Commands that run on all RPs
rp_exec[1]="show process rsi_master"
rp__ksh[1]='sysmgr_show -o -p rsi_master'
rp_exec[2]='show srlg trace'
rp__ksh[2]='rsi_srlg_show_ltrace'
rp_exec[3]='show srlg'
rp__ksh[3]='show_rsi_agent_srlg -c -s'
rp_exec[4]='show srlg interfaces all detail'
rp__ksh[4]='show_rsi_agent_srlg -c -A -I'


display() {
    print_main_heading "show tech-support srlg"

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
#        do_serial_per_node
    else
        case "$__cardtype" in
        "RP")
            exec_commands rp
            ;;
        "LC")
            exec_commands lc
            ;;
        esac
    fi

    print_main_heading "show tech-support srlg complete"
}

# Run the appropriate function depending on the node specified and if a
# file is specified write the output to that file. We need to redirect
# stderr to stdout when writing to a file because some of the show
# commands output to stderr instead of stdout
. /pkg/bin/show_tech_file_fragment
