#!/pkg/bin/ksh          
# ---------------------------------------------------------------------
# show_tech_ppp - Show tech-support script for ppp
#
# July 2006, Ross Denham
#
# Copyright (c) 2006, 2008-2009, 2011 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 - traces 
command1[0]='show ppp trace all location $location'      
command1[1]=''   

# Command 2 - Global show commands (supporting location all or running globally)              
command2[0]='show processes ppp_ma location $location'
command2[1]='show processes ppp_ea location $location'
command2[2]='show processes ppp_socket location $location'
command2[3]='' 

# Command 3 - Local show commands (not supporting location all)    
command3[0]='show ppp interfaces location $location'
command3[1]='show ppp ea interface all location $location'
command3[2]='show ppp summary location $location'
command3[3]='show ppp statistics extended location $location'
command3[4]='show ppp api calls location $location'
command3[5]='show ppp disconnect-history location $location'
command3[6]='show ppp disconnect-history detail location $location'
command3[7]=''

# Command 4 - Interface specific commands (not supporting location all)
command4[0]=''


# Command 5 - Interface specific commands (running globally)
command5[0]='show ppp idb $external_if'
command5[1]='show ppp statistics interface $external_if'
command5[2]=''

# Initialise variables

internal_if="unspecified"
external_if=""  
trace_only="0"
show_only="0"

# Parse the arguments to the script.
# Usage: 
# 
# -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 common"

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

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

            run_commands 5
        fi
     fi

     if [ "$show_only" = "0" ]; then
        run_commands 1
     fi  

     # Print the closing heading. 
     print_main_heading "show tech-support ppp common complete"
}

display



