0

I am able to run snmpwalk from my machine

snmpwalk -c public -v 2c junipertestrtr 1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1 from the same computer's command line I get the right output

iso.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.172.28.254.83.1.172.16.25.82 = Gauge32: 64902 iso.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.172.28.254.135.1.172.17.25.134 = Gauge32: 64902 iso.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.172.28.255.135.1.172.29.255.136 = Gauge32: 64861 iso.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.172.28.255.135.1.172.28.255.137 = Gauge32: 64861 iso.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.172.28.255.135.1.172.28.255.138 = Gauge32: 64861 iso.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.10.1.1.1.1.10.1.1.2 = Gauge32: 64810

However when I try to run the same from pysnmp, I get a failure

from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.smi import *


cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, varBind = cmdGen.nextCmd(
    cmdgen.CommunityData('public', 1),
    cmdgen.UdpTransportTarget(('junipertestrtr', 161)),
    (1,3,6,1,4,1,2636,5,1,1,2,1,1,1,13,0,1),

)

print errorIndication, errorStatus

for varBindTableRow in varBind:
    for name, val in varBindTableRow:
        print name, val

I get the below error message "requestTimedOut 0"

1 Answers1

0

You should be using just:

cmdgen.CommunityData('public')

or:

cmdgen.CommunityData('public', mpModel=1)  # mpModel specifies SNMP protocol version

or:

cmdgen.CommunityData('my-snmp-agent', 'public', 1)

You could also enable pysnmp debugging at the beginning of your script to see what's going on under the hood:

debug.setLogger(debug.Debug('msgproc', 'secmod'))

A bunch of examples are available at pysnmp site

Pooh
  • 244
  • 1
  • 2