From: Stephen Soltesz Date: Thu, 25 Jun 2009 23:01:59 +0000 (+0000) Subject: added references to google gadgets X-Git-Tag: Monitor-3.0-18~10 X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=commitdiff_plain;h=28e240eb7def09d695bff401226193faffbbd59a added references to google gadgets added sitesummary and summary controls for gadgets clarified sitehistory, and other history views simplified controllers.py in many places, trying to make node() faster. --- diff --git a/web/MonitorWeb/monitorweb/controllers.py b/web/MonitorWeb/monitorweb/controllers.py index a1746c8..60bdbcc 100644 --- a/web/MonitorWeb/monitorweb/controllers.py +++ b/web/MonitorWeb/monitorweb/controllers.py @@ -108,12 +108,16 @@ def prep_pcu_for_display(pcu): class NodeWidget(widgets.Widget): pass -def prep_node_for_display(node): +def prep_node_for_display(node, pcuhash=None): agg = aggregate() agg.node = node if node.plc_pcuid: - pcu = FindbadPCURecord.get_latest_by(plc_pcuid=node.plc_pcuid) + if pcuhash: + pcu = pcuhash[node.plc_pcuid] + else: + pcu = FindbadPCURecord.get_latest_by(plc_pcuid=node.plc_pcuid) + if pcu: agg.pcu_status = pcu.reboot_trial_status agg.pcu_short_status = format_pcu_shortstatus(pcu) @@ -167,6 +171,31 @@ class Root(controllers.RootController, MonitorXmlrpcServer): flash("Welcome To MyOps!") return dict(now=time.ctime()) + @expose(template="monitorweb.templates.nodelist") + def node2(self, filter='boot'): + + fbquery = FindbadNodeRecord.get_all_latest() + fbpcus = FindbadPCURecord.get_all_latest() + def fbtohash(fbpculist): + h = {} + for p in fbpculist: + h[p.plc_pcuid] = p + + pcuhash = fbtohash(fbpcus) + + query = [] + for node in fbquery: + # NOTE: reformat some fields. + agg = prep_node_for_display(node, pcuhash) + + if not agg.history: + continue + + query.append(agg) + + widget = NodeWidget(template='monitorweb.templates.node_template') + return dict(now=time.ctime(), query=query, nodewidget=widget) + @expose(template="monitorweb.templates.nodelist") def node(self, filter='boot'): print "NODE------------------" @@ -181,9 +210,6 @@ class Root(controllers.RootController, MonitorXmlrpcServer): # NOTE: reformat some fields. agg = prep_node_for_display(node) - #node.history.status - #print node.hostname - if not agg.history: continue @@ -197,9 +223,6 @@ class Root(controllers.RootController, MonitorXmlrpcServer): elif agg.history.status in ['debug', 'monitordebug']: filtercount['debug'] += 1 else: - # TODO: need a better fix. filtercount - # doesn't maps to GetBootStates() on - # 4.3 so this one fails quite often. if filtercount.has_key(agg.history.status): filtercount[agg.history.status] += 1 @@ -462,6 +485,41 @@ class Root(controllers.RootController, MonitorXmlrpcServer): query.append(site) return dict(query=query, fc=filtercount) + @expose(template="monitorweb.templates.sitesummary") + def sitesummary(self, loginbase="princeton"): + nodequery = [] + for node in FindbadNodeRecord.query.filter_by(loginbase=loginbase): + agg = prep_node_for_display(node) + nodequery += [agg] + + return dict(nodequery=nodequery, loginbase=loginbase) + + @expose(template="monitorweb.templates.summary") + def summary(self, since=7): + sumdata = {} + sumdata['nodes'] = {} + sumdata['sites'] = {} + sumdata['pcus'] = {} + + def summarize(query, type): + for o in query: + if o.status not in sumdata[type]: + sumdata[type][o.status] = 0 + sumdata[type][o.status] += 1 + + fbquery = HistorySiteRecord.query.all() + summarize(fbquery, 'sites') + fbquery = HistoryPCURecord.query.all() + summarize(fbquery, 'pcus') + fbquery = HistoryNodeRecord.query.all() + summarize(fbquery, 'nodes') + + if 'monitordebug' in sumdata['nodes']: + d = sumdata['nodes']['monitordebug'] + del sumdata['nodes']['monitordebug'] + sumdata['nodes']['failboot'] = d + + return dict(sumdata=sumdata, setorder=['good', 'offline', 'down', 'online']) @expose(template="monitorweb.templates.actionsummary") def actionsummary(self, since=7): diff --git a/web/MonitorWeb/monitorweb/static/css/style.css b/web/MonitorWeb/monitorweb/static/css/style.css index d3a365c..ac85b33 100644 --- a/web/MonitorWeb/monitorweb/static/css/style.css +++ b/web/MonitorWeb/monitorweb/static/css/style.css @@ -108,6 +108,9 @@ a.right { float: right; } #site-offline { background-color: red; } #site-down { background-color: indianred; } +#site-True { background-color : darkseagreen; } +#site-False { background-color: indianred; } + #node-online { background-color : lightgreen; } #node-good { background-color : darkseagreen; } #node-offline { background-color: red; } @@ -118,7 +121,7 @@ a.right { float: right; } #pcu-offline { background-color: red; } #pcu-down { background-color: indianred; } -/*#site-0 { background-color : white; }*/ +#site-0 { background-color : darkseagreen ; } #site-1 { background-color: gold; } #site-2 { background-color: indianred; } diff --git a/web/MonitorWeb/monitorweb/static/xml/gadget.xml b/web/MonitorWeb/monitorweb/static/xml/gadget.xml index 8a3c79a..bae4356 100644 --- a/web/MonitorWeb/monitorweb/static/xml/gadget.xml +++ b/web/MonitorWeb/monitorweb/static/xml/gadget.xml @@ -1,6 +1,6 @@ - + ]]> diff --git a/web/MonitorWeb/monitorweb/static/xml/sitemonitor.xml b/web/MonitorWeb/monitorweb/static/xml/sitemonitor.xml index 0bb0b02..2b2c4ad 100644 --- a/web/MonitorWeb/monitorweb/static/xml/sitemonitor.xml +++ b/web/MonitorWeb/monitorweb/static/xml/sitemonitor.xml @@ -1,6 +1,6 @@ - + ]]> diff --git a/web/MonitorWeb/monitorweb/templates/links.py b/web/MonitorWeb/monitorweb/templates/links.py index 95f192e..1a951bd 100644 --- a/web/MonitorWeb/monitorweb/templates/links.py +++ b/web/MonitorWeb/monitorweb/templates/links.py @@ -2,6 +2,8 @@ from monitor import config import turbogears as tg import urllib +def plc_myops_uri(): + return "http://" + config.MONITOR_HOSTNAME def plc_mail_uri(ticketid): return config.RT_WEB_SERVER + "/Ticket/Display.html?id=" + str(ticketid) def plc_node_uri(hostname): diff --git a/web/MonitorWeb/monitorweb/templates/nodehistory.kid b/web/MonitorWeb/monitorweb/templates/nodehistory.kid index de60dd9..e63d957 100644 --- a/web/MonitorWeb/monitorweb/templates/nodehistory.kid +++ b/web/MonitorWeb/monitorweb/templates/nodehistory.kid @@ -18,37 +18,16 @@ from links import * - - - + + - + - - - - - + diff --git a/web/MonitorWeb/monitorweb/templates/pcuhistory.kid b/web/MonitorWeb/monitorweb/templates/pcuhistory.kid index 79fd07b..d809609 100644 --- a/web/MonitorWeb/monitorweb/templates/pcuhistory.kid +++ b/web/MonitorWeb/monitorweb/templates/pcuhistory.kid @@ -10,7 +10,7 @@ from links import * xmlns:mochi="http://www.mochi.org">
-

