#!/pkg/bin/ksh
#!/usr/bin/ksh
# Created by Rakesh Gandhi July 2003
# Copyright (c) 2003-2017 by cisco Systems, Inc.
# All rights reserved.
# Processes: te_control, mpls_lsd
#
# This scripts expects 1 or three arguments
#
# -L <level> where level is 0x1, 0x2 or 0x3
#
# -t <tunnel-id> Tunnel number (string)
#
# -f <device> <filename> These two arguments are used to redirect
#                        output to a file system, ex: disk, 
#                        tftp, ftp etc..
#----------------------------------------------------------------------


# This script fragment contains the code for the following functions
# - print_main_heading
# - print_command_heading
# - run_single_command
# - run_commands
# - run_single_command_on_all_nodes
# - run_commands_on_all_nodes
# - default_parser_function
. /pkg/bin/show_tech_main_fragment

# List each set of show commands to be run. Each set must finish with an empty
# string. Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands; showtech infra expects the command
# exactly the way it was entered.
# Use "\" ahead of any special character (eg. |) used in the command line.

# Common commands
i=1
j=1
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -s'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels summary private $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -8'
commandCommon_exec[$((i++))]='show mpls traffic-eng counters signaling summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0xc $standby_te__ksh -s'
commandCommon_exec[$((i++))]='show mpls traffic-eng counters rewrite summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0xf $standby_te__ksh -s'
commandCommon_exec[$((i++))]='show mpls traffic-eng counters batch $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x10 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng per-call $standby_exec'
commandCommon_exec[$((i++))]='show mpls traffic-eng connections $standby_exec'

if [[ $standby_exec = "standby" ]];then
    commandCommon__ksh[$((j++))]='percall_show te_control /oper/mpls_te/gl/standby/'
    commandCommon__ksh[$((j++))]='mpls_show 0x1 te_control /oper/mpls_te/gl/standby/'
else
    commandCommon__ksh[$((j++))]='percall_show te_control /oper/mpls_te/gl/'
    commandCommon__ksh[$((j++))]='mpls_show 0x1 te_control /oper/mpls_te/gl/'
fi

commandCommon_exec[$((i++))]='show mpls traffic-eng link-management statistics summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x80 -s'
commandCommon_exec[$((i++))]='show  mpls traffic-eng link-management summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x20'
commandCommon_exec[$((i++))]='show mpls traffic-eng fast-reroute database summary location $location'
commandCommon__ksh[$((j++))]='fib_mpls_show_frr 0x8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 -l $fq_nodeid'
commandCommon_exec[$((i++))]='show mpls forwarding summary'
commandCommon__ksh[$((j++))]='fib_mpls_show_fwding -S'
commandCommon_exec[$((i++))]='show cef drops'
commandCommon__ksh[$((j++))]='fib_statistics_show_command -P 0x0 -d'
commandCommon_exec[$((i++))]='show mpls lsd client'
commandCommon__ksh[$((j++))]='mpls_lsd_show -c -Z'
commandCommon_exec[$((i++))]='show mpls lsd applications'
commandCommon__ksh[$((j++))]='mpls_lsd_show -a -Z'
commandCommon_exec[$((i++))]='show mpls traffic-eng link-management interfaces detail private $standby_exec'
commandCommon__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x40 -d -Z'
commandCommon_exec[$((i++))]='show mpls traffic-eng telemetry bandwidth-accounting $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x37 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng nsr status detail $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x23 $standby_te__ksh -z 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng proc-fsm $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x1e $standby_te__ksh'
commandCommon_exec[$((i++))]='show imds client'
commandCommon__ksh[$((j++))]='im_show clients -l 0x0 -v 0x2'

commandCommon_exec[$((i++))]='show version'
commandCommon_exec[$((i++))]='show context'
commandCommon_exec[$((i++))]='show process blocked'
commandCommon_exec[$((i++))]='show memory heap fail all'
if [[ "$platform" = "panini" ]]; then
    commandCommon__ksh[$((j++))]='ng_show_version'
    commandCommon__ksh[$((j++))]='corehelper_context -c 0x1 -n all'
    commandCommon__ksh[$((j++))]='sh_proc_ng_blocked'
    commandCommon__ksh[$((j++))]='malloc_dump_wrapper -A -F'

    commandCommon_exec[$((i++))]='show memory summary'
    commandCommon__ksh[$((j++))]='show_memory_ng -s'
    commandCommon_exec[$((i++))]='show install active'
    commandCommon__ksh[$((j++))]='sdr_instcmd show install active'
