|
ru.cisco- RU.CISCO --------------------------------------------------------------------- From : Auster 2:5020/400 05 Jul 2006 13:57:55 To : Konstantin Kubatkin Subject : Re: snmp ping -------------------------------------------------------------------------------- Konstantin Kubatkin <Konstantin.Kubatkin@f13.n468.z2.fidonet.org> wrote: > > Пытаюсь реализовать snmp ping на 2811, но выдает мне ошибку. Решения я не > нашел :( > ###### Create the instance ####### > SNMPv2-SMI::enterprises.9.9.16.1.1.1.16.333 = INTEGER: 6 > SNMPv2-SMI::enterprises.9.9.16.1.1.1.16.333 = INTEGER: 5 > ###### Now let's set the characteristics of the ping ####### > 1 > .1.3.6.1.4.1.9.9.16.1.1.1.15.333: Unknown Object Identifier (Sub-id not found: > (top) -> ishka) > 11 > 2 > SNMPv2-SMI::enterprises.9.9.16.1.1.1.2.333 = INTEGER: 1 > 22 > если кто делал ping через snmp - поделитесь знанием pls > -------- ~/snmp-ping.sh : # use: $0 [options] src:dst ... # example: $0 -c rw_community src:dst rnd="$$" opts="-Oq -v2c" oid=".1.3.6.1.4.1.9.9.16.1.1.1" ro_comm="public" rw_comm="private" count=5 size=100 tmout=2000 dly=0 src="" progname="$(basename $0)" usage() { echo "Use: $progname [options] src:dst ..." echo "options:" echo " -ro readonly_community" echo " -rw readwrite_community" echo " -c common_community" echo " -n count" echo " -s size" echo " -t timeout [msec]" echo " -d delay [msec]" exit 0 } sp() { echo "${1%%.*} ${1#*.}"; } snmps() { snmpset $opts -c$rw_comm "$src" "$oid.$1.$rnd" "$2" "$3" >/dev/null || return 1; } snmpg() { ready=$(snmpget $opts -c$ro_comm "$src" "$oid.$1.$rnd") test $? -ne 0 && { echo -1; return 1;} test "$ready" = "" && { echo -1; return 1;} echo ${ready#* } } get_sec() { test $# -ne 2 && return msec=$(snmpg "$1" || echo "$2") sec=$(($msec/1000)) test $(($msec%1000)) -gt 0 && sec=$(($sec+1)) echo $sec } get_results() { echo "Source: $src" echo "Target: $dst0" snmpwalk $opts -c$ro_comm "$src" "$oid" | while read a b; do c=${a%.$rnd} test "$a" = "$c" && continue a=${c##*.} case $a in 4) name="Count";; 5) name="Size";; 9) name="Sent";; 10) name="Recv";; 11) name="MinRTT"; units="msec";; 12) name="AvgRTT"; units="msec";; 13) name="MaxRTT"; units="msec";; *) continue;; esac echo "$name: $b $units" done } # main while [ $# -gt 0 ]; do case "$1" in -ro) ro_comm="$2"; shift;; -rw) rw_comm="$2"; shift;; -c) ro_comm="$2"; rw_comm="$2"; shift;; -n) count="$2"; shift;; -s) size="$2"; shift;; -t) tmout="$2"; shift;; -d) dly="$2"; shift;; -*) usage;; *) break;; esac shift done test $# -eq 0 && usage while [ $# -gt 0 ]; do arg="$1"; shift src="${arg%:*}"; dst0="${arg#*:}" test "$src" = "$arg" && { echo "$arg: unrecognized argument" continue } dst=$(host $dst0 2>/dev/null | grep 'has address' | tail -1 | cut -f4 -d' ') test "$dst" = "" && dst="$dst0" haddr=$(printf '%02x %02x %02x %02x' $(sp "$(sp "$(sp $dst)")") 2>/dev/null) test $? -ne 0 && { echo "$dst0: unrecognized target" continue } snmps 16 i 6 # destroy entry snmps 16 i 5 || continue # create entry snmps 2 i 1 || continue # use ip snmps 3 x "$haddr" || continue # set destination snmps 4 i "$count" || continue # set count snmps 5 i "$size" || continue # set size snmps 6 i "$tmout" || continue # set timeout snmps 7 i "$dly" || continue # set delay snmps 15 s any || continue # set owner test $(snmpg 16) -ne 2 && { # not ready echo "$src -> $dst0: not ready" continue } snmps 16 i 1 || continue # run r_count=$(snmpg 4 || echo 5) # count, default 5 r_tmout=$(get_sec 6 2000) # timeout, default 2000 msec r_dly=$(get_sec 7 0) # delay, default 0 msec max_wait=$(( $r_count*$r_tmout + ($r_count-1)*$r_dly )) i=0 while test $i -lt $max_wait; do test $(snmpg 14) -eq 1 && break sleep 1; i=$(($i+1)) done get_results snmps 16 i 6 # destroy entry test $# -gt 0 && echo "" done -------- -- Auster Vl. --- ifmail v.2.15dev5.3 * Origin: Demos online service (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.cisco/3293e9327111.html, оценка из 5, голосов 10
|