#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# call_home_show_tech_fast - show commands for show tech-support 
#                     call-home spawned by show_tech_fast
#
# Nov 2011, Long Yang 
#
# Copyright (c) 2010, 2013-2014, 2016-2017 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 "call_home_show_tech_fast: output file not specified"
    exit
fi

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

# Check platform type.
uname -a | grep hfr > /dev/null 2>&1;  RC=$?
uname -a | grep prp > /dev/null 2>&1;  RC1=$?
uname -a | grep enxr > /dev/null 2>&1; RC2=$?
uname -a | grep asr9k > /dev/null 2>&1; RC3=$?

if [[ "$RC" -eq "0" ]]; then
    platform="hfr"
elif [[ "$RC1" -eq "0" ]]; then
    platform="prp"
elif [[ "$RC2" -eq "0" ]]; then
    platform="enxr"
elif [[ "$RC3" -eq "0" ]]; then
    platform="viking"
else
    platform="panini"
fi

# ***********************************************************
#  Show commands to be run by the show tech-support commands
# ***********************************************************
# 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 version"
if [[ "$platform" = "panini" ]]; then
    sys__ksh[2]='ng_show_version'
else
    sys__ksh[2]='show_version'
fi
sys_exec[3]="show call-home detail"
sys__ksh[3]='show_callhome -C -t 1'
sys_exec[4]="show call-home mail-server status"
sys__ksh[4]='show_callhome -M'
sys_exec[5]="show call-home statistics"
sys__ksh[5]='show_callhome -S -t 0'
sys_exec[6]="show call-home trace all"
sys__ksh[6]='call_home_show_ltrace -A'
sys_exec[7]="show call-home events"
sys__ksh[7]='show_callhome -C -t 2'
sys_exec[8]="show call-home smart-licensing"
sys__ksh[8]='show_callhome -L -t 0'
sys_exec[9]="show call-home smart-licensing statistics"
sys__ksh[9]='show_callhome -L -t 1'
sys_exec[10]="show processes call_home detail"
sys__ksh[10]='sysmgr_show -o -p call_home -D'
sys_exec[11]="show logging"
sys__ksh[11]='show_logging'

sys__ksh[12]=''

display() {
    print_main_heading "show tech-support call-home"
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    fi
    print_main_heading "show tech-support call-home complete"

    enable_techs "-t $__cardtype" /pkg/bin/show_tech_eem_fast
    enable_techs "" /pkg/bin/show_tech_xoslib
}

# 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