elif [[ "$platform" = "viking" ]]; then
    commandCommon__ksh[$((j++))]='show_version'
    commandCommon__ksh[$((j++))]='dumper_context -c 0x1 -n all'
    commandCommon__ksh[$((j++))]='show_processes -b'
    commandCommon__ksh[$((j++))]='malloc_dump -A -F'

    commandCommon_exec[$((i++))]='show memory summary'
    commandCommon__ksh[$((j++))]='show_memory -s'
    commandCommon_exec[$((i++))]='show install active'
    commandCommon__ksh[$((j++))]='instcmd show install active'
else
    commandCommon__ksh[$((j++))]='show_version'
    commandCommon__ksh[$((j++))]='dumper_context -c 0x1 -n all'
    commandCommon__ksh[$((j++))]='show_processes -b'
    commandCommon__ksh[$((j++))]='malloc_dump_wrapper -A -F'
fi
    
commandCommon_exec[$((i++))]='show process failover'
commandCommon__ksh[$((j++))]='sysmgr_show -o -f'
commandCommon_exec[$((i++))]='show mrib mpls traffic-eng fast-reroute database summary'
commandCommon__ksh[$((j++))]='mrib_show_frr -h -g'
commandCommon_exec[$((i++))]='show placement program mpls_lsd'
commandCommon__ksh[$((j++))]='placed_show -p mpls_lsd'
commandCommon_exec[$((i++))]='show running-config'
commandCommon__ksh[$((j++))]='nvgen -c -l 1 -t 1 -o 1'
commandCommon_exec[$((i++))]='show mpls traffic-eng igp-areas detail $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x7 $standby_te__ksh -z 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng topology $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x2 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng topology srlg $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x17 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng topology model-type rdm $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x2 $standby_te__ksh -K 0x0'
commandCommon_exec[$((i++))]='show mpls traffic-eng topology model-type mam $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x2 $standby_te__ksh -K 0x1'
commandCommon_exec[$((i++))]='show isis database verbose'
commandCommon__ksh[$((j++))]='isis_show -l -v'
commandCommon_exec[$((i++))]='show ospf database opaque-area'
commandCommon__ksh[$((j++))]='ospf_show -T + -v + -l active -D -X 0x0 -Y 0x0 -f 0x0 -t 0xa -o 0x0 -a 0x0 -r 0x0 -i 0x0 -l 0x0 -m 0x0 -x 0x0 -y 0x0 -z 0x0'
commandCommon_exec[$((i++))]='show mpls traffic-eng affinity-map $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x9 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels auto-bw brief $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x13 $standby_te__ksh -E 0x2 ipv4 unicast -t 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels auto-bw private collect-list $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x13 $standby_te__ksh -E 0x3 ipv4 unicast -t 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels auto-bw private counters $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x13 $standby_te__ksh -E 0x4 ipv4 unicast -t 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels auto-bw private main-info $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x13 $standby_te__ksh -E 0x6 ipv4 unicast -t 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels auto-bw private collect-info $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x13 $standby_te__ksh -E 0x5 ipv4 unicast -t 0x2'
commandCommon_exec[$((i++))]='show mpls traffic-eng maximum tunnels $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0xb $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng topology summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x14 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng tunnels protection path log $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x16 $standby_te__ksh ipv4 unicast -d'
commandCommon_exec[$((i++))]='show mpls traffic-eng hw-oor summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x31 $standby_te__ksh'
commandCommon_exec[$((i++))]='show mpls traffic-eng lsp-oor summary $standby_exec'
commandCommon__ksh[$((j++))]='mpls_te_show 0x38 $standby_te__ksh'
commandCommon_exec[$((i++))]='show snmp interface'
commandCommon__ksh[$((j++))]='show_snmp_interface -a'
commandCommon_exec[$((i++))]='show mpls traffic-eng service egress-info all'
commandCommon__ksh[$((j++))]='mpls_te_show 0x26 --async_svr_cmd 0x2 --egress_info_type 0x5'
commandCommon_exec[$((i++))]='show mpls traffic-eng service summary'
commandCommon__ksh[$((j++))]='mpls_te_show 0x26 --async_svr_cmd 0x1'
commandCommon_exec[$((i++))]='show logging process te_control'
commandCommon__ksh[$((j++))]='show_logging -p te_control'
commandCommon_exec[$((i++))]='show logging process rsvp'
commandCommon__ksh[$((j++))]='show_logging -p rsvp'
commandCommon_exec[$((i++))]=''
commandCommon__ksh[$((j++))]=''

