#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_ether - Show tech-support script for ethernet
#
# July 2006, Ross Denham
#
# Copyright (c) 2006-2008, 2012 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 all'
command1[2]='show context location all'
command1[3]='show redundancy location all'
command1[4]='show logging'
command1[5]='show cdp'
command1[6]='show processes cdp location all'
command1[7]='show version'
command1[8]='show configuration history'
command1[9]=''   

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

# Command 3 - Local show commands (not supporting location all)
command3[0]='show cdp neighbors location $location'
command3[1]='show cdp traffic location $location'
command3[2]=''

# 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]='show cef $external_if location $location'                 
command4[3]=''

# Initialise any variables used. 
                                                       
internal_if="unspecified"
external_if=""
ether_arg_string=""
bundle_arg_string=""

# Parse the arguments to the script.
# Usage: 
# 
# -I  : Run commands for a specific interface
# -V  : Specify a specific VRF
# -T  : Collect trace only
# -S  : Collect show commands only  
while [ $# -gt 0 ]; do
  case "$1" in
     -I) internal_if="$2"; shift 2;;
     *)  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() {
     #
     # Note: 'interface' is the only supported option (and this only adds 
     # information, doesn't filter any).  
     #
     # Some commands do not support "location all" - so call these for each 
     # location.
     #
     
     # Print the output heading 
     print_main_heading "show tech-support ethernet interfaces" 

     run_commands 1

     #
     # Script to get all config events from cfgmgr history, and for each event
     # show the details.
     #
     . /pkg/bin/show_tech_config_history
     
     run_commands_on_all_nodes 3
                        
     if [ "$internal_if" != "unspecified" ]; then
         external_if=`convert_interface_fmt '-e' $internal_if`
         run_commands 2 
         run_commands_on_all_nodes 4
         
         ether_arg_string="$ether_arg_string -I $internal_if"
     fi

     run_module show_tech_ether_common "$ether_arg_string"
     run_module show_tech_ether_only
     run_module show_tech_bundle_common
     run_module show_tech_ether_pd "$ether_arg_string"
     run_module cfm_show_tech
     run_module l2vpn_show_tech_bridging
     run_module show_tech_elo
     
     # Print the closing heading. 
     print_main_heading "show tech-support ethernet 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



