#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_smartlic_fast - show commands for show tech-support 
#                                smartlic spawned by show_tech_fast
#
# May 2015, Sreejith Sreekumaran
#
# Copyright (c) 2015-2020 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

# ***********************************************************
#  Show commands to be run by the show tech-support commands
#  running config helps in seeing the configuration of the 
#  sytem.
#  call-home related logs help in debugging any transport layer issues
#  when talking back to the CSSM/Satellite
#  show logging helps in seeing all the syslogs generated
#  install active helps in understanding all the active 
#  packages on the box 
# ***********************************************************

# Commands that run on 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 call-home detail"
sys__ksh[5]='show_callhome -C -t 1'
sys_exec[6]="show call-home trace all"
sys__ksh[6]='call_home_show_ltrace -A'
sys_exec[7]="show call-home smart-licensing"
sys__ksh[7]='show_callhome -L -t 0'
sys_exec[8]="show call-home smart-licensing statistics"
sys__ksh[8]='show_callhome -L -t 1'
sys_exec[9]="show processes call_home detail"
sys__ksh[9]='sysmgr_show -o -p call_home -D'
sys_exec[10]="show xos errors"
sys__ksh[10]='show_xos_command gen_error_traces'
sys_exec[11]="show inventory"
sys__ksh[11]='show_inventory -e'
sys_exec[12]="show ip int br"
sys__ksh[12]='show_ip_interface -b -v all'
sys_exec[13]="show int br"
sys__ksh[13]='show_interface -a -o 0x2'
sys_exec[13]="show http client trace all"
sys__ksh[13]='httpc_show_ltrace 0x0 0x10000000'
sys__ksh[14]=''

# Exec Plane Commands
admin_exec[1]="show license udi"
admin__ksh[1]='smartliccmdexr show license smart udi'
admin_exec[2]="show license techsupport"
admin__ksh[2]='smartliccmdexr show license smart techsupport'
admin_exec[3]="show license trace smartlic"
admin__ksh[3]='smartlic_show_smartlic_ltrace'
admin_exec[4]="show license trace client location all"
admin__ksh[4]='smartlic_show_ltrace'
admin_exec[5]="show license trace all"
admin__ksh[5]='smartlic_show_all_ltrace'
admin_exec[6]="sh diag details"
admin__ksh[6]='show_diag -t'
admin_exec[7]="sh license platform detail"
admin__ksh[7]='plat_sl_show detail'
admin_exec[8]="sh license platform summary"
admin__ksh[8]='plat_sl_show summary'
admin_exec[9]="sh license platform trace all"
admin__ksh[9]='plat_sl_ltrace_show -I -E -D'
admin__ksh[10]=''

cp="/bin/cp"
mkdir="/bin/mkdir"
node_name=`uname -n`
node_subdir=$__tar_file_directory_on_node/$node_name

if [ ! -d "$node_subdir" ]; then
     $mkdir $node_subdir
fi
a=(/var/log/license/plat_sl.log*)
if [ -f "$a" ]; then
   $cp /var/log/license/plat_sl.log* $node_subdir
fi

b=(/var/log/license/smart_lic_detail.log*)
if [ -f "$b" ]; then
   $cp /var/log/license/smart_lic_detail.log* $node_subdir
fi
c=(/etc/build-info.txt)

if [ -f "$b" ]; then
   ver_log1_exec[1]="run cat /etc/build-info.txt"
   ver_log1__ksh[1]='cat /etc/build-info.txt'
   ver_log1__ksh[2]=''
   exec_commands ver_log1
fi 

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

    if [[ "$__cardtype" == "RP" || "$__cardtype" == "DRP" ]]; then
        exec_commands sys
        exec_commands admin
    fi

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