One of the things I forgot to mention is that my host is using Python 2.4 and net-snmp 5.3; both packaged by a major North American Linux vendor. :)
So there doesn't seem to be a native net-snmp tool set for these versions. I'll poke around and see what else can be done. Thanks! On Fri, Aug 16, 2013 at 12:06 AM, Chris Down <ch...@chrisdown.name> wrote: > Hi Leam, > > On 2013-08-14 15:21, leam hall wrote: > > Is there a way to do a simple check in Python to see if a remote host is > > listening on SNMP port 161/UDP? > > "Simple" in this case could either mean technically simple (in which case, > use > a socket with SOCK_DGRAM and wait for data) or implementationally simple > (in > which case, use an SNMP library). I'd only recommend doing the latter. > > Since UDP is stateless, you'll need to make sure that your destination > replies > with something, which means you probably need to send a real SNMP request. > Since that's the case, you should really just use a real SNMP library > (although > I fear that your meaning of "simple" was "not using an SNMP library", > which is > really not simple at all. > > net-snmp[0] can do this fairly trivially, anyway. The following works for > me: > > >>> import netsnmp > >>> var = netsnmp.Varbind('sysDescr.0') > >>> netsnmp.snmpget( > ... var, > ... Version=2, > ... DestHost="localhost", > ... Community="pub", > ... ) > ('OpenBSD',) > > Best, > > Chris > > 0: http://www.net-snmp.org/wiki/index.php/Python_Bindings > -- Mind on a Mission <http://leamhall.blogspot.com/>
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor