#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_qos_pd - PD QOS specific show tech command for LS 
#
# April 2018, Sravanthi
#
# Copyright (c) 2008-2009, 2017-2018, 2020-2021 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_qos_pd: output file not specified"
    exit
fi

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

PLATFORM_TYPE=`uname -m`

# ***********************************************************
#  Show commands to be run by the show tech-support commands
# ***********************************************************

#############################################################
# Show commands that run once per system
sys_show_exec[1]='show version'
sys_show__ksh[1]='ng_show_version'
sys_show_exec[2]='show logging'
sys_show__ksh[2]='show_logging'
sys_show_exec[3]='show interfaces summary'
sys_show__ksh[3]='show_interface -a -o 0x3'
sys_show_exec[4]='show interfaces brief'
sys_show__ksh[4]='show_interface -a -o 0x2'
sys_show_exec[5]='show running-config'
sys_show__ksh[5]='nvgen -c -l 1 -t 1 -o 1'
sys_show_exec[6]='show policymap targets'
sys_show__ksh[6]='policymgr_show -A -B 0x1'
sys_show_exec[7]='show processes policymgr_rp'
sys_show__ksh[7]='sysmgr_show -o -p policymgr_rp'
sys_show_exec[8]='show uidb data-dump'
sys_show__ksh[8]='uidb_show data-dump -a'
sys_show_exec[9]='show bundle'
sys_show__ksh[9]='bundlemgr_show -b'
sys_show_exec[10]='show bundle ea members'
sys_show__ksh[10]='bundlemgr_ea_show -m -a'
sys_show_exec[11]='show run policy-map'
sys_show__ksh[11]='nvgen -c -q gl/policymgr/policymap/'
sys_show_exec[12]='show run class-map'
sys_show__ksh[12]='nvgen -c -q gl/policymgr/classmap/'
sys_show_exec[13]='show processes ancp'
sys_show__ksh[13]='sysmgr_show -o -p ancp'
sys_show_exec[14]='show configuration failed'
sys_show__ksh[14]='cfgmgr_show_failed -c'
#End
sys_show__ksh[15]=''

# Trace
sys_trace_exec[1]='show policymgr process trace all location all'
sys_trace__ksh[1]='show_ltrace_policymgr -i all -A'
sys_trace_exec[2]='show policy-lib trace all location all'
sys_trace__ksh[2]='show_ltrace_pllib -i all -A'
sys_trace_exec[3]='show qos-lib trace client qos_ea both location all'
sys_trace__ksh[3]='qos_lib_show_ltrace -i all -C qos_ea -W -U'
sys_trace_exec[4]='show qos-ma trace location all'
sys_trace__ksh[4]='show_qos_ma_ltrace -i all'
sys_trace_exec[5]='show qos-ea trace all location all'
sys_trace__ksh[5]='qos_ea_show_ltrace -i all -A'
#End
sys_trace__ksh[6]=''


#############################################################
# Commands that run on RP and LC nodes

# Show commands

# Show procs
rplc_show_exec[1]='show process blocked'
rplc_show__ksh[1]='sh_proc_ng_blocked'
rplc_show_exec[2]='show processes qos_ma'
rplc_show__ksh[2]='sysmgr_show -o -p qos_ma'
#End
rplc_show__ksh[3]=''

