示例#1
0
                        snmpget.send(m, ('localhost', 161), snmpget.WALK)
            else:
                output.dbg("SNMP Error : "+event.response.recv_error.prettyPrint(),
                           self.__class__.__name__)
        else:
            output.dbg("Error", self.__class__.__name__)

        if(self.count == self.expectedCount):
            self.server.cleanup()
            
        return True

server = core.core()
output.set_mode("DBG")
snmpget = snmp.reliable_snmp(server)
snmps = snmpcomm.snmp_udp_server(server, 5000)
ps = print_snmp(server)
server.run(runbg=True)

m1 = snmpcomm.xet_message(
    {(1,3,6,1,2,1,1,1,0): None,
     (1,3,6,1,2,1,1,2,0): None})

snmpget.send(m1, ('openflow2.stanford.edu', 161), snmpget.GET)
output.dbg("Sent message 1")
snmpget.send(m1, ('localhost', 161), snmpget.GET)
output.dbg("Sent message 2")

while (ps.count < 2):
    time.sleep(0.1)
print
示例#2
0
            output.dbg("", self.__class__.__name__)

            output.dbg(str(event.community), self.__class__.__name__)
            output.dbg(str(event.uptime), self.__class__.__name__)
            output.dbg(str(event.agent_addr), self.__class__.__name__)
            output.dbg(str(event.enterprise), self.__class__.__name__)
            output.dbg(str(event.generic_trap), self.__class__.__name__)
            output.dbg(str(event.specific_trap), self.__class__.__name__)
            output.dbg(str(event.oid), self.__class__.__name__)

        return True


output.set_mode("DBG")
server = core.core()
snmpcomm = snmp.snmp_udp_server(server, 9000)
client = snmp.snmp_udp_client(server)
ps = print_snmp(server)

server.run(runbg=True)
time.sleep(1)

# Send using netsnmp
commands.getoutput("snmptrap -v 1 -c public 127.0.0.1:9000 1.3.6.1.2.1.2.2.1.1 192.168.5.2 6 666 1233433")

# Send my own trap
tmsg = snmp.trap_message()
tmsg.enterprise = (1, 3, 6, 1, 2, 1, 2, 2, 1, 1)
tmsg.set_agent_ip_addr("192.168.5.2")
tmsg.generic_trap = 6
tmsg.specific_trap = 666