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
pgpfsJNUJXjPl.pgp
Description: PGP signature
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor