#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# show_tech_swucode_ptp - Show tech-support fast script for the PTP SPP plugin
#
# May 2011, Christopher North
#
# Copyright (c) 2011, 2017 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------------------

#
# Load the script provided by show-tech infra, which provides worker functions
#
. /pkg/bin/show_tech_main_fragment

#
# Parse the arguments to the script
#
__cardtype="unspecified"
internal_if="unspecified"
external_if=""

while [ "$#" -gt "0" ]; do
    case "$1" in
        -I) internal_if="$2"; shift 2;;
        -t) __cardtype="$2"; shift 2;;
        *) shift;;
    esac
done

if [ "$internal_if" != "unspecified" ]; then
    external_if=`convert_interface_fmt '-e' $internal_if`
fi

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

#
# List of commands to be run.  East set must finish with a pair of empty 
# strings.  Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands.
#
# For all of these the __ksh variable is the process that will actually be 
# spawned, the _exec variable is just a string that is printed in the output to
# describe it. 
#

###############################################################################
# Show commands that run once per LR
###############################################################################
sys_exec[1]=''
sys__ksh[1]=''

#
# Commands requiring interface handle
#
sys_if_exec[1]=''
sys_if__ksh[1]=''

###############################################################################
# Show commands that run on all RPs or LCs                                    #
###############################################################################

#
# Show commands
#
rplc_exec[1]='spp_ui node graph'
rplc__ksh[1]='spp_ui node graph'

rplc_exec[2]='spp_ui node counters'
rplc__ksh[2]='spp_ui node counters'

rplc_exec[3]='spp_ui node stats'
rplc__ksh[3]='spp_ui node stats'

rplc_exec[4]='spp_ui ptp global detail'
rplc__ksh[4]='spp_ui ptp global detail'

rplc_exec[5]='spp_ui ptp intfs'
rplc__ksh[5]='spp_ui ptp intfs'

rplc_exec[6]='spp_ui ptp sessions detail'
rplc__ksh[6]='spp_ui ptp sessions detail'

rplc_exec[7]='spp_ui client stats'
rplc__ksh[7]='spp_ui client stats'

rplc_exec[8]='show process spp'
rplc__ksh[8]='sysmgr_show -o -p spp'

rplc_exec[9]=''
rplc__ksh[9]=''

#
# The display() function is the one that does all the work - called by us as 
# this is a worker script.
#
display() {
    print_main_heading "PTP Offload Plugin tech support start"
        
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys

        if [ "$internal_if" != "unspecified" ]; then
        exec_commands sys_if
        fi
    else
        case "$__cardtype" in
        "DRP"|"RP")
            exec_commands rplc
            ;;
        "LC")
            exec_commands rplc
            ;;
        esac
    fi
    
    run_module show_tech_swoffload

    print_main_heading "PTP Offload Plugin tech support end"
}

display
