#!/pkg/bin/ksh
#---------------------------------------------------------------------------
#
# show tech-support sysmgr command
#
# March 2009, Kiran Rathna Kempahanumaiah
#
# Copyright (c) 2009, 2012-2014, 2017-2018, 2020 by cisco Systems, Inc.
# All rights reserved.
#----------------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

sys_exec[1]='show version'

if [[ "$platform" = "panini" ]]; then
    sys__ksh[1]='ng_show_version'
else
    sys__ksh[1]='show_version'
fi

sys_exec[2]='show redundancy summary'
sys__ksh[2]='redcon_show -s'
sys_exec[3]='show redundancy'
sys__ksh[3]='redcon_show'
sys_exec[4]='show redundancy trace location all'
sys__ksh[4]='show_rmf_trace -ESDL -i all'
sys__ksh[5]=''

dumpcore_location_cmds_exec[1]='dumpcore running processmgr '
dumpcore_location_cmds__ksh[1]=' corehelper_gen -o running -p processmgr'
dumpcore_location_cmds__ksh[2]=''

current_location_cmds_exec[1]='run sysmgr_show -o -l all '
current_location_cmds__ksh[1]='sysmgr_show -o -l all '
current_location_cmds_exec[2]='show log local location $location'
current_location_cmds__ksh[2]='show_local_log '
current_location_cmds_exec[3]='run sysmgr_show -o -b '
current_location_cmds__ksh[3]='sysmgr_show -o -b '
current_location_cmds_exec[4]='run cmp_dbg -i pm'
current_location_cmds__ksh[4]='cmp_dbg -i pm'
current_location_cmds_exec[5]='run show_libcmp_trace -F all'
current_location_cmds__ksh[5]='show_libcmp_trace -F all'
current_location_cmds_exec[6]='show processes boot-stalled'
current_location_cmds__ksh[6]='sysmgr_show -B'
current_location_cmds_exec[7]='run sysmgr_show -h'
current_location_cmds__ksh[7]='sysmgr_show -h'
current_location_cmds_exec[8]='run /pkg/bin/show_tech_enf '
current_location_cmds__ksh[8]='/pkg/bin/show_tech_enf'
current_location_cmds_exec[9]='run ps -ef'
current_location_cmds__ksh[9]='ps -ef'
current_location_cmds_exec[10]='run ifconfig -a'
current_location_cmds__ksh[10]='ifconfig -a'
current_location_cmds__ksh[11]=''

fo_location_cmds_exec[1]='run sysmgr_show -o -f '
fo_location_cmds__ksh[1]='sysmgr_show -o -f '
fo_location_cmds__ksh[2]=''

dumpcore=0;
__cardtype="unspecified";


while [ "$#" -gt "0" ]; do
    case "$1" in
       -D) dumpcore=1; 
           shift 1;;
       -t) __cardtype="$2"; shift 2;;
       -l) location="$2"; shift 2;; 
        *) default_parser_function $@; shift $#;;  
    esac
done

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

display() {

    print_main_heading "show tech-support processmgr"

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "DRP"|"RP")
            if [ "$dumpcore" == "1" ]; then
                exec_commands dumpcore_location_cmds
            fi
            exec_commands current_location_cmds
            exec_commands fo_location_cmds
            ;;
         "SC")
            if [ "$dumpcore" == "1" ]; then
                exec_commands dumpcore_location_cmds
            fi
            exec_commands current_location_cmds
            exec_commands fo_location_cmds
            ;;
         "LC")
             if [ "$dumpcore" == "1" ]; then
                exec_commands dumpcore_location_cmds
             fi
             exec_commands current_location_cmds
            ;;
         esac
    fi
    
    #Include show tech placed, tech ds
    enable_techs "" /pkg/bin/placed_show_tech_support_fast show_tech_ds_fast    
    set_max_depth 2

    print_main_heading "show tech-support processmgr complete"
}

. /pkg/bin/show_tech_file_fragment

