#!/bin/sh
#############################################################################
#
#       GetNextHopTable() - issue the SNMP queries to fetch NextHop table
#                       store the result in /tmp/NextHops$UniqueID
#
GetNextHopTable()
{
        echo `date` 'GetNextHopTable('$UniqueID')' - this may take a while
        snmptable2 -r $RETRIES -t $TIMEOUT -c $community -h $UniqueID ipRouteNextHop | \
                grep -v '0.0.0.0' >/tmp/neighbors$$
}

UniqueID=$1
community=$2
RETRIES=20
TIMEOUT=20

GetNextHopTable
cat /tmp/neighbors$$ | awk '{ print $3 }' | grep -v $UniqueID | sort | uniq  >/tmp/nexthops$$
vi /tmp/nexthops$$ /tmp/neighbors$$
rm /tmp/neighbors$$ /tmp/nexthops$$
