#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# isis_techsupport_mc - ISIS specific show tech commands - fast mode
#
# April 2014, Siddhesh M. Divekar
#
# Copyright (c) 2013-2017 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

__cardtype="unspecified"
### Required argument parsing
### All local options must be upper-case.
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_routing_isis: output file not specified"
    exit
fi
if [ "$__cardtype" == "unspecified" ]; then
    __cardtype=`node_type`
fi

# **********************************************************************
# List of show commands for show tech-support routing isis
# **********************************************************************

cmd_index=1

#
# Command set 1 are run on RPs.
#
com1_SYS_exec[$cmd_index]='show version'
if [[ "$platform" = "viking" ]]; then
     com1_SYS__ksh[$cmd_index]='show_version -b'
elif [[ "$platform" = "panini" ]]; then
     com1_SYS__ksh[$cmd_index]='ng_show_version'
else
     com1_SYS__ksh[$cmd_index]='show_version -b'
fi
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]="show install active summary"
if [[ "$platform" = "viking" ]]; then
     com1_SYS__ksh[$cmd_index]='instcmd show install active summary'
elif [[ "$platform" = "panini" ]]; then
     com1_SYS__ksh[$cmd_index]='sdr_instcmd show install active'
else
     com1_SYS__ksh[$cmd_index]='instcmd show install active summary'
fi
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]="show placement"
com1_SYS__ksh[$cmd_index]='placed_show'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show running-config inheritance detail'
com1_SYS__ksh[$cmd_index]='nvgen -c -H -O -l 1 -t 1 -o 1'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show platform'
if [[ "$platform" = "viking" ]]; then
     com1_SYS__ksh[$cmd_index]='show_platform_vkg -e'
elif [[ "$platform" = "panini" ]]; then
     com1_SYS__ksh[$cmd_index]='show_platform_sysdb -v'
else
     com1_SYS__ksh[$cmd_index]='show_platform -a'
fi
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show processes blocked location $location'
if [[ "$platform" = "panini" ]]; then
 com1_SYS__ksh[$cmd_index]='sh_proc_ng_blocked -l $fq_nodeid'
else
 com1_SYS__ksh[$cmd_index]='show_processes -b $fq_nodeid'
fi
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show processes isis'
if [[ "$platform" = "enxr" ]]; then
 com1_SYS__ksh[$cmd_index]='sysmgr_show_enxr -o -p isis'
else
 com1_SYS__ksh[$cmd_index]='sysmgr_show -o -p isis'
fi
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis all'
com1_SYS__ksh[$cmd_index]='isis_show -a -d -v -B -5 -# -F -M -1 -2 all'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis private all'
com1_SYS__ksh[$cmd_index]='isis_show -a -P'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis standby all'
com1_SYS__ksh[$cmd_index]='isis_show -a -Q -d -v -B -5 -# -F -M -1 -2 all'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis standby private all'
com1_SYS__ksh[$cmd_index]='isis_show -a -Q -P'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis trace all'
com1_SYS__ksh[$cmd_index]='isis_show_ltrace -A -B -C -D -i all'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show logging'
com1_SYS__ksh[$cmd_index]='show_logging'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis uber-verifier trace all location $location'
com1_SYS__ksh[$cmd_index]='isis_uv_show_ltrace -A -B -C -i all'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show clns trace'
com1_SYS__ksh[$cmd_index]='clns_show_ltrace'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show segment-routing trace'
com1_SYS__ksh[$cmd_index]='xostrace srms'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show ipv4 int brief'
com1_SYS__ksh[$cmd_index]='show_ip_interface -b -v default'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show ipv6 int brief'
com1_SYS__ksh[$cmd_index]='show_ipv6_interface -b -v default'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show imds interface all'
com1_SYS__ksh[$cmd_index]='im_show database -v 0x2'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show lpts bindings client-id clnl brief'
com1_SYS__ksh[$cmd_index]='show_lpts_pa -a -B -j 0x4'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show route afi-all safi-all topology all isis'
com1_SYS__ksh[$cmd_index]='show_all_afi_rib -X 0x0 -Y 0x3 -Z ________ -V all -P isis all ________'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show route afi-all safi-all topology all'
com1_SYS__ksh[$cmd_index]='show_all_afi_rib -X 0x0 -Y 0x3 -Z ________ -V all -s all ________'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show clns statistics'
com1_SYS__ksh[$cmd_index]='show_clns_traffic'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show interfaces accounting'
com1_SYS__ksh[$cmd_index]='show_interface -a -o 0x4'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show clns pcb location $location'
com1_SYS__ksh[$cmd_index]='lpts_show_pcb -p 0x4 -f 0x0 -N $fq_nodeid -e /oper/clns/'
cmd_index=$((cmd_index + 1))

com1_SYS_exec[$cmd_index]='show isis xipc'
com1_SYS__ksh[$cmd_index]='isis_show_xipc'
cmd_index=$((cmd_index + 1))

com1_SYS__ksh[$cmd_index]=''

cmd_index=1
#
# Command set 2 are run on all nodes.
#
com2_SYS_exec[$cmd_index]='show netio clients location $location'
com2_SYS__ksh[$cmd_index]='netio_show -L  $fq_nodeid'
cmd_index=$((cmd_index + 1))

com2_SYS_exec[$cmd_index]='show lpts pifib entry type isis brief location $location'
com2_SYS__ksh[$cmd_index]='show_lpts_pifib -z 0x0 -k 0x0 -a 0x1 -i $fq_nodeid'
cmd_index=$((cmd_index + 1))

com2_SYS_exec[$cmd_index]='show lpts pifib entry type isis location $location'
com2_SYS__ksh[$cmd_index]='show_lpts_pifib -z 0x0 -k 0x0 -a 0x0 -i $fq_nodeid'
cmd_index=$((cmd_index + 1))

com2_SYS__ksh[$cmd_index]=''

cmd_index=1
#
# Command set 3 are run on linecards.
#
if [ -x /pkg/bin/show_platform_pifib ]; then
 com3_SYS_exec[$cmd_index]='show lpts pifib hardware entry type isis location $location'
 com3_SYS__ksh[$cmd_index]='show_platform_pifib -z 0x1 -r 0x2 -i $fq_nodeid'
 cmd_index=$((cmd_index + 1))
elif [ -x /pkg/bin/platform_show_pifib ]; then
 com3_SYS_exec[$cmd_index]='show lpts pifib hardware entry type isis location $location'
 com3_SYS__ksh[$cmd_index]='platform_show_pifib -z 0x1 -r 0x2 -i $fq_nodeid'
 cmd_index=$((cmd_index + 1))
fi

com3_SYS__ksh[$cmd_index]=''


##################################################################
# This is called from the show tech infra for each card requested
##################################################################

display() {
  
    print_main_heading "show tech-support routing isis"
    
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands com1_SYS
        exec_commands com2_SYS
    else
        case "$__cardtype" in
        "RP"|"DRP")
            exec_commands com1_SYS
            exec_commands com2_SYS
            ;;
        "LC")
            exec_commands com2_SYS
            exec_commands com3_SYS
            ;;
        esac        
    fi

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