# TE general commands
i=1
j=1
commandTE_exec[$((i++))]='show mpls interfaces detail'
commandTE__ksh[$((j++))]='mpls_lsd_show -n -d -Z'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management advertisement $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x2'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management optical-nni advertisement $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x503'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management bandwidth-allocation $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x4'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management interface $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x40'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management optical-nni $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x501'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management igp $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x8'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management admission-control $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x1'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management optical-nni admission-control $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x502'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management statistics $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x80'
commandTE_exec[$((i++))]='show srlg'
commandTE__ksh[$((j++))]='show_rsi_agent_srlg -c -s'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels tabular $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -z 0x3'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels detail private role head $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -t 0x2 -9 0x2'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels detail private role middle $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -t 0x3 -9 0x2'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels detail private role tail $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -t 0x1 -9 0x2'
commandTE_exec[$((i++))]='show mpls traffic-eng counters signaling all $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0xc $standby_te__ksh -t 0x0'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels backup $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -w'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels protection private $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -q'
commandTE_exec[$((i++))]='show mpls traffic-eng fast-reroute database location $location'
commandTE__ksh[$((j++))]='fib_mpls_show_frr 0x1 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 -l $fq_nodeid'
commandTE_exec[$((i++))]='show mpls traffic-eng fast-reroute log location $location'
commandTE__ksh[$((j++))]='fib_mpls_show_frr 0x0 0x2 -l $fq_nodeid'
commandTE_exec[$((i++))]='show mpls traffic-eng preemption log'
commandTE__ksh[$((j++))]='mpls_lm_show -STDBY false 0x201'
commandTE_exec[$((i++))]='show mpls label table'
commandTE__ksh[$((j++))]='mpls_lsd_show -t 0x0 -Z'
commandTE_exec[$((i++))]='show mpls lsd forwarding summary'
commandTE__ksh[$((j++))]='mpls_lsd_fwd_show -s -Z'
commandTE_exec[$((i++))]='show mpls lsd forwarding tunnels'
commandTE__ksh[$((j++))]='mpls_lsd_fwd_show -T -Z'
commandTE_exec[$((i++))]='show mpls traffic-eng autoroute $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x4 $standby_te__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng forwarding $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x100'
commandTE_exec[$((i++))]='show mpls forwarding tunnels detail private no-counters'
commandTE__ksh[$((j++))]='fib_mpls_show_fwding -T -V -P -Z'
commandTE_exec[$((i++))]='show route'
commandTE__ksh[$((j++))]='show_ipv4_rib -X 0x1 -Y 0x1 -Z ________ -V ________ -s ipv4 ________'
commandTE_exec[$((i++))]='show ipv4 interface brief'
commandTE__ksh[$((j++))]='show_ip_interface -b -v default'
commandTE_exec[$((i++))]='show imds registrations all'
commandTE__ksh[$((j++))]='im_show registrations -v 0x2 -t 0x8'
commandTE_exec[$((i++))]='show isis adjacency'
commandTE__ksh[$((j++))]='isis_show -n'
commandTE_exec[$((i++))]='show isis mpls traffic-eng adjacency-log'
commandTE__ksh[$((j++))]='isis_show -u'
commandTE_exec[$((i++))]='show isis mpls traffic-eng advertisements'
commandTE__ksh[$((j++))]='isis_show -r'
commandTE_exec[$((i++))]='show isis mpls traffic-eng tunnel'
commandTE__ksh[$((j++))]='isis_show -w'
commandTE_exec[$((i++))]='show ospf neighbor'
commandTE__ksh[$((j++))]='ospf_show -T + -v + -l active -N -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -a 0x0 -d 0x0 -j 0x0'
commandTE_exec[$((i++))]='show ospf mpls traffic-eng link'
commandTE__ksh[$((j++))]='ospf_show -T + -v + -l active -m -X 0x0 -Y 0x0 -f 0x0 -t -l 0x0'
commandTE_exec[$((i++))]='show ospf mpls traffic-eng fragment'
commandTE__ksh[$((j++))]='ospf_show -T + -v + -l active -m -X 0x0 -Y 0x0 -f 0x0 -t -l 0x1'
commandTE_exec[$((i++))]='show mpls lsd trace location all'
commandTE__ksh[$((j++))]='mpls_lsd_trace_show -i all'
commandTE_exec[$((i++))]='show process te_control location all'
commandTE__ksh[$((j++))]='sysmgr_show -o -p te_control -n all'
commandTE_exec[$((i++))]='show process rsvp location all'
commandTE__ksh[$((j++))]='sysmgr_show -o -p rsvp -n all'
commandTE_exec[$((i++))]='show process isis'
commandTE__ksh[$((j++))]='sysmgr_show -o -p isis'
commandTE_exec[$((i++))]='show process ospf'
commandTE__ksh[$((j++))]='sysmgr_show -o -p ospf'
commandTE_exec[$((i++))]='show process mpls_lsd'
commandTE__ksh[$((j++))]='sysmgr_show -o -p mpls_lsd'
commandTE_exec[$((i++))]='show process rsi_master'
commandTE__ksh[$((j++))]='sysmgr_show -o -p rsi_master'
commandTE_exec[$((i++))]='show process rsi_agent'
commandTE__ksh[$((j++))]='sysmgr_show -o -p rsi_agent'
commandTE_exec[$((i++))]='show process log'
commandTE__ksh[$((j++))]='sysmgr_show -o -l all'
commandTE_exec[$((i++))]='show mpls lsd forwarding'
commandTE__ksh[$((j++))]='mpls_lsd_fwd_show -Z'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management bfd $standby_exec'
commandTE__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x200'
commandTE_exec[$((i++))]='show redundancy'
commandTE__ksh[$((j++))]='show_rmf_sysdb'
commandTE_exec[$((i++))]='show mpls traffic-eng ds-te te-class $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x6 $standby_te__ksh'