#############################################################
# Commands that run on all LCs
count=1
lc_exec[count]='show qos summary police location $location input'
lc__ksh[count]='qos_ea_show_interface -u summary -t police -d input -l $fq_nodeid'
let count+=1
lc_exec[count]='show qos summary police location $location output'
lc__ksh[count]='qos_ea_show_interface -u summary -t police -d output -l $fq_nodeid'
let count+=1
lc_exec[count]='show qos summary queue location $location input sw'
lc__ksh[count]='qos_ea_show_interface -u summary -t queue -d input -l $fq_nodeid -z sw'
let count+=1
lc_exec[count]='show qos summary queue location $location output sw'
lc__ksh[count]='qos_ea_show_interface -u summary -t queue -d output -l $fq_nodeid -z sw'
let count+=1
lc_exec[count]='show controllers np counters all location $location'
lc__ksh[count]='prm_np_show counters -s $fq_nodeid'
let count+=1
lc_exec[count]='show processes qos_ma_ea location $location'
lc__ksh[count]='sysmgr_show -o -p qos_ma_ea -n $fq_nodeid'
let count+=1
lc_exec[count]='show qos-ea ha state location $location'
lc__ksh[count]='qos_ea_show_ha -p $fq_nodeid -S'
let count+=1
lc_exec[count]='show qos-ea ha chkpt all info $location'
lc__ksh[count]='qos_ea_show_ha -p $fq_nodeid -t 0x7 -I' 
let count+=1
lc_exec[count]='show qoshal resource summary location $location'
lc__ksh[count]='nphal_show_chk -p $fq_nodeid resource summary'
let count+=1
lc_exec[count]='show qoshal trace location $location'
lc__ksh[count]='qoshal_show_ltrace -i $fq_nodeid'
let count+=1
lc_exec[count]='show controllers np tm counters all'
lc__ksh[count]='prm_np_show TM counters'
let count+=1
lc_exec[count]='show processes qos_ma location $location'
lc__ksh[count]='sysmgr_show -o -p qos_ma -n $fq_nodeid'
let count+=1
lc_exec[count]='show qos capability location $location'
lc__ksh[count]='qos_ea_show_interface -y capability -l $fq_nodeid'
let count+=1
lc_exec[count]='show qos inconsistency summary location $location'
lc__ksh[count]='qos_ea_show_interface -a inconsistency -l $fq_nodeid'
let count+=1
lc_exec[count]='show qos inconsistency detail 0 location $location'
lc__ksh[count]='qos_ea_show_interface -a inconsistency -v 0x0 -l $fq_nodeid'
let count+=1
lc_exec[count]='show controllers fabric fia drops ingress location $location'
lc__ksh[count]='fsi_show -n $fq_nodeid -f -d -N'
let count+=1
lc_exec[count]='show controllers fabric fia drops egress location $location'
lc__ksh[count]='fsi_show -n $fq_nodeid -f -d -E'
let count+=1
lc_exec[count]='show controllers rm  uidb trace all location all'
lc__ksh[count]='lightspeed_uidb_show_ltrace -J -i all'
let count+=1
lc_exec[count]='show controllers rm  trm trace all location all'
lc__ksh[count]='trm_show_ltrace -J -i all'
let count+=1
lc_exec[count]='show controllers rm tcam trace event location $location'
lc__ksh[count]='ls_tcam_show_ltrace -i $fq_nodeid -V'
let count+=1
lc_exec[count]='show controllers rm tcam trace error location $location'
lc__ksh[count]='ls_tcam_show_ltrace -i $fq_nodeid -E'
let count+=1
lc_exec[count]='show controllers rm stats trace client qos_ma_ea all location $location'
lc__ksh[count]='ls_stats_show_ltrace -i $fq_nodeid -C qos_ma_ea -A'
let count+=1
lc_exec[count]='show controllers rm edrm trace client group all member all all location $location'
lc__ksh[count]='edrm_show_ltrace -i $fq_nodeid -C -G 0x11 -B 0x100 -E -I -M -W'
let count+=1
lc_exec[count]='show qos summary police location $location input'
lc__ksh[count]='qos_ea_show_interface -u summary -t police -d input -l $fq_nodeid'
let count+=1
lc_exec[count]='show qos summary police location $location output'
lc__ksh[count]='qos_ea_show_interface -u summary -t police -d output -l $fq_nodeid'
let count+=1
lc_exec[count]='show qos summary queue location $location input sw'
lc__ksh[count]='qos_ea_show_interface -u summary -t queue -d input -l $fq_nodeid -z sw'
let count+=1
lc_exec[count]='show qos summary queue location $location output sw'
lc__ksh[count]='qos_ea_show_interface -u summary -t queue -d output -l $fq_nodeid -z sw'
let count+=1
lc_exec[count]='show controllers np counters all location $location'
lc__ksh[count]='prm_np_show counters -s $fq_nodeid'
let count+=1
lc__ksh[count]=''





#############################################################
# Commands that run on all RPs
#End
rp__ksh[0]=''

#############################################################
# Commands that run on all SCs
sc__ksh[0]=''

#############################################################
# Commands that run on all SPs
sp__ksh[0]=''

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

display() {
    print_main_heading "show tech-support qos pd"
        
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys_show
	  exec_commands sys_trace
    else
        case "$__cardtype" in
        "RP")
            exec_commands rplc_show
            exec_commands rp
            ;;
        "DRP")
            exec_commands rplc_show
            exec_commands rp
            ;;
        "LC")
            exec_commands rplc_show
            exec_commands lc
            ;;
        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
