コード例 #1
0
ファイル: snmp2gml.py プロジェクト: Hadhat/flow-inspector
                for ip in interface.ip:
                    if node.ip == ip.split("/")[0]:
                        print str(node.ip) + "/" + str(
                            node.netmask
                        ) + " is not(!) unknown, belongs to " + str(
                            interface) + node.reason_creation

    print "Checking for self-loop-nodes"
    for node in graph.db["Node"].itervalues():
        if node in node.successors:
            print "Self-loop-node " + str(node)


## create graph structure containing router and interfaces ##

graph = Graph()
print "Creating router and interfaces"

# add interfaces and routers to graph
for entry in collections['interface_log'].find({"timestamp": timestamp}):

    # convert from int to ip representation
    entry["ipAdEntAddr"] = int2ip(entry["ipAdEntAddr"])

    if_info = collections['interface_perf'].find({
        "router":
        entry["router"],
        "ifIndex":
        entry["ipAdEntIfIndex"],
        "timestamp":
        timestamp
コード例 #2
0
ファイル: snmp2gml.py プロジェクト: Hadhat/flow-inspector
		if node.__class__ == Node:
			for interface in graph.db["Interface"].itervalues():
				for ip in interface.ip:
					if node.ip == ip.split("/")[0]:
						print str(node.ip) + "/" + str(node.netmask) + " is not(!) unknown, belongs to " + str(interface) + node.reason_creation
	
	print "Checking for self-loop-nodes"
	for node in graph.db["Node"].itervalues():
		if node in node.successors:
			print "Self-loop-node " + str(node)



## create graph structure containing router and interfaces ##

graph = Graph()
print "Creating router and interfaces"

# add interfaces and routers to graph
for entry in collections['interface_log'].find({"timestamp": timestamp}):
	
	# convert from int to ip representation
	entry["ipAdEntAddr"] = int2ip(entry["ipAdEntAddr"])
	
	if_info = collections['interface_perf'].find({ 
		"router": entry["router"], "ifIndex": entry["ipAdEntIfIndex"], "timestamp": timestamp
	})[0]
	
	# add operational interface to graph
	if if_info["ifOperStatus"] == 1:
		graph.addInterface(