#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_ppp_main - Show tech-support script for ppp
#
# October 2008, Matthew Edwards
# Copyright (c) 2008-2009, 2014, 2017 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------


# This script fragment contains the code for the following functions
# - print_main_heading
# - print_command_heading
# - run_single_command
# - run_commands
# - run_single_command_on_all_nodes
# - run_commands_on_all_nodes
# - default_parser_function

. /pkg/bin/show_tech_main_fragment

# List each set of show commands to be run. Each set must finish with an empty
# string. Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands. 

# Command 1 - generic commands 
command1[0]='show running-config'      
command1[1]='show process blocked location $location'
command1[2]='show context location $location'
command1[3]='show redundancy location $location'
command1[4]='show logging'
command1[5]=''   

# Command 2 - Interface specific commands (global or supporting location all)             
command2[0]='show interfaces $external_if'
command2[1]='show controllers $external_if' 
command2[2]='show adjacency $external_if location all'
command2[3]='show imds interface $external_if'
command2[4]='' 

# Command 3 - Local show commands (not supporting location all)
command3[0]='show interfaces brief location $location'
command3[1]=''

# Command 4 - Interface specific commands (not supporting location all)
command4[0]='show im chains $external_if location $location'
command4[1]='show netio chains $external_if location $location' 
command4[2]=''                 

# Initialise any variables used. 
                                                       
internal_if="unspecified"
external_if=""
trace_only="0"
show_only="0"
arg_string=""

# Parse the arguments to the script.
# Usage: 
# 
# -I  : Run commands for a specific interface
# -T  : Collect trace only
# -S  : Collect show commands only  
while [ $# -gt 0 ]; do
  case "$1" in
     -I) internal_if="$2"; shift 2;;
     -T) trace_only="1"; shift 1;;
     -S) show_only="1"; shift 1;;
     *)  default_parser_function "$@"; shift $#;;
  esac
done

# A function called display() must be provided that calls the functions to 
# run the required show commands. The display() function will be called in 
# the /pkg/bin/show_tech_comp_file_frag

display() {

     # Print the output heading 
     print_main_heading "show tech-support ppp"

     run_commands 1

     if [ "$internal_if" != "unspecified" ]; then
         external_if=`convert_interface_fmt '-e' $internal_if`
         run_commands 2 
         if [ "$location" = "all" ]; then
             run_commands_on_all_nodes 4
         else
             run_commands 4
         fi
     fi

     if [ "$location" = "all" ]; then
         run_commands_on_all_nodes 3
     else
         run_commands 3
     fi

     if [ "$internal_if" != "unspecified" ]; then
        arg_string="$arg_string -I $internal_if"
     fi

     if [ "$trace_only" != "0" ]; then
         arg_string="$arg_string -T"
     fi

     if [ "$show_only" != "0" ]; then
         arg_string="$arg_string -S"
     fi

     run_module show_tech_ppp "$arg_string"

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




