#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_raw_ip - Runs show commands for show tech-support raw_ip
#
# Mar 2017 Prasanth Thammendra
#
# Copyright (c) 2002-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_raw_ip: 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
# ***********************************************************

# Show commands that run once per system
#
sys_exec[1]='show redundancy'
sys__ksh[1]='redcon_show'
sys__ksh[2]=''

#############################################################
# Commands that run on all RPs

# TCP trace commands
rp_trace_exec[1]='show raw trace location $location'
rp_trace__ksh[1]='raw_show_ltrace'

# Socket trace commands
rp_exec[1]='show socket trace process raw_ip location $location'
rp__ksh[1]='socket_show_ltrace -P raw_ip'

# show raw
rp_exec[2]='show raw br location $location'
rp__ksh[2]='raw_show show brief'

rp_exec[3]='show raw detail pcb all location $location'
rp__ksh[3]='raw_show show detail -a'

rp_exec[4]='show raw statistics pcb all location $location'
rp__ksh[4]='raw_show show detail -a'

rp_exec[5]='show raw statistics clients location $location'
rp__ksh[5]='raw_show show statistics -c'

#end 

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

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

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "RP")
            exec_commands rp_trace
            exec_commands rp
            exec_commands rplc_show
            ;;
        "DRP")
            exec_commands rp_trace
            exec_commands rp
            exec_commands rplc_show
            ;;
        "LC")
            exec_commands rplc_show
            ;;
        esac
    fi

    print_main_heading "show tech-support 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

