[j-nsp] How to determine last ifindex used ?
Richard A Steenbergen
ras at e-gerbil.net
Sat Nov 1 22:35:07 EST 2003
On Sat, Nov 01, 2003 at 02:46:42PM -0800, joe mcguckin wrote:
>
> Since ifindexes are not allocated contiguously, what's the best way to
> determine the maximum valid ifindex?
Are you sure that the maximum ifindex is what you're looking for, rather
than the total count of ifindex's? You probably want the latter, since the
former is fairly useless (especially if you're polling one of those
not-a-juniper devices with weird fixed ifindex's of 50000 built in). The
answer to the question you probably meant to ask is, interfaces.ifNumber.0.
You getnext up through your ifindex's until you hit the max count,
skipping any unallocated ifindex's along the way.
A smart design will poll the ifNumber.0 to check for changes, then run
parallel get's of the ifName table. If any changes are detected, or if
this is your first run, do a sequential getnext loop to map out / update
the ifName's and ifIndex's, else do your normal speedy parallel polling.
This lets you auto-detect interface changes (people who write pollers
which need cfg updates or cfgmaker runs with every interface change need
to be shot), without being piss slow on devices that aren't nearby.
--
Richard A Steenbergen <ras at e-gerbil.net> http://www.e-gerbil.net/ras
GPG Key ID: 0xF8B12CBC (7535 7F59 8204 ED1F CC1C 53AF 4C41 5ECA F8B1 2CBC)
More information about the juniper-nsp
mailing list