Author: justi9
Date: 2007-10-22 20:56:26 -0400 (Mon, 22 Oct 2007)
New Revision: 1140
Added:
mgmt/cumin/python/cumin/client.strings
Modified:
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/demo.py
mgmt/cumin/python/cumin/model.py
Log:
Adds client stats.
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2007-10-22 21:03:02 UTC (rev 1139)
+++ mgmt/cumin/python/cumin/client.py 2007-10-23 00:56:26 UTC (rev 1140)
@@ -5,7 +5,7 @@
from parameters import *
from util import *
-#strings = StringCatalog(__file__)
+strings = StringCatalog(__file__)
class ClientSet(ItemSet):
def render_title(self, session, vhost):
@@ -14,6 +14,19 @@
def get_items(self, session, vhost):
return sorted_by(vhost.client_items(), "address")
- def render_item_link(self, session, client):
- branch = session.branch()
- return mlink(branch.marshal(), "Client", client.address)
+ def render_item_address(self, session, client):
+ #branch = session.branch()
+ #return mlink(branch.marshal(), "Client", client.address)
+ return client.address
+
+ def render_item_messages_produced(self, session, client):
+ return client.get_measurement("msgsProduced").get_value()
+
+ def render_item_bytes_produced(self, session, client):
+ return client.get_measurement("bytesProduced").get_value()
+
+ def render_item_messages_consumed(self, session, client):
+ return client.get_measurement("msgsConsumed").get_value()
+
+ def render_item_bytes_consumed(self, session, client):
+ return client.get_measurement("bytesConsumed").get_value()
Added: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings (rev 0)
+++ mgmt/cumin/python/cumin/client.strings 2007-10-23 00:56:26 UTC (rev 1140)
@@ -0,0 +1,35 @@
+[ClientSet.html]
+<form>
+ <select>
+ <option>Act on Selection...</option>
+ <option>Close Client</option>
+ <option>Detach Client</option>
+ </select>
+
+ <input type="Submit" value="Submit">
+
+ <br/><br/>
+
+ <table class="mobjects">
+ <tr>
+ <th><input type="checkbox"/></th>
+ <th>Client</th>
+ <th>Messages Produced</th>
+ <th>Bytes Produced</th>
+ <th>Messages Consumed</th>
+ <th>Bytes Consumed</th>
+ </tr>
+
+ {items}
+ </table>
+</form>
+
+[ClientSet.item_html]
+<tr>
+ <td><input type="checkbox"/></td>
+ <td>{item_address}</td>
+ <td>{item_messages_produced}</td>
+ <td>{item_messages_consumed}</td>
+ <td>{item_bytes_produced}</td>
+ <td>{item_bytes_consumed}</td>
+</tr>
Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py 2007-10-22 21:03:02 UTC (rev 1139)
+++ mgmt/cumin/python/cumin/demo.py 2007-10-23 00:56:26 UTC (rev 1140)
@@ -207,6 +207,14 @@
finally:
queue.unlock()
+ for client in vhost.client_items():
+ client.lock()
+ try:
+ for measure in client.measurements:
+ self.frob_measure(measure)
+ finally:
+ client.unlock()
+
if __name__ == "__main__":
import sys
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-10-22 21:03:02 UTC (rev 1139)
+++ mgmt/cumin/python/cumin/model.py 2007-10-23 00:56:26 UTC (rev 1140)
@@ -619,3 +619,31 @@
super(Client, self).__init__(model, model.client)
self.address = None
+
+ self.measurements = list()
+
+ measure = Measurement("msgsProduced", "int")
+ measure.title = "Messages produced"
+ measure.categories = ("message", "general")
+ self.measurements.append(measure)
+
+ measure = Measurement("msgsConsumed", "int")
+ measure.title = "Messages consumed"
+ measure.categories = ("message", "general")
+ self.measurements.append(measure)
+
+ measure = Measurement("bytesProduced", "int")
+ measure.title = "Bytes produced"
+ measure.categories = ("byte", "general")
+ self.measurements.append(measure)
+
+ measure = Measurement("bytesConsumed", "int")
+ measure.title = "Bytes consumed"
+ measure.categories = ("message", "general")
+ self.measurements.append(measure)
+
+ def get_measurement(self, name):
+ for measure in self.measurements:
+ if measure.name == name:
+ return measure
+