[Checkins] SVN: zc.z3monitor/trunk/src/zc/z3monitor/ Separated zeo status into a different command.

Jim Fulton jim at zope.com
Thu Nov 29 15:57:41 EST 2007


Log message for revision 82034:
  Separated zeo status into a different command.
  

Changed:
  U   zc.z3monitor/trunk/src/zc/z3monitor/README.txt
  U   zc.z3monitor/trunk/src/zc/z3monitor/__init__.py

-=-
Modified: zc.z3monitor/trunk/src/zc/z3monitor/README.txt
===================================================================
--- zc.z3monitor/trunk/src/zc/z3monitor/README.txt	2007-11-29 20:48:09 UTC (rev 82033)
+++ zc.z3monitor/trunk/src/zc/z3monitor/README.txt	2007-11-29 20:57:41 UTC (rev 82034)
@@ -53,6 +53,8 @@
     ...     zc.z3monitor.interfaces.IZ3MonitorPlugin, 'dbinfo')
     >>> zope.component.provideUtility(zc.z3monitor.zeocache,
     ...     zc.z3monitor.interfaces.IZ3MonitorPlugin, 'zeocache')
+    >>> zope.component.provideUtility(zc.z3monitor.zeostatus,
+    ...     zc.z3monitor.interfaces.IZ3MonitorPlugin, 'zeostatus')
 
 The first is the help command.  Giving help without input, gives a
 list of available commands:
@@ -63,7 +65,8 @@
       hello -- Say hello
       help -- Get help about server commands
       monitor -- Get general process info
-      zeocache -- Get ZEO client cache and status information
+      zeocache -- Get ZEO client cache statistics
+      zeostatus -- Get ZEO client status information
     -> CLOSE
 
 We can get detailed help by specifying a command name:
@@ -251,9 +254,9 @@
     >>> connection.test_input('help zeocache\n')
     Help for zeocache:
     <BLANKLINE>
-    Get ZEO client cache and status information
+    Get ZEO client cache statistics
     <BLANKLINE>
-        The commands returns data in a single line:
+        The command returns data in a single line:
     <BLANKLINE>
         - the number of records added to the cache,
     <BLANKLINE>
@@ -265,29 +268,52 @@
     <BLANKLINE>
         - the number of cache accesses.
     <BLANKLINE>
-        - a flag indicating whether the ZEO storage is connected
-    <BLANKLINE>
         By default, data for the main database are returned.  To return
         information for another database, pass the database name.
     <BLANKLINE>
     -> CLOSE
 
     >>> connection.test_input('zeocache\n')
-    42 4200 23 2300 1000 1 
+    42 4200 23 2300 1000 
     -> CLOSE
 
 You can specify a database name:
 
     >>> connection.test_input('zeocache other\n')
-    42 4200 23 2300 1000 1 
+    42 4200 23 2300 1000 
     -> CLOSE
 
+ZEO Cache status
+----------------
+
+The zeostatus command lets you get information about ZEO connection status:
+
+    >>> connection.test_input('help zeostatus\n')
+    Help for zeostatus:
+    <BLANKLINE>
+    Get ZEO client status information
+    <BLANKLINE>
+        The command returns True if the client is connected and False otherwise.
+    <BLANKLINE>
+        By default, data for the main database are returned.  To return
+        information for another database, pass the database name.
+    <BLANKLINE>
+    -> CLOSE
+
+    >>> connection.test_input('zeostatus\n')
+    True 
+    -> CLOSE
+
+    >>> connection.test_input('zeostatus other\n')
+    True 
+    -> CLOSE
+
 In this example, we're using a faux ZEO connection.  It has an
 attribute that determines whether it is connected or not.  Id we
 change it, then the zeocache output will change:
 
     >>> main._storage._is_connected = False
-    >>> connection.test_input('zeocache\n')
-    42 4200 23 2300 1000 0 
+    >>> connection.test_input('zeostatus\n')
+    False 
     -> CLOSE
 

Modified: zc.z3monitor/trunk/src/zc/z3monitor/__init__.py
===================================================================
--- zc.z3monitor/trunk/src/zc/z3monitor/__init__.py	2007-11-29 20:48:09 UTC (rev 82033)
+++ zc.z3monitor/trunk/src/zc/z3monitor/__init__.py	2007-11-29 20:57:41 UTC (rev 82034)
@@ -176,9 +176,9 @@
     print >> connection, data[0], data[1], data[2], s, ng
 
 def zeocache(connection, database=''):
-    """Get ZEO client cache and status information
+    """Get ZEO client cache statistics
 
-    The commands returns data in a single line:
+    The command returns data in a single line:
 
     - the number of records added to the cache,
 
@@ -190,17 +190,24 @@
 
     - the number of cache accesses.
 
-    - a flag indicating whether the ZEO storage is connected
+    By default, data for the main database are returned.  To return
+    information for another database, pass the database name.
+    """
+    
+    db = zope.component.getUtility(ZODB.interfaces.IDatabase, database)
+    print >> connection, ' '.join(map(str, db._storage._cache.fc.getStats()))
 
+def zeostatus(connection, database=''):
+    """Get ZEO client status information
+
+    The command returns True if the client is connected and False otherwise.
+
     By default, data for the main database are returned.  To return
     information for another database, pass the database name.
     """
     
     db = zope.component.getUtility(ZODB.interfaces.IDatabase, database)
-    storage = db._storage
-    stats = list(storage._cache.fc.getStats())
-    stats.append(int(storage.is_connected()))
-    print >> connection, ' '.join(map(str, stats))
+    print >> connection, db._storage.is_connected()
 
 @zope.component.adapter(zope.app.appsetup.interfaces.IDatabaseOpenedEvent)
 def initialize(opened_event):



More information about the Checkins mailing list