def GenerateReportebyIP(IP_addres): #try: #information device print "Information Device:" print "Serial Device: ", GetInformationDevice.GetSerialNumeberBySNMP(IP_addres, list_OID) print "IP Device: ", IP_addres print "Name Device: ", GetInformationDevice.GetNameDeviceBySNMP(IP_addres, list_OID) print "Model Device: ", GetInformationDevice.GetModelDeviceBySNMP(IP_addres, list_OID) #traffic result = GetInformationDevice.getListOfNeighbours(IP_addres) List_count = GetInformationDevice.GetTrafficDevice(IP_addres, result["dict"]) print "Teleco Conectados: ", List_count['enlaces'] print "Irregular traffic:" for element in List_count['MAC']: print element #statistics neighbour print "Statistics Neighbour:" statistics = GetStatisticsDevice(GetInformationDevice.GetNeighbour(IP_addres)) print "Total AP:\t", statistics['APS'] print "Total TIP:\t", statistics['TIP'] print "Total RSW:\t", statistics['RSW'] print "Total SW:\t", statistics['SW']
def GenerateReporteFullbyIP(IP_addres): try: #information device print "Information Device:" print "Serial Device: ", GetInformationDevice.GetSerialNumeberBySNMP(IP_addres, list_OID) print "IP Device: ", IP_addres print "Name Device: ", GetInformationDevice.GetNameDeviceBySNMP(IP_addres, list_OID) print "Model Device: ", GetInformationDevice.GetModelDeviceBySNMP(IP_addres, list_OID) #statistics neighbour print "Statistics Neighbour:" List_response = GetInformationDevice.GetNeighbour(IP_addres) statistics = GetStatisticsDevice(List_response) print "Total AP: \t", statistics['APS'], PrintNameDevice(List_response, "ap",1) print "Total TIP:\t", statistics['TIP'], PrintNameDevice(List_response, "SEP",0) print "Total RSW:\t", statistics['RSW'], PrintNameDevice(List_response, "rs",1) print "Total SW:\t", statistics['SW'], PrintNameDevice(List_response, "sw",1) #traffic #result = GetInformationDevice.getListOfNeighbours(IP_addres) #List_count = GetInformationDevice.GetTrafficDevice(IP_addres, result["dict"]) #print "Teleco Conectados: ", #print "Irregular traffic:" #for element in List_count['MAC']: # print element except: # print "IP %s not response SNMP " %IP_addres pass
def GenerateReporteErrMac(IP_addres): print "Information Device:" print "Serial Device: ", GetInformationDevice.GetSerialNumeberBySNMP(IP_addres, list_OID) print "IP Device: ", IP_addres print "Name Device: ", GetInformationDevice.GetNameDeviceBySNMP(IP_addres, list_OID) print "Model Device: ", GetInformationDevice.GetModelDeviceBySNMP(IP_addres, list_OID) try: #traffic result = GetInformationDevice.getListOfNeighbours(IP_addres) List_count = GetInformationDevice.GetTrafficDevice(IP_addres, result["dict"]) print "Teleco Conectados: ", len(result["dict"]) print "Irregular traffic:" for element in List_count['MAC']: print element if len(List_count['MAC']) >0: print "For check the information do:" print "telnet "+IP_addres print "show mac address interface "+ List_count['MAC'][0] except: pass
def CreateTree(IP_addres): List_IP_already = [] #list with ip List_IP_already.append(IP_addres) try: #information device serial = GetInformationDevice.GetSerialNumeberBySNMP( IP_addres, list_OID) name_device = GetInformationDevice.GetNameDeviceBySNMP( IP_addres, list_OID) model_device = GetInformationDevice.GetModelDeviceBySNMP( IP_addres, list_OID) print "├─ (%s, %s, %s, %s)" % (serial, IP_addres, model_device, name_device) #traffic try: result = GetInformationDevice.getListOfNeighbours(IP_addres) #remove elements of list where not are sw or rsw for elements in result["dict"]: if "sw-" in result["dict"][elements][ "name"] or "rsw-" in result["dict"][elements]["name"]: if result["dict"][elements][ "address"] not in List_IP_already: print "│ ├─ (%s, %s, %s)" % ( result["dict"][elements]["address"], result["dict"][elements]["model"], result["dict"][elements]["name"]) List_IP_already.append(result["dict"][elements]["address"]) try: #get son of ip addres device... result2 = GetInformationDevice.getListOfNeighbours( result["dict"][elements]["address"]) for elements_son in result2["dict"]: if "sw-" in result2["dict"][elements_son][ "name"] or "rsw-" in result2["dict"][ elements_son]["name"]: if result2["dict"][elements_son][ "address"] not in List_IP_already: print "│ │ ├─ (%s, %s, %s)" % ( result2["dict"][elements_son] ["address"], result2["dict"][elements_son]["model"], result2["dict"][elements_son]["name"]) List_IP_already.append( result2["dict"][elements_son]["address"]) try: result3 = GetInformationDevice.getListOfNeighbours( result2["dict"][elements_son] ["address"]) #get son of ip address device... for elements_son2 in result3["dict"]: if "sw-" in result3["dict"][ elements_son2][ "name"] or "rsw-" in result3[ "dict"][elements_son2][ "name"]: if result3["dict"][elements_son2][ "address"] not in List_IP_already: print "│ │ │ ├─ (%s, %s, %s)" % ( result3["dict"] [elements_son2]["address"], result3["dict"] [elements_son2]["model"], result3["dict"] [elements_son2]["name"]) List_IP_already.append( result3["dict"][elements_son2] ["address"]) try: result4 = GetInformationDevice.getListOfNeighbours( result3["dict"] [elements_son2]["address"]) #get son of ip address device... for elements_son3 in result4[ "dict"]: if "sw-" in result4["dict"][ elements_son3][ "name"] or "rsw-" in result4[ "dict"][elements_son3][ "name"]: if result4["dict"][ elements_son3][ "address"] not in List_IP_already: print "│ │ │ │ ├─ (%s, %s, %s)" % ( result4["dict"] [elements_son3] ["address"], result4["dict"] [elements_son3] ["model"], result4["dict"] [elements_son3] ["name"]) List_IP_already.append( result4["dict"] [elements_son3] ["address"]) try: result5 = GetInformationDevice.getListOfNeighbours( result4["dict"] [elements_son3] ["address"]) #get son of ip address device... for elements_son4 in result5[ "dict"]: if "sw-" in result5[ "dict"][elements_son4][ "name"] or "rsw-" in result5[ "dict"][elements_son4][ "name"]: if result5["dict"][ elements_son4][ "address"] not in List_IP_already: print "│ │ │ │ │ ├─ (%s, %s, %s)" % ( result5[ "dict"] [elements_son4] ["address"], result5[ "dict"] [elements_son4] ["model"], result5[ "dict"] [elements_son4] ["name"] ) List_IP_already.append( result5[ "dict"] [elements_son4] ["address"] ) try: result6 = GetInformationDevice.getListOfNeighbours( result5[ "dict"] [elements_son4] ["address"] ) #get son of ip address device... for elements_son5 in result6[ "dict"]: if "sw-" in result6[ "dict"][elements_son5][ "name"] or "rsw-" in result6[ "dict"][elements_son5][ "name"]: if result6["dict"][ elements_son5][ "address"] not in List_IP_already: print "│ │ │ │ │ │ ├─ (%s, %s, %s)" % ( result6[ "dict"] [elements_son5] ["address"], result6[ "dict"] [elements_son5] ["model"], result6[ "dict"] [elements_son5] ["name"] ) List_IP_already.append( result6[ "dict"] [elements_son5] ["address"] ) except: pass except: pass except: pass except: pass except: pass except: pass except: print "IP %s not response SNMP " % IP_addres sys.exit(0)