Author: justi9
Date: 2007-11-08 16:46:00 -0500 (Thu, 08 Nov 2007)
New Revision: 1276
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/widgets.py
mgmt/notes/justin-todo.txt
Log:
Ajaxifies client status.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-08 21:46:00 UTC (rev 1276)
@@ -12,7 +12,7 @@
from page import CuminPage
from queue import QueueXmlPage, QueueChartPage
from exchange import ExchangeXmlPage, ExchangeChartPage
-from client import ClientChartPage
+from client import ClientXmlPage, ClientChartPage
class Cumin(Application):
def __init__(self, model):
@@ -38,6 +38,7 @@
self.add_page(QueueChartPage(self, "queue.png"))
self.add_page(ExchangeXmlPage(self, "exchange.xml"))
self.add_page(ExchangeChartPage(self, "exchange.png"))
+ self.add_page(ClientXmlPage(self, "client.xml"))
self.add_page(ClientChartPage(self, "client.png"))
class CuminServer(WebServer):
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/client.py 2007-11-08 21:46:00 UTC (rev 1276)
@@ -67,6 +67,9 @@
return "Client %s" % client.address
class ClientStatus(CuminStatus):
+ def render_data_url(self, session, client):
+ return "client.xml?id=%i" % client.id
+
def render_messages_produced(self, session, client):
value = client.get_measurement("msgsProduced").get_rate()
return fmt_rate(value, "msg", "sec")
@@ -171,6 +174,14 @@
def render_item_status(self, session, session_):
return fmt_status(len(session_.errors), len(session_.warnings))
+class ClientXmlPage(CuminXmlPage):
+ def __init__(self, app, name):
+ super(ClientXmlPage, self).__init__(app, name)
+
+ self.client = ClientParameter(app, "id")
+ self.add_parameter(self.client)
+ self.set_object_parameter(self.client)
+
class ClientChartPage(CuminChartPage):
def __init__(self, app, name):
super(ClientChartPage, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/client.strings 2007-11-08 21:46:00 UTC (rev 1276)
@@ -32,6 +32,30 @@
<td>{item_status}</td>
</tr>
+[ClientStatus.javascript]
+function updateClientStatus(id, data) {
+ updateStatus(id, data);
+
+ var ms = data.root().elem("measurements");
+
+ var mprod = ms.elem("msgsproduced").elem("r").text().get();
+ var bprod = ms.elem("bytesproduced").elem("r").text().get();
+ var mcons = ms.elem("msgsconsumed").elem("r").text().get();
+ var bcons = ms.elem("bytesconsumed").elem("r").text().get();
+
+ var status = wooly.doc().elembyid(id);
+ var trs =
status.elem("table").elem("tbody").elems("tr", 1);
+ var tds = null;
+
+ tds = trs.next().elems("td");
+ tds.next().text().set(mprod);
+ tds.next().text().set(bprod);
+
+ tds = trs.next().elems("td");
+ tds.next().text().set(mcons);
+ tds.next().text().set(bcons);
+}
+
[ClientStatus.html]
<div id="{id}" class="{class}">
<h2>Client Status</h2>
@@ -56,6 +80,9 @@
</tr>
</table>
</div>
+<script>
+ wooly.setIntervalUpdate("{id}", "{data_url}", updateClientStatus,
3000);
+</script>
[ClientView.html]
{status}
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/exchange.py 2007-11-08 21:46:00 UTC (rev 1276)
@@ -386,24 +386,14 @@
value = producer.get_measurement("bytesProduced").get_rate()
return fmt_rate(value, "byte", "sec")
-class ExchangeXmlPage(Page):
+class ExchangeXmlPage(CuminXmlPage):
def __init__(self, app, name):
super(ExchangeXmlPage, self).__init__(app, name)
self.exchange = ExchangeParameter(app, "id")
self.add_parameter(self.exchange)
+ self.set_object_parameter(self.exchange)
- def get_content_type(self, session):
- return Page.xml_content_type
-
- def do_render(self, session, object):
- writer = Writer()
-
- writer.write(Page.xml_1_0_declaration)
- self.exchange.get(session).write_xml(writer)
-
- return writer.to_string()
-
class ExchangeChartPage(CuminChartPage):
def __init__(self, app, name):
super(ExchangeChartPage, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/model.py 2007-11-08 21:46:00 UTC (rev 1276)
@@ -780,6 +780,15 @@
measure.categories = ("byte", "general")
self.measurements.append(measure)
+ def write_xml(self, writer):
+ writer.write("<client id=\"client-%i\">" % self.id)
+ writer.write("<address>%s</address>" % self.address)
+
+ self.write_error_xml(writer)
+ self.write_measurement_xml(writer)
+
+ writer.write("</client>")
+
class Session(CuminModelObject):
def __init__(self, model):
super(Session, self).__init__(model, model.session)
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-08 21:46:00 UTC (rev 1276)
@@ -471,24 +471,14 @@
def render_item_unacked_messages(self, session, consumer):
return consumer.get_measurement("unackedMessages").get_value()
-class QueueXmlPage(Page):
+class QueueXmlPage(CuminXmlPage):
def __init__(self, app, name):
super(QueueXmlPage, self).__init__(app, name)
self.queue = QueueParameter(app, "id")
self.add_parameter(self.queue)
-
- def get_content_type(self, session):
- return Page.xml_content_type
+ self.set_object_parameter(self.queue)
- def do_render(self, session, object):
- writer = Writer()
-
- writer.write(Page.xml_1_0_declaration)
- self.queue.get(session).write_xml(writer)
-
- return writer.to_string()
-
class QueueChartPage(CuminChartPage):
def __init__(self, app, name):
super(QueueChartPage, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-08 21:46:00 UTC (rev 1276)
@@ -172,6 +172,30 @@
chart.write(writer)
return writer.to_string()
+class CuminXmlPage(Page):
+ def __init__(self, app, name):
+ super(CuminXmlPage, self).__init__(app, name)
+
+ self.__param = None
+
+ def set_object_parameter(self, param):
+ self.__param = param
+
+ def get_object(self, session, object):
+ return self.__param.get(session)
+
+ def get_content_type(self, session):
+ return Page.xml_content_type
+
+ def do_render(self, session, object):
+ writer = Writer()
+
+ writer.write(Page.xml_1_0_declaration)
+
+ object.write_xml(writer)
+
+ return writer.to_string()
+
class UnitSwitch(Widget):
def __init__(self, app, name):
super(UnitSwitch, self).__init__(app, name)
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-11-08 21:25:40 UTC (rev 1275)
+++ mgmt/notes/justin-todo.txt 2007-11-08 21:46:00 UTC (rev 1276)
@@ -8,8 +8,6 @@
* Exchange: ajaxify charts
- * Client: ajaxify status
-
* Client: ajaxify charts
* Queue: ajaxify charts