Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=6020471
By: lnxgnome
Script mod: add "community name" as 2nd (optional) parm. Default is "public".
Add a little error handling.
#!/bin/bash
# 20080107 v0.2 - LnxGnome
if [ "$1" == "" ]; then
echo "error: required parameter, internal IP or hostname of router, is missing!"
>&2
exit 99
else
GW=$1
CM=$2
[[ "$CM" == "" ]] && CM="public"
EXTIF=`snmpwalk -Ov -Oq -c $CM -v 1 $GW ipRouteIfIndex.0.0.0.0 2>/dev/null
|| if [[ $? -ne 0 ]]; then echo ERROR ; fi`
if [ "$EXTIF" == "ERROR" ]; then
echo "error: can not access router!" >&2
exit 1
elif [ "$EXTIF" == "End of MIB" ]; then
echo "warning: Default gateway not found. Check community name and routing
table in router!" >&2
exit 2
fi
ENTRY=`snmpwalk -Os -Oq -c $CM -v 1 $GW ipAdEntIfIndex | awk '$2=='$EXTIF'
{ print $1 }'`
IP=${ENTRY/ipAdEntIfIndex./}
echo $IP
fi
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=399427
|