commandTE_exec[$((i++))]='show mpls traffic-eng chunks $standby_exec'
if [[ $standby_exec = "standby" ]];then
    commandTE__ksh[$((j++))]='mpls_show 0x2 te_control /oper/mpls_te/gl/standby/'
else
    commandTE__ksh[$((j++))]='mpls_show 0x2 te_control /oper/mpls_te/gl/'
fi

commandTE_exec[$((i++))]='show im registrations all location all \| incl te_control'
commandTE__ksh[$((j++))]='im_show registrations -t 0x8 -a | grep -E te_control'
commandTE_exec[$((i++))]='show mpls traffic-eng pce peer all $standby_exec'
commandTE__ksh[$((j++))]='te_pce_show $standby_te_bool__ksh 0x1 -p 0x0'
commandTE_exec[$((i++))]='show mpls traffic-eng pce trace $standby_exec'
commandTE__ksh[$((j++))]='te_pce_show_ltrace $standby_te_bool__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng pce tunnels $standby_exec'
commandTE__ksh[$((j++))]='te_pce_show $standby_te_bool__ksh 0x4'
commandTE_exec[$((i++))]='show mpls traffic-eng pce topology $standby_exec'
commandTE__ksh[$((j++))]='te_pce_show $standby_te_bool__ksh 0x2'
commandTE_exec[$((i++))]='show mpls traffic-eng pce stats $standby_exec'
commandTE__ksh[$((j++))]='te_pce_show $standby_te_bool__ksh 0x3'
commandTE_exec[$((i++))]='show mpls traffic-eng pce requests $standby_exec'
commandTE__ksh[$((j++))]='te_pce_show $standby_te_bool__ksh 0x5'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels protection path $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -d'
commandTE_exec[$((i++))]='show mpls traffic-eng auto-tunnel backup $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x19 $standby_te__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng auto-tunnel backup private $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x19 $standby_te__ksh -7'
commandTE_exec[$((i++))]='show mpls traffic-eng auto-tunnel mesh private $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1a $standby_te__ksh -7'
commandTE_exec[$((i++))]='show mpls traffic-eng attribute-set private $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x1b $standby_te__ksh -7'
commandTE_exec[$((i++))]='show mpls traffic-eng routes first-hop $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x2c $standby_te__ksh $standby_te__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng routes label $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x33 $standby_te__ksh $standby_te__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng autoroute-destination $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x30 $standby_te__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng service sr-policy $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x35 0x0 0x0 $standby_te__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng binding-sid context $standby_exec'
commandTE__ksh[$((j++))]='mpls_te_show 0x34 $standby_te__ksh'
commandTE_exec[$((i++))]='show igpte-lib trace location mgmt-nodes'
commandTE__ksh[$((j++))]='igpte_show_ltrace -i mgmt-nodes'
commandTE_exec[$((i++))]='show imds interface all'
commandTE__ksh[$((j++))]='im_show database -v 0x2'
commandTE_exec[$((i++))]='show adjacency'
commandTE__ksh[$((j++))]='aib_show_command'
commandTE_exec[$((i++))]='show rsvp api client te summary $standby_exec'
commandTE__ksh[$((j++))]='rsvp_ng_api_show -p 0x1 -s $standby_rsvp__ksh'
commandTE_exec[$((i++))]='show rsvp api client te ctx psrid all $standby_exec'
commandTE__ksh[$((j++))]='rsvp_ng_api_show -p 0x1 -R 0x1 $standby_rsvp__ksh'
commandTE_exec[$((i++))]='show rsvp api client te ctx csrid only $standby_exec'
commandTE__ksh[$((j++))]='rsvp_ng_api_show -p 0x1 -R 0x2 -O $standby_rsvp__ksh'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management optical-uni tabular'
commandTE__ksh[$((j++))]='mpls_te_show 0x27 -STDBY false -z 0x3'
commandTE_exec[$((i++))]='show igpte-lib stats te $standby_exec'
commandTE__ksh[$((j++))]='igpte_show_client $standby_igpte__ksh -T 0x2'
commandTE_exec[$((i++))]='show igpte-lib stats ospf $standby_exec'
commandTE__ksh[$((j++))]='igpte_show_client $standby_igpte__ksh -T 0x1'
commandTE_exec[$((i++))]='show igpte-lib stats isis $standby_exec'
commandTE__ksh[$((j++))]='igpte_show_client $standby_igpte__ksh -T 0x0'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels optical-uni tabular'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 ipv4 unicast -z 0x3 --optical_uni'
commandTE_exec[$((i++))]='show mpls traffic-eng tunnels optical-uni'
commandTE__ksh[$((j++))]='mpls_te_show 0x1 ipv4 unicast --optical_uni'
commandTE_exec[$((i++))]='show mpls traffic-eng link-management optical-uni'
commandTE__ksh[$((j++))]='mpls_te_show 0x27 -STDBY false'
commandTE_exec[$((i++))]='show mpls traffic-eng segment-routing'
commandTE__ksh[$((j++))]='mpls_te_show 0x2f'
commandTE_exec[$((i++))]='show igpte-lib prefix-registration ospf $standby_exec'
commandTE__ksh[$((j++))]='igpte_show_client $standby_igpte__ksh -T 0x4'
commandTE_exec[$((i++))]='show igpte-lib prefix-registration isis $standby_exec'
commandTE__ksh[$((j++))]='igpte_show_client $standby_igpte__ksh -T 0x3'
commandTE_exec[$((i++))]='sh mpls lib traffic-eng notification trace'
commandTE__ksh[$((j++))]='te_notification_lib_show -T 0xffff'
commandTE_exec[$((i++))]=''
commandTE__ksh[$((j++))]=''

