On Thu, 05 Jan 1995 11:19:39 -0500,
"John P. Rouillard" <rouilj@dstar.iddis.com> said:
John> At the end of the script the variable interval is improperly specified
John> as intervall. Needless to say this stops it from running.
John> Also an additional command line argument to specify the number of
John> iterations of rstat (sort of like vmstat) would be helpful. The
John> following patch adds this option and fixes the intervall bug.
Thanks for the patch. I added it to my sources so it will be in the
1.2.2 patch.
John> Also does anybody have a simple snmp script along the lines of the
John> rstat script that will grab an oid or name from a remote host?
Something simple is simple :-) Below is a snmpwalk script I just wrote
down, but it is a bit slow if you have lots of MIBs because of the
startup time.
Juergen
#!/bin/sh
# Tcl sees the next lines as an assignment to variable `kludge'.
# For sh, the two shifts cancel the effect of the set, and then we
# run scotty on this script.
set kludge { $*
shift
shift
if test -x ../scotty ; then
exec ../scotty -nf $0 $*
else
exec scotty -nf $0 $*
fi
}
##
## Walk a MIB subtree starting by label. This is currently only a
## SNMPv1 version as I have no time to implement all the arguments
## needed for SNMPv2 sessions...
##
proc walk { host label community } {
if {[catch {snmp session -address $host -community $community} s]} {
puts stderr $s
exit
}
if {[catch {
$s walk x $label {
set x [lindex $x 0]
set oid [lindex $x 0]
set type [lindex $x 1]
set value [lindex $x 2]
puts [format "%-16s : %s" [mib name $oid] $value]
}
} err]} {
puts stderr $err
exit
}
$s destroy
}
##
## Check the command line and start the MIB walk.
##
proc usage {} {
puts stderr "usage: snmpwalk hostname subtree \[community\]"
exit
}
if { !([llength $argv] == 2 || [llength $argv] == 3)} { usage } else {
set ip [lindex $argv 0]
set label [lindex $argv 1]
if {[llength $argv] == 3} {
set community [lindex $argv 2]
} else {
set community public
}
walk $ip $label $community
}
exit