Node History : ${pcu_id}

+

PCU History for pcu_id : ${pcu_id}

dateLast CheckLast Change hostnamelast_contactStatus
your.host.org
@@ -18,37 +18,16 @@ from links import *
- - - + + - + - - - - - + diff --git a/web/MonitorWeb/monitorweb/templates/sitehistory.kid b/web/MonitorWeb/monitorweb/templates/sitehistory.kid index 8dfb823..6040d83 100644 --- a/web/MonitorWeb/monitorweb/templates/sitehistory.kid +++ b/web/MonitorWeb/monitorweb/templates/sitehistory.kid @@ -20,9 +20,10 @@ from links import * + - + @@ -37,11 +38,11 @@ from links import * - - - + + + diff --git a/web/MonitorWeb/monitorweb/templates/sitesummary.kid b/web/MonitorWeb/monitorweb/templates/sitesummary.kid new file mode 100644 index 0000000..37e0541 --- /dev/null +++ b/web/MonitorWeb/monitorweb/templates/sitesummary.kid @@ -0,0 +1,41 @@ + + + + + + + +

Nodes for site ${loginbase}

+

Working on the color...

+

+ There are no registered nodes for this site. +

+
dateLast CheckLast Change pcu_idlast_contactStatus
your.host.org
Site nameSlices/Max Enabled PenaltySlices/MaxLast Change Nodes/Total Date Checked
${site.penalty_level} ${site.slices_used}/${site.slices_total}${site.nodes_up} / ${site.nodes_total}${site.penalty_level} ${site.nodes_up} / ${site.nodes_total}
+ + + + + + + + + + + + + + +
HistoryHostnameStatus
history + + ${agg.node.hostname} +
+ + diff --git a/web/MonitorWeb/monitorweb/templates/summary.kid b/web/MonitorWeb/monitorweb/templates/summary.kid new file mode 100644 index 0000000..27b888c --- /dev/null +++ b/web/MonitorWeb/monitorweb/templates/summary.kid @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
${primarykey.capitalize()}
+
+
+ + diff --git a/web/MonitorWeb/monitorweb/templates/welcome.kid b/web/MonitorWeb/monitorweb/templates/welcome.kid index 43fdc21..af7b007 100644 --- a/web/MonitorWeb/monitorweb/templates/welcome.kid +++ b/web/MonitorWeb/monitorweb/templates/welcome.kid @@ -1,4 +1,7 @@ + @@ -32,7 +35,13 @@

All nodes: Nodes

- +

If you'd like to track things a little more informally, you can install + these Google Gadgets for summaries of the entire system or a specific + site.

+