Changeset 6645
- Timestamp:
- Jan 29, 2009, 7:34:45 PM (16 years ago)
- Location:
- trunk/exodus
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exodus/settings.py
r6517 r6645 21 21 # AP subnet size 22 22 AP_NETMASK = 26 23 24 23 # Graph for network 24 try: 25 import networkx as nx 26 G = nx.Graph() 27 except: 28 G = 'no_networkx' 25 29 # Master super path, set to current working path 26 30 EXODUS_ROOT = os.path.dirname(__file__) -
trunk/exodus/templates/nagios/object.nagios
r6618 r6645 12 12 icon_image_alt Node {{ node.name }} 13 13 statusmap_image nodes.gd2 14 } 14 {% ifnotequal viewpoint 'none' %} parents {{ node.name|getParents:viewpoint }}{% else %}}{% endifnotequal %} 15 {% ifnotequal viewpoint 'none' %}}{% endifnotequal %} -
trunk/exodus/templates/viewNagios.html
r6610 r6645 6 6 <table border="3" cellpadding="1"> 7 7 <tr> 8 <td colspan=2> 9 If you have installed <a href=http://networkx.lanl.gov/>networkx</a> the parent directive can be rendered<br/> 10 Currently no monitor is added to the exodus database so the monitor parameter is set<br/> 11 to a node viewpoint.<br/> 12 This is the last commit for nagios until the new build environment/addon structure for<br/> 13 exodus is defined...<br/><br/> 14 example usage: view/nagios/AZC/exodus.cfg<br/> 15 searches for parent dependencies between each node and AZC<br/> 16 </td> 17 </tr> 18 <tr> 8 19 <td class="list" >Full nagios config from exodus</td> 9 20 <td class="list" ><a class="list" href="{% url exodus.views.viewNagios %}">exodus.cfg</a></td> -
trunk/exodus/templatetags/location.py
r6618 r6645 1 1 from django import template 2 2 from django.template.defaultfilters import stringfilter 3 4 from exodus.settings import G 5 if G != 'no_networkx': 6 from networkx import shortest_path 3 7 4 8 register = template.Library() … … 10 14 11 15 register.filter('getLocationName', getLocationName) 16 17 def getParents(node,viewpoint): 18 if G != 'no_networkx': 19 route = shortest_path(G,viewpoint,node) 20 parents = [viewpoint] 21 if route and len(route) > 2: 22 for hop in route: 23 if hop != node and hop != viewpoint: 24 bakhop = G.neighbors(hop) 25 G.remove_node(hop) 26 if not shortest_path(G,viewpoint,node): 27 parents.append(hop) 28 for link in bakhop: 29 G.add_edge(hop,link) 30 return ' '.join(parents) 31 else: 32 return viewpoint 33 register.filter('getParents', getParents) -
trunk/exodus/urls.py
r6629 r6645 29 29 url(r'^view/nagios/$', 'exodus.urls.direct_to_template', {'template': 'viewNagios.html'}, "nagios"), 30 30 (r'^view/nagios/exodus.cfg$', 'exodus.views.viewNagios'), 31 (r'^view/nagios/(?P<monitor>.+)/exodus.cfg$', 'exodus.views.viewNagios'), 31 32 32 33 # 3th party/embedded database browser -
trunk/exodus/views.py
r6637 r6645 9 9 10 10 from exodus.models import Node, Network, Location 11 from exodus.settings import G 11 12 12 13 # Views … … 76 77 mimetype='text/plain') 77 78 78 def viewNagios(request ):79 def viewNagios(request, monitor='none'): 79 80 nodes = Node.objects.all() 80 81 networks = Network.objects.all() 81 82 locations = Location.objects.all() 82 return render_to_response('nagios/exodus.cfg', {'nodes' : nodes, 'networks' : networks, 'locations' : locations}, mimetype='text/plain') 83 #TODO monitors should be added to exodus (static hosts) 84 # to get the viewpoint of the monitor 85 #viewpoint = DhcpStatic.objects.filter(hostname=monitor).accespoint.node.name 86 # for demo purpose the viewpoint is set to the monitor 87 viewpoint=monitor 88 # check if networkx is available 89 if G == 'no_networkx': 90 monitor = 'none' 91 print 'Networkx is not available' 92 #only if monitor is set create a graph to work with 93 if monitor != 'none': 94 G.clear 95 for node in Node.objects.all(): 96 if node.status == 'up': 97 G.add_node(node.name) 98 for interface in node.interface_set.all(): 99 if interface.mode == 'mn' and interface.link.node.status == 'up': 100 G.add_edge(node.name,interface.link.node.name) 101 102 return render_to_response('nagios/exodus.cfg', {'nodes' : nodes, 'networks' : networks, 'locations' : locations, 'viewpoint' : viewpoint}, mimetype='text/plain') 83 103 84 104
Note:
See TracChangeset
for help on using the changeset viewer.