#!/bin/bash
#
# show commands for show tech-support
#
# July 2016, Neil McGill
#
# Copyright (c) 2016-2018 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_smartlic_fast: output file not specified"
    exit
fi

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

# Commands that run once per system
sys_exec[1]="show running-config"
sys__ksh[1]='nvgen -c -l 1 -t 1 -i1 -o 1'
sys_exec[2]="show install active"
sys__ksh[2]='sdr_instcmd show install active'
sys_exec[3]="show redundancy"
sys__ksh[3]='redcon_show'
sys_exec[4]="show logging"
sys__ksh[4]='show_logging'
sys_exec[5]="show kim tech-support"
sys__ksh[5]='kim_show_edm -t'
sys_exec[6]="show kim status"
sys__ksh[6]='kim_show_edm -0 default'
sys_exec[7]="show kim status vrf all"
sys__ksh[7]='kim_show_edm -0 all'
sys_exec[8]="show kim vrf all"
sys__ksh[8]='kim_show_edm -3 all'
sys_exec[9]="show kim interface"
sys__ksh[9]='kim_show_edm -1'
sys_exec[10]="show kim lpts"
sys__ksh[10]='kim_show_edm -2'
sys_exec[11]="show kim trace"
sys__ksh[11]='kim_show_ltrace'
sys_exec[12]="show kim lpts internal"
sys__ksh[12]='kim_show_edm -8'

display() {
    print_main_heading "show tech-support kim"

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
        exec_commands admin
    fi

    print_main_heading "show tech-support kim 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