# P2MP-specific commands
i=1
j=1
commandP2MP_exec[$((i++))]='show mpls traffic-eng tunnels p2mp concise $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh -M ipv4 unicast -z 0x5'
commandP2MP_exec[$((i++))]='show mpls traffic-eng tunnels brief $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh ipv4 unicast -z 0x1'
commandP2MP_exec[$((i++))]='show mpls traffic-eng counters global $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0xd $standby_te__ksh'
commandP2MP_exec[$((i++))]='show mpls traffic-eng counters fsm $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0xe $standby_te__ksh'
commandP2MP_exec[$((i++))]='show mpls traffic-eng counters sync-retry $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x32 $standby_te__ksh'
commandP2MP_exec[$((i++))]='show mpls traffic-eng collaborator-timers $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x11 $standby_te__ksh'
commandP2MP_exec[$((i++))]='show mpls traffic-eng database output-rw $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x103'
commandP2MP_exec[$((i++))]='show mpls traffic-eng database tunnel-rw $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x104'
commandP2MP_exec[$((i++))]='show mpls traffic-eng forwarding p2mp $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_lm_show $standby_te_bool__ksh 0x100 -Q'
commandP2MP_exec[$((i++))]='show mpls traffic-eng tunnels tabular p2mp $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh -M ipv4 unicast -z 0x3'
commandP2MP_exec[$((i++))]='show mpls traffic-eng tunnels p2mp $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x1 $standby_te__ksh -M ipv4 unicast'
commandP2MP_exec[$((i++))]='show mpls traffic-eng tunnels fsm'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x1 -F'
commandP2MP_exec[$((i++))]='show mpls traffic-eng chkpt all $standby_exec'
commandP2MP__ksh[$((j++))]='mpls_te_show 0x12 $standby_te__ksh --chkpt_option 0x8'
commandP2MP_exec[$((i++))]='show mrib mpls traffic-eng fast-reroute database summary'
commandP2MP__ksh[$((j++))]='mrib_show_frr -h -g'
commandP2MP_exec[$((i++))]='show mrib mpls traffic-eng fast-reroute database'
commandP2MP__ksh[$((j++))]='mrib_show_frr -h'
commandP2MP_exec[$((i++))]='show mrib mpls forwarding'
commandP2MP__ksh[$((j++))]='mrib_show_frr -p'
commandP2MP_exec[$((i++))]='show mrib mpls forwarding summary'
commandP2MP__ksh[$((j++))]='mrib_show_frr -p -q'
commandP2MP_exec[$((i++))]='show mrib client '
commandP2MP__ksh[$((j++))]='mrib_show -cmd 0x1'
commandP2MP_exec[$((i++))]='show mrib mpls route '
commandP2MP__ksh[$((j++))]='mrib_show -B 0x0 0x0'
commandP2MP_exec[$((i++))]='show prefix-list'
commandP2MP__ksh[$((j++))]='ipv4_prefix_show'
commandP2MP_exec[$((i++))]='show mpls traffic-eng trace client location mgmt-nodes'
commandP2MP__ksh[$((j++))]='mpls_te_client_show_ltrace -i mgmt-nodes'
commandP2MP_exec[$((i++))]=''
commandP2MP__ksh[$((j++))]=''

