|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/var/arpwatch/ |
Upload File : |
#!/bin/sh
# @(#) $Id: arpfetch,v 1.4 2000/03/21 02:27:45 leres Exp $ (LBL)
#
# arpfetch - collect arp data from a cisco using snmpwalk
#
if test $# -ne 2; then
echo "usage: $0 host cname"
exit 1
fi
#
host=$1
cname=$2
temp=/tmp/arpfetch.temp.$$
errs=/tmp/arpfetch.errs.$$
what="ip.ipnettomediatable.ipnettomediaentry.ipnettomediaphysaddress"
#
# Get the data
#
snmpwalk -v 1 $host $cname $what | 2>&1 tr A-Z a-z > $temp
#
# Try to make up for the fact that snmpwalk doesn't write errors to stderr
#
grep -v $what $temp > $errs
if test -s $errs; then
cat $errs 1>&2
rm -f $temp $errs
exit 1
fi
#
# Convert the results
#
sed -e 's/[ ][ ]*/ /g' \
-e 's/ = hex: /=/' \
-e 's/ $//' \
-e 's/ /:/g' \
-e 's/^.*\.\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)=\(.*\)/\2 \1/' \
-e 's/:0/:/g' \
-e 's/^0//' $temp
#
rm -f $temp $errs