#!/usr/bin/sh
#############
# Copyright 11/20/00 Sun Microsystems, Inc. All Rights Reserved         
#############
# x25info tool
##############

. /etc/snet_info

USAGE="Usage:  x25info [-h | -l] \n\
\t-h\tget some help (this) \n\
\t-ln\tspecify the link number (n)" 


if [ $# = 0 ]
then
echo $USAGE
echo Configuration:
awk '{ if ($1 == "device") { print "Link " substr(FILENAME, 43, 3) " : " $1 " " $2 " " $3 " " $4 " " $5 " " $6 }}' $X25CONFIGFILES/config/link_config_0*.cfg
else

while getopts "hl:" ARG
do
    case $ARG in
	\?)      echo $USAGE; exit 2;;
        h)       echo $USAGE; exit 0;;
        l)       LINK_ID=$OPTARG;;
        -)       break;;
    esac
done

######################
# Per link information
######################


if [ -f $X25CONFIGFILES/config/link_config_0*$LINK_ID.cfg ]
then

CFG_FILE=`ls $X25CONFIGFILES/config/link_config_0*$LINK_ID.cfg | head -1`

echo""
echo "##########################################"
echo Hardware Driver statistics
echo "##########################################"


# NPCTE fix for bug 4073671, take into account hihp (HSI/PCI), SD, 22 Aug 97
# NPCTE fix for bug 4337479, remove hard coded path to hsiX_stat utilities, <GS> 18/May/2000
CMD=`awk '{ if ($1 == "device") \
		 {if (substr($2, 6, 3) == "zsh") \
			 {print "/usr/sbin/syncstat " substr($2, 6, 50)} 
		  else if (substr($2, 6, 4) == "hihp") \
			 {print "hsip_stat " substr($2, 6, 50)} 
		  else if (substr($2, 6, 3) == "hih") \
			 {print "hsi_stat " substr($2, 6, 50)} ;
		 }}' $CFG_FILE`
# end NPCTE fix for bug 4073671, take into account hihp (HSI/PCI), SD, 22 Aug 97
$CMD

echo ""
echo "##########################################"
echo configuration file for link $LINK_ID  $CFG_FILE
echo "##########################################"
cat $CFG_FILE
echo ""
echo "##########################################"
echo X25 statistics for link $LINK_ID
echo "##########################################"
/opt/SUNWconn/bin/x25stat -l $LINK_ID -p all -g
/opt/SUNWconn/bin/x25stat -l $LINK_ID -V
echo ""
echo "##########################################"
echo ip configuration file is :
echo "##########################################"
cat $X25CONFIGFILES/ipconf
echo ""
echo "##########################################"
echo last generated netconf file is :
echo "##########################################"
cat $X25CONFIGFILES/netconf
echo ""
echo "##########################################"
echo netstat -r
echo "##########################################"
/usr/bin/netstat -r
echo ""
echo "##########################################"
echo netstat -i
echo "##########################################"
/usr/bin/netstat -i
echo ""
echo "##########################################"
echo netstat -m
echo "##########################################"
/usr/bin/netstat -m
echo ""
echo "##########################################"
echo swap space
echo "##########################################"
/usr/sbin/swap -l
else
echo Link $LINK_ID is not configured 
fi
fi




