#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# ot_show_tech - Show tech-support for Object Tracking
#
# October 2018, Dhananjay S. Patki
#
# Copyright (c) 2018 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

#
# Load the script provided by show-tech infra, which provides worker functions
#
. /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

node_name_internal=$showtech_node_name
node_number=`node_conversion -i $node_name_internal`

###############################################################################
# Show commands that run once per LR                                          #
###############################################################################
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 install active'
if [[ "$platform" == "panini" ]]; then
    sys__ksh[2]='sdr_instcmd show install active'
else
    sys__ksh[2]='instcmd show install active'
fi

sys_exec[3]='show running-config'
sys__ksh[3]='nvgen -c -l 1 -t 1 -o 1'

sys_exec[4]='show process object_tracking location all'
sys__ksh[4]='sysmgr_show -o -p object_tracking -n all'

sys_exec[5]='show context location all'
if [[ "$platform" == "panini" ]]; then
    sys__ksh[5]='corehelper_context -c 0x1 -n all'
else
    sys__ksh[5]='dumper_context -c 0x1 -n all'
fi

sys_exec[6]='show redundancy location all'
sys__ksh[6]='redcon_show -n all'

sys_exec[7]='show logging'
sys__ksh[7]='show_logging'

sys_exec[8]=''
sys__ksh[8]=''

###############################################################################
# Show commands that run on every RP                                          #
###############################################################################

# misc info
rp_exec[1]='show track'
rp__ksh[1]='object_tracking_cmd show track all-tracks all'

rp_exec[2]='show track trace'
rp__ksh[2]='show_track_ltrace'

rp_exec[3]=''
rp__ksh[3]=''


display() {
     
    # Print the output heading
    print_main_heading "show tech-support object_tracking"

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "DRP"|"RP")
            exec_commands rp
            ;;
        "LC")
            ;;
        esac
    fi

    # Print the closing heading.
    print_main_heading "show tech-support object_tracking 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