# LMP specific commands
#
# The debug commands here are show-like functionality (which should be changed)
i=1
j=1
commandLMP_exec[$((i++))]='show lmp clients'
commandLMP__ksh[$((j++))]='show_lmp_command -e'
commandLMP_exec[$((i++))]='show lmp gmpls optical-uni'
commandLMP__ksh[$((j++))]='show_lmp_command -A -Z UNI'
commandLMP_exec[$((i++))]='show lmp gmpls optical-uni ipcc'
commandLMP__ksh[$((j++))]='show_lmp_command -C -Z UNI'
commandLMP_exec[$((i++))]='show lmp gmpls optical-uni neighbor'
commandLMP__ksh[$((j++))]='show_lmp_command -M -Z UNI'
commandLMP_exec[$((i++))]='show lmp database client rsvp'
commandLMP__ksh[$((j++))]='show_lmp_command -g 0x0'
commandLMP_exec[$((i++))]='show lmp database client te'
commandLMP__ksh[$((j++))]='show_lmp_command -g 0x1'
commandLMP_exec[$((i++))]='show lmp database server'
commandLMP__ksh[$((j++))]='show_lmp_command -d'
commandLMP_exec[$((i++))]='show lmp trace client'
commandLMP__ksh[$((j++))]='show_lmp_command -t client -b 0x0'
commandLMP_exec[$((i++))]='show lmp trace default'
commandLMP__ksh[$((j++))]='show_lmp_command -t default -b 0x0'
commandLMP_exec[$((i++))]='show lmp trace errors'
commandLMP__ksh[$((j++))]='show_lmp_command -t errors -b 0x0'
commandLMP_exec[$((i++))]='show lmp trace interface'
commandLMP__ksh[$((j++))]='show_lmp_command -t interface -b 0x0'
commandLMP_exec[$((i++))]=''
commandLMP__ksh[$((j++))]=''

