#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_spio - SPIO show tech command
#
# June 2012, Paul Stanley
#
# Copyright (c) 2012-2013, 2016-2017 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_spio: 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
# ***********************************************************

#############################################################

# 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 [ "$platform" = "panini" ]; then
    sys_exec[2]="show install active"
    sys__ksh[2]='sdr_instcmd show install active'
    sys_exec[3]="show version"
    sys__ksh[3]='ng_show_version'
else
    sys_exec[2]="show install active summary"
    sys__ksh[2]='instcmd show install active summary'
    sys_exec[3]="show version"
    sys__ksh[3]='show_version'
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 RP and LC nodes

rplc_show_exec[1]='show spio trace'
rplc_show__ksh[1]='spio_show -C 3 -V -W -X -Y -Z -U -S'
rplc_show_exec[2]='show spio clients'
rplc_show__ksh[2]='spio_show -C 2 -l'
rplc_show_exec[3]='show spio interface'
rplc_show__ksh[3]='spio_show -C 1 -l'
rplc_show_exec[4]='show spio offload summary'
rplc_show__ksh[4]='spio_show -C 1 -l -B'
rplc_show_exec[5]='show spio offload detail'
rplc_show__ksh[5]='spio_show -C 4 -l'
rplc_show_exec[6]='show spio vi'
rplc_show__ksh[6]='spio_show -C 5 -l'
rplc_show_exec[7]='show spio protocols'
rplc_show__ksh[7]='spio_show -C 0'
rplc_show_exec[8]="show process spio_ma"
rplc_show__ksh[8]='sysmgr_show -o -p spio_ma'
rplc_show_exec[9]="show process spio_ea"
rplc_show__ksh[9]='sysmgr_show -o -p spio_ea'

# End
rplc_show__ksh[10]=''


#############################################################
# Script

display() {
    print_main_heading "show tech-support spio"
        
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "RP")
            exec_commands rplc_show        
            ;;
        "DRP")
            exec_commands rplc_show        
            ;;
        "LC")
            exec_commands rplc_show
            ;;
        esac
    fi
    print_main_heading "show tech-support complete"

    enable_techs ""  /pkg/bin/spp_show_tech_support
}

# 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
