[Checkins] SVN: five.z2monitor/trunk/ Add entry point for plone.recipe.zope2instance & More documentation

Jean-François Roche cvs-admin at zope.org
Mon Nov 5 17:09:33 UTC 2012


Log message for revision 128178:
  Add entry point for plone.recipe.zope2instance & More documentation

Changed:
  _U  five.z2monitor/trunk/
  U   five.z2monitor/trunk/CHANGES.txt
  A   five.z2monitor/trunk/MANIFEST.in
  U   five.z2monitor/trunk/README.txt
  U   five.z2monitor/trunk/setup.py
  A   five.z2monitor/trunk/src/five/z2monitor/zope2instance.py

-=-

Property changes on: five.z2monitor/trunk
___________________________________________________________________
Added: svn:ignore
   + src/*.egg-info
var
parts
local
.installed.cfg
dist
versions-picked.cfg
lib
bin
.mr.developer.cfg
develop-eggs
include


Modified: five.z2monitor/trunk/CHANGES.txt
===================================================================
--- five.z2monitor/trunk/CHANGES.txt	2012-11-05 16:10:47 UTC (rev 128177)
+++ five.z2monitor/trunk/CHANGES.txt	2012-11-05 17:09:32 UTC (rev 128178)
@@ -4,9 +4,11 @@
 0.2 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Add entry point for plone.recipe.zope2instance
 
+- More documentation
 
+
 0.1 (2012-11-05)
 ----------------
 

Added: five.z2monitor/trunk/MANIFEST.in
===================================================================
--- five.z2monitor/trunk/MANIFEST.in	                        (rev 0)
+++ five.z2monitor/trunk/MANIFEST.in	2012-11-05 17:09:32 UTC (rev 128178)
@@ -0,0 +1,2 @@
+recursive-include docs *
+recursive-include src *

Modified: five.z2monitor/trunk/README.txt
===================================================================
--- five.z2monitor/trunk/README.txt	2012-11-05 16:10:47 UTC (rev 128177)
+++ five.z2monitor/trunk/README.txt	2012-11-05 17:09:32 UTC (rev 128178)
@@ -7,6 +7,16 @@
 zc.monitor use zc.ngi server and define another thread to handle monitoring. This way you should still be able to monitor your application even if the
 HTTPServer is hanging.
 
+Zope config
+===========
+
+Add this to your ``zope.conf`` to enable the zc.ngi server on the loopback interface on port 8888::
+
+    <product-config five.z2monitor>
+        bind 127.0.0.1:8888
+    </product-config>
+
+
 Probes
 ======
 
@@ -43,3 +53,36 @@
 The ngi server is started and you can look up values with netcat for example::
 
   echo 'uptime' | nc -i 1 localhost 8888
+
+plone.recipe.zope2instance
+==========================
+
+If you configure your zope instance using buildout and the plone.recipe.zope2instance recipe (http://pypi.python.org/pypi/plone.recipe.zope2instance).
+To define the zc.z2monitor host and port use the ``zope-conf-additional`` option like this::
+
+  [client1]
+  recipe = plone.recipe.zope2instance
+  http-address = 8080
+  user = admin:admin
+  eggs =
+    ${buildout:eggs}
+  zcml =
+    ${buildout:zcml}
+  zope-conf-additional =
+    <product-config five.z2monitor>
+      bind 127.0.0.1:8888
+    </product-config>
+
+
+Once the instance is running, you will be able to ask the available probes from the
+command line using::
+
+  bin/instance monitor dbinfo main
+
+which is the equivalent to::
+
+  echo 'dbinfo main' | nc -i 1 <zc.monitor host> <zc.monitor port>
+
+To know the registered probes, Use this command::
+
+  bin/instance monitor help

Modified: five.z2monitor/trunk/setup.py
===================================================================
--- five.z2monitor/trunk/setup.py	2012-11-05 16:10:47 UTC (rev 128177)
+++ five.z2monitor/trunk/setup.py	2012-11-05 17:09:32 UTC (rev 128178)
@@ -35,4 +35,9 @@
           'ZODB3',
           'zope.component',
           'zope.processlifetime'
-      ])
+      ],
+      entry_points="""
+[plone.recipe.zope2instance.ctl]
+monitor = five.z2monitor.zope2instance:monitor
+"""
+      )

Added: five.z2monitor/trunk/src/five/z2monitor/zope2instance.py
===================================================================
--- five.z2monitor/trunk/src/five/z2monitor/zope2instance.py	                        (rev 0)
+++ five.z2monitor/trunk/src/five/z2monitor/zope2instance.py	2012-11-05 17:09:32 UTC (rev 128178)
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+
+import socket
+
+
+def netcat(hostname, port, content):
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    s.connect((hostname, port))
+    s.sendall(content)
+    while 1:
+        data = s.recv(1024)
+        if data == "":
+            break
+        print data.strip()
+    s.close()
+
+
+def monitor(zope2Cmd, *args):
+    """
+    Ask for monitoring probe to five.z2monitor using tcp
+    """
+    productConfig = zope2Cmd.options.configroot.product_config
+    z2monitorConfig = productConfig.get('five.z2monitor')
+    if z2monitorConfig is None:
+        raise KeyError('Cannot find five.z2monitor section in Zope instance configuration')
+    hostname, port = z2monitorConfig.get('bind').split(':')
+    if args == ('',):
+        content = 'help'
+    else:
+        content = ' '.join(args)
+    netcat(hostname, int(port), '%s\n' % content)



More information about the checkins mailing list