#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_chassis_ctrl - Satellite chassis ctrl infra Tech-support
#
# October 2016
#
# Copyright (c) 2016-2019 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 [ "$__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_show_exec[1]='show logging'
sys_show__ksh[1]='show_logging'
sys_show_exec[2]='show platform'
sys_show__ksh[2]='show_platform_sysdb'
sys_show_exec[3]='show version'
sys_show__ksh[3]='ng_show_version'
sys_show_exec[4]='sh processes sat_chassis_ctrl'
sys_show__ksh[4]='sysmgr_show -o -p sat_chassis_ctrl'
sys_show_exec[5]='sh install active'
sys_show__ksh[5]='sdr_instcmd show install active'
sys_show_exec[6]='sh context'
sys_show__ksh[6]='corehelper_context -c 0x1 -n all'
sys_show_exec[7]='sh processes blocked'
sys_show__ksh[7]='sh_proc_ng_blocked'

# infra specific commands                         
infra_show_exec[1]='show inventory'                   
infra_show__ksh[1]='show_inventory -e'               
infra_show_exec[2]='show environment nv satellite all'
infra_show__ksh[2]='show_satellite_envmon -A'

# Inventory trace
infra_show_exec[3]='show nv satellite trace internal platform inventory all'
infra_show__ksh[3]='sat_chassis_show_ltrace -F satinvmgr/all'

# Sat chassis controller trace
infra_show_exec[4]='show nv satellite trace internal platform controller all'
infra_show__ksh[4]='sat_chassis_show_ltrace -F satctrl/all'

# Envmon trace
infra_show_exec[5]='show nv satellite trace internal platform envmon all'
infra_show__ksh[5]='sat_chassis_show_ltrace -F satenvmon/all'

# Envmon slow trace 
infra_show_exec[6]='show nv satellite trace internal platform envmon-slow all'
infra_show__ksh[6]='sat_chassis_show_ltrace -F satenvmon-slow/all'

# To get sdr instance
infra_show_exec[7]='sh placement program all'
infra_show__ksh[7]='placed_show -p all'

#SatID-RackID table display
infra_show_exec[8]='show nv satellite racks'
infra_show__ksh[8]='show_satellite_rackid'

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

display() {
    print_main_heading "show tech-support sat_chassis_ctrl"
    
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys_show
    else
        exec_commands infra_show
    fi
    enable_techs "" /pkg/bin/show_tech_satellite_platform
    enable_techs "" /pkg/bin/sysdb_show_tech_support_fast show_tech_sdr_mgbl_fast   
    enable_techs "" /pkg/bin/sysdb_show_tech_support_fast placed_show_tech_support_fast

    set_max_depth 3 

    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