# Trace commands
i=1
j=1
commandTrace_exec[$((i++))]='show mpls traffic-eng trace tunnel-id-map $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x16 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace auto-bw $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0xb $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace bselect $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0xe $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace chkpt $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x7 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace default $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0xd $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace destroy $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x6 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace error $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0xa $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace event $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x1 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace fsm $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x5 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace generic $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x4 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace head-end $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x3 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace link $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x9 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace proc-fsm $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x12 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace sig $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x2 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace sync-updates $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x11 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace topology $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x8 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace automesh $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x10 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace segment-routing $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x15 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace bandwidth-accounting $standby_exec usec'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -s -T 0x18 $standby_te_trace__ksh'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace async-server location $location'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -i $fq_nodeid -T 0x13'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace instrument location $location'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -i $fq_nodeid -T 0xf'
commandTrace_exec[$((i++))]='show mpls traffic-eng trace unique location $location'
commandTrace__ksh[$((j++))]='mpls_te_show_ltrace -u -i $fq_nodeid -T 0x19'
commandTrace_exec[$((i++))]='show rsvp api client te trace unique location $location'
commandTrace__ksh[$((j++))]='rsvp_ng_api_show -u -i $fq_nodeid -p 0x1 -T 0x5'
commandTrace_exec[$((i++))]='show rsvp api client te trace errors location $location'
commandTrace__ksh[$((j++))]='rsvp_ng_api_show -i $fq_nodeid -p 0x1 -T 0x3'
commandTrace_exec[$((i++))]='show rsvp api client te trace warnings location $location'
commandTrace__ksh[$((j++))]='rsvp_ng_api_show -i $fq_nodeid -p 0x1 -T 0x2'
commandTrace_exec[$((i++))]='show rsvp api client te trace events location $location'
commandTrace__ksh[$((j++))]='rsvp_ng_api_show -i $fq_nodeid -p 0x1 -T 0x1'
commandTrace_exec[$((i++))]='show rsvp api client te trace history location $location'
commandTrace__ksh[$((j++))]='rsvp_ng_api_show -i $fq_nodeid -p 0x1 -T 0x4'
commandTrace_exec[$((i++))]='show rsvp api trace errors location $location'
commandTrace__ksh[$((j++))]='rsvp_ng_api_show -i $fq_nodeid -p 0x0 -T 0x3'
commandTrace_exec[$((i++))]='show rsi clients name te_control location $location'
commandTrace__ksh[$((j++))]='show_rsi_agent -c 0x29 -n te_control -l $fq_nodeid'
commandTrace_exec[$((i++))]=''
commandTrace__ksh[$((j++))]=''


# Initialise any variables used. 
standby_exec=""
standby_te__ksh=""
standby_te_bool__ksh="-STDBY false"
standby_te_trace__ksh=""
standby_igpte__ksh="-S 0x0"
standby_rsvp__ksh=""


# Parse the arguments to the script.
# Usage: 
# 
#    mpls_te_show_tech [-N] 
#
while [ "$#" -gt "0" ]; do
  case "$1" in
     -N) stdby="standby";shift 1;;
     *)  default_parser_function "$@"; shift $#;;
  esac
done

# Find if the current location is active or standby RP.
. /pkg/bin/mpls_te_show_tech_helper

# A function called display() must be provided that calls the functions to 
# run the required show commands. The display() function is called in 
# /pkg/bin/show_tech_comp_file_frag

display() {
    # Print the output heading 
    print_main_heading "show tech-support mpls traffic-eng"
 
    if is_standby "te_control" $ext_node_name; then
        standby_exec="standby"
        standby_te__ksh="--standby"
        standby_te_bool__ksh="-STDBY true"
        standby_te_trace__ksh="-Stdby standby-only"
        standby_igpte__ksh="-S 0x1"
        standby_rsvp__ksh="-S"
    fi
  
    exec_commands commandCommon

    # Grab the traces first, before they wrap
    exec_commands commandTrace

    # Run Common and TE general commands
    exec_commands commandCommon
    exec_commands commandTE

    # Run P2MP commands
    exec_commands commandP2MP 

    # Run LMP commands
    exec_commands commandLMP
     
    # Print the closing heading. 
    print_main_heading "show tech-support mpls traffic-eng complete"
}


# This function calls the display() function and sends the output to file if
# the file option has been set. 
. /pkg/bin/show_tech_file_fragment
