#!/bin/bash -i ##################################################################### # project for: Advanced Computer Network Technologies 2004/2005 # # authors: Nour Oweis, Milan Egydy # # description: script for print etherStatsTable using snmpwalk # ##################################################################### tmp1=/tmp/tmp1$$ tmp2=/tmp/tmp2$$ tmp3=/tmp/tmp3$$ snmpwalk -c $1 -v 1 $2 1.3.6.1.2.1.16.1.1.1 > $tmp3 #cat $tmp3 #na labu cat $tmp3|cut -d: -f4,5,6,7,8,9 > $tmp1 #na ntb #cat |cut -d: -f4,5,6,7,8,9 > $tmp1 nlines=`wc -l $tmp1 | cut -d" " -f1` nrows=`expr $nlines / 21`; for((i=0;$i<$nlines ;$((i++)))); do read tmpline < $tmp1 #echo $tmpline pole[$i]=$tmpline sed '1 d' $tmp1 > $tmp2 tmp=$tmp1 tmp1=$tmp2 tmp2=$tmp done echo Stats Table echo "==========================================================================================================" echo "Idx Interface Drop nBytes nPckts Broad Multi CRC UndrSz OvrSz Frgmt Jabb" echo " Cllsm 64Pkts 64to127 128to255 256to511 512to1023 1024to1518" echo "==========================================================================================================" for((i=0;$i<$nrows ;$((i++)))); do echo -n ${pole[$((0*nrows+i))]} " " #$'\t' OID=`echo .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.${pole[$((i))]}` interface=`snmpget -c $1 -v1 $2 $OID | cut -d: -f4` echo -n $interface $'\t' echo -n ${pole[$((2*nrows+i))]} $'\t' echo -n ${pole[$((3*nrows+i))]} $'\t' echo -n ${pole[$((4*nrows+i))]} $'\t' echo -n ${pole[$((5*nrows+i))]} $'\t' echo -n ${pole[$((6*nrows+i))]} $'\t' echo -n ${pole[$((7*nrows+i))]} $'\t' echo -n ${pole[$((8*nrows+i))]} $'\t' echo -n ${pole[$((9*nrows+i))]} $'\t' echo -n ${pole[$((10*nrows+i))]} $'\t' echo ${pole[$((11*nrows+i))]} $'\t' echo -n $'\t' $'\t'$'\t' $'\t'$'\t' $'\t' ${pole[$((12*nrows+i))]} $'\t' echo -n ${pole[$((13*nrows+i))]} $'\t' echo -n ${pole[$((14*nrows+i))]} $'\t' echo -n ${pole[$((15*nrows+i))]} $'\t' echo -n ${pole[$((16*nrows+i))]} $'\t' echo -n ${pole[$((17*nrows+i))]} $'\t' echo -n ${pole[$((18*nrows+i))]} $'\t' #echo -n ${pole[$((19*nrows+i))]} " " #$'\t' #echo -n ${pole[$((20*nrows+i))]} " " #$'\t' #echo -n ${pole[$((21*nrows+i))]} " " #$'\t' echo " " echo ".........................................................................................................." done rm -f $tmp1 rm -f $tmp2 rm -f $tmp3