Contact Us

Question: (by Sandiyago)  Hi, I need to send SNMP get commands in one of our automated test scripts. Can anyone quickly tell me how can I do that?

We have been using Net-SNMP command line utilities but would like to use SilverCreek's Tcl command since our test scripts are all written in Tcl. It is ""painful"" to call SNMP shell commands in our Tcl scripts.

Thanks in advance!"

Answer One: (by PumpkinJason)  The following simple commands show you how this can be done:

set ctx [snmptcl::context::create -address \
-version SNMPv1 -rcomm public ]
snmptcl::snmpget sysDescr.0 value -context $ctx
puts $value

Hope this helps!

Answer Two:  (by Syed)

1)  Actually, what the below step will do?

set ctx [snmptcl::context::create -address \
-version SNMPv1 -rcomm public ]

2) My requirement is to get the below index value and need to save in the variable But when i did through SC GUI , it gave the below snippet.

snmptcl::snmpget -vbinds mplsTunnelIndexNextIndex.1 \
-rvbinds res -restatus estatus -expectstatus noError \
-expectvalue 2 -reindex eindex -octetstringformat 1 -comments comm\
-context $snmptcl(agent)

but when i try to edit the above script(shown below) and re-run it failed. Also help me to execute in CONSOLE too...

#get mplsTunnelIndexNextIndex.1
set mplsTunnelIndex [snmptcl::snmpget -vbinds mplsTunnelIndexNextIndex.1 \
-rvbinds res -restatus estatus -expectstatus noError \
-reindex eindex -octetstringformat 1 -comments comm\
-context $snmptcl(agent)]
puts $mplsTunnelIndex

if { $comm != """" } { 
append results "\nCOMMENTS: GET on mplsTunnelIndexNextIndex.1; 
Expected value: $mplsTunnelIndex \n$comm"
set type "failed"
} else { 
append results "\n \nGET on mplsTunnelIndexNextIndex.1; Expected value: 
$mplsTunnelIndex \n "
set type "passed"

::snmptools::scriptcmdtool::writeMessage $type $results
set results""

Answer Three:  (by Sandiyago)  

"set ctx [snmptcl::context::create -address \
-version SNMPv1 -rcomm public ]

This creates an agent context "handle". The context handle "encapsulate" agent IP address, community string etc.

Then later you can use the handle like

snmptcl::snmpget sysDescr.0 value -context $ctx

Answer Four:  (by Sandiyago)  When you generate a command using SC GUI, the generated command always uses the default agent context "handle", i.e., the currently connected agent: $snmptcl(agent)