def update_traffic(client, lock, coll_config, community, ipTraffic, collectionsName, indexTraffic, config_name): lock.acquire() data = coll_config.find_one() indexTraffic = data["traffic_index"] print "sssssssssssssssssssssssssssssssssssssssssss", indexTraffic print "indexTraffic(update_traffic1) : " + str(indexTraffic) try: collectionsName_traffic_new = "test" indexTraffic, traffic_datetime = traffic.traffic( community, ipTraffic, collectionsName, indexTraffic ) # Wed17Feb2016_053526 print "indexTraffic(update_traffic2) : " + str(indexTraffic) collectionsNameTopo = collectionsName collectionsNameTraff = str(collectionsName) + "_traffic_" + str(indexTraffic - 1) aaa, collectionsName_traffic_new = an.anaysit(collectionsNameTopo, collectionsNameTraff, indexTraffic) ##topo_config_name coll_config = connectDatabase(config_name) coll_config.update({"index": "0"}, {"$set": {"traffic_index": str(indexTraffic)}}) ## ##traffic_config_name config_traffic_name = "timeline_" + collectionsName_traffic_new coll_config_traffic = connectDatabase(config_traffic_name) coll_config_traffic.insert_one({"index": "0"}) coll_config_traffic.update( {"index": "0"}, {"$set": {"name": collectionsName_traffic_new, "date_time": traffic_datetime}} ) ## except: print "Topology has been change" client.send("missing") lock.release() return indexTraffic, collectionsName_traffic_new
def update_traffic(client, lock, coll_config, community, ipTraffic, collectionsName, indexTraffic, config_name): lock.acquire() data = coll_config.find_one() indexTraffic = data['traffic_index'] print "sssssssssssssssssssssssssssssssssssssssssss", indexTraffic print "indexTraffic(update_traffic1) : " + str(indexTraffic) try: collectionsName_traffic_new = "test" indexTraffic, traffic_datetime = traffic.traffic( community, ipTraffic, collectionsName, indexTraffic) #Wed17Feb2016_053526 print "indexTraffic(update_traffic2) : " + str(indexTraffic) collectionsNameTopo = collectionsName collectionsNameTraff = str(collectionsName) + "_traffic_" + str( indexTraffic - 1) aaa, collectionsName_traffic_new = an.anaysit(collectionsNameTopo, collectionsNameTraff, indexTraffic) ##topo_config_name coll_config = connectDatabase(config_name) coll_config.update({"index": "0"}, {'$set': { "traffic_index": str(indexTraffic) }}) ## ##traffic_config_name config_traffic_name = "timeline_" + collectionsName_traffic_new coll_config_traffic = connectDatabase(config_traffic_name) coll_config_traffic.insert_one({"index": "0"}) coll_config_traffic.update({"index": "0"}, { '$set': { "name": collectionsName_traffic_new, "date_time": traffic_datetime } }) ## except: print "Topology has been change" client.send("missing") lock.release() return indexTraffic, collectionsName_traffic_new
CISCOSMI_ciscoMgmt = ".1.3.6.1.4.1.9.9.68.1.2.2.1.2" # vlan interface ########### forwarding blocking BRIDGEMIB_dot1dStpPort = "1.3.6.1.2.1.17.2.15.1.1" #stp port BRIDGEMIB_dot1dStpPortState = ".1.3.6.1.2.1.17.2.15.1.3" #stp port state #BRIDGEMIB_dot1dBasePort = ".1.3.6.1.2.1.17.1.4.1.1" # BRIDGEMIB_dot1dBasePortIfIndex = ".1.3.6.1.2.1.17.1.4.1.2" # port index #IFMIB_ifIndex #IFMIB_ifDescr indexTraffic = 0 community, ipTraffic, collectionsName, config_name = topo.topology( your_ip, ip, community, username, password) while (True): indexTraffic, traffic_datetime = traffic.traffic(community, ipTraffic, collectionsName, indexTraffic) #print "index traffic :" + str(indexTraffic) + "+++++++" collectionsNameTopo = collectionsName collectionsNameTraff = str(collectionsName) + "_traffic_" + str( indexTraffic - 1) #print collectionsNameTraff aaa, collectionsName_traffic_new = an.anaysit(collectionsNameTopo, collectionsNameTraff, indexTraffic) ##topo_config_name coll_config = router.connectDatabase(config_name) coll_config.update({"index": "0"}, {'$set': { "traffic_index": str(indexTraffic) }})
########### IFMIB_ifIndex = ".1.3.6.1.2.1.2.2.1.1" # index CISCOSMI_ciscoMgmt = ".1.3.6.1.4.1.9.9.68.1.2.2.1.2" # vlan interface ########### forwarding blocking BRIDGEMIB_dot1dStpPort = "1.3.6.1.2.1.17.2.15.1.1" #stp port BRIDGEMIB_dot1dStpPortState = ".1.3.6.1.2.1.17.2.15.1.3" #stp port state #BRIDGEMIB_dot1dBasePort = ".1.3.6.1.2.1.17.1.4.1.1" # BRIDGEMIB_dot1dBasePortIfIndex = ".1.3.6.1.2.1.17.1.4.1.2" # port index #IFMIB_ifIndex #IFMIB_ifDescr indexTraffic = 0 community,ipTraffic,collectionsName,config_name = topo.topology(your_ip,ip,community,username,password) while (True): indexTraffic,traffic_datetime = traffic.traffic(community,ipTraffic,collectionsName,indexTraffic) #print "index traffic :" + str(indexTraffic) + "+++++++" collectionsNameTopo = collectionsName collectionsNameTraff = str(collectionsName)+"_traffic_"+str(indexTraffic-1) #print collectionsNameTraff aaa,collectionsName_traffic_new = an.anaysit(collectionsNameTopo,collectionsNameTraff,indexTraffic) ##topo_config_name coll_config = router.connectDatabase(config_name) coll_config.update({"index":"0"},{'$set':{"traffic_index":str(indexTraffic)}}) ## ##traffic_config_name config_traffic_name = "timeline_"+collectionsName_traffic_new coll_config_traffic = router.connectDatabase(config_traffic_name) coll_config_traffic.insert_one({"index":"0"}) coll_config_traffic.update({"index":"0"},{'$set':{"name":collectionsName_traffic_new,"date_time":traffic_datetime}}) ##