[Checkins] SVN: five.z2monitor/ initial import

Jean-François Roche cvs-admin at zope.org
Mon Nov 5 16:02:10 UTC 2012


Log message for revision 128174:
  initial import

Changed:
  A   five.z2monitor/
  A   five.z2monitor/branches/
  A   five.z2monitor/tags/
  A   five.z2monitor/trunk/
  A   five.z2monitor/trunk/CHANGES.txt
  A   five.z2monitor/trunk/README.txt
  A   five.z2monitor/trunk/bootstrap.py
  A   five.z2monitor/trunk/buildout.cfg
  A   five.z2monitor/trunk/docs/
  A   five.z2monitor/trunk/docs/LICENSE.ZPL
  A   five.z2monitor/trunk/setup.py
  A   five.z2monitor/trunk/sources.cfg
  A   five.z2monitor/trunk/src/
  A   five.z2monitor/trunk/src/five/
  A   five.z2monitor/trunk/src/five/__init__.py
  A   five.z2monitor/trunk/src/five/z2monitor/
  A   five.z2monitor/trunk/src/five/z2monitor/__init__.py
  A   five.z2monitor/trunk/src/five/z2monitor/configure.zcml
  A   five.z2monitor/trunk/versions.cfg

-=-
Added: five.z2monitor/trunk/CHANGES.txt
===================================================================
--- five.z2monitor/trunk/CHANGES.txt	                        (rev 0)
+++ five.z2monitor/trunk/CHANGES.txt	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,7 @@
+Changelog
+=========
+
+0.1-dev (unreleased)
+--------------------
+
+- Initial implementation

Added: five.z2monitor/trunk/README.txt
===================================================================
--- five.z2monitor/trunk/README.txt	                        (rev 0)
+++ five.z2monitor/trunk/README.txt	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,45 @@
+.. contents::
+
+Introduction
+============
+
+This package enable to monitoring of Zope 2 instance from the command line. It plugs zc.monitor (http://pypi.python.org/pypi/zc.monitor) and zc.z3monitor (http://pypi.python.org/pypi/zc.z3monitor) in Zope 2.
+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.
+
+Probes
+======
+
+This package has been tested with probes coming from different packages:
+
+  - zc.z3monitor
+  - Products.ZNagios
+  - zc.monitorcache
+  - zc.monitorlogstats
+  - ztfy.monitor
+
+To register your own probe, just define a new utility providing the ``zc.z3monitor.interfaces.IZ3MonitorPlugin`` interface. Like this::
+
+  <utility
+     component=".zc_uptime"
+     provides="zc.z3monitor.interfaces.IZ3MonitorPlugin"
+     name="uptime" />
+
+and the component should look like this::
+
+  def zc_uptime(connection, database='main'):
+      """uptime of the zope instance in seconds"""
+      app = App()
+      elapsed = time.time() - app.Control_Panel.process_start
+      print >> connection, elapsed
+      app._p_jar.close()
+
+ZODB connection is always the first parameter. You can add your own parameters after.
+
+Once you start your instance you should see something like::
+
+  INFO zc.ngi.async.server listening on ('127.0.0.1', 8888)
+
+The ngi server is started and you can look up values with netcat for example::
+
+  echo 'uptime' | nc -i 1 localhost 8888

Added: five.z2monitor/trunk/bootstrap.py
===================================================================
--- five.z2monitor/trunk/bootstrap.py	                        (rev 0)
+++ five.z2monitor/trunk/bootstrap.py	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,106 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 102545 2009-08-06 14:49:47Z chrisw $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+from optparse import OptionParser
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+# parsing arguments
+parser = OptionParser()
+parser.add_option("-v", "--version", dest="version",
+                          help="use a specific zc.buildout version")
+parser.add_option("-d", "--distribute",
+                   action="store_true", dest="distribute", default=False,
+                   help="Use Disribute rather than Setuptools.")
+
+options, args = parser.parse_args()
+
+if options.version is not None:
+    VERSION = '==%s' % options.version
+else:
+    VERSION = ''
+
+USE_DISTRIBUTE = True
+args = args + ['bootstrap']
+
+to_reload = False
+try:
+    import pkg_resources
+    if not hasattr(pkg_resources, '_distribute'):
+        to_reload = True
+        raise ImportError
+except ImportError:
+    ez = {}
+    if USE_DISTRIBUTE:
+        exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
+                         ).read() in ez
+        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
+    else:
+        exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                             ).read() in ez
+        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    if to_reload:
+        reload(pkg_resources)
+    else:
+        import pkg_resources
+
+def quote (c):
+    return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+
+if USE_DISTRIBUTE:
+    requirement = 'distribute'
+else:
+    requirement = 'setuptools'
+
+if is_jython:
+    import subprocess
+
+    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+           quote(tmpeggs), 'zc.buildout' + VERSION],
+           env=dict(os.environ,
+               PYTHONPATH=
+               ws.find(pkg_resources.Requirement.parse(requirement)).location
+               ),
+           ).wait() == 0
+
+else:
+    assert os.spawnle(
+        os.P_WAIT, sys.executable, quote (sys.executable),
+        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
+        dict(os.environ,
+            PYTHONPATH=
+            ws.find(pkg_resources.Requirement.parse(requirement)).location
+            ),
+        ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout' + VERSION)
+import zc.buildout.buildout
+zc.buildout.buildout.main(args)
+shutil.rmtree(tmpeggs)

Added: five.z2monitor/trunk/buildout.cfg
===================================================================
--- five.z2monitor/trunk/buildout.cfg	                        (rev 0)
+++ five.z2monitor/trunk/buildout.cfg	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,32 @@
+[buildout]
+extensions = buildout.dumppickedversions
+             mr.developer
+extends = http://download.zope.org/Zope2/index/2.13.6/versions.cfg
+          sources.cfg
+	  versions.cfg
+#auto-checkout = Products.ZNagios
+sources-dir = devel
+dump-picked-versions-file = versions-picked.cfg
+develop = .
+eggs = five.z2monitor
+zcml = five.z2monitor
+parts =
+    client1
+    omelette
+
+[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>
+
+[omelette]
+recipe = collective.recipe.omelette
+eggs = ${client1:eggs}

Added: five.z2monitor/trunk/docs/LICENSE.ZPL
===================================================================
--- five.z2monitor/trunk/docs/LICENSE.ZPL	                        (rev 0)
+++ five.z2monitor/trunk/docs/LICENSE.ZPL	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,20 @@
+Some code carries the Zope Public License (as indicated in the comments):
+
+Zope Public License (ZPL) Version 2.1
+
+A copyright notice accompanies this license document that identifies the copyright holders.
+
+This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+  1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer.
+  2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
+  3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders.
+  4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders.
+  5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+Disclaimer
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+	       

Added: five.z2monitor/trunk/setup.py
===================================================================
--- five.z2monitor/trunk/setup.py	                        (rev 0)
+++ five.z2monitor/trunk/setup.py	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,38 @@
+from setuptools import setup, find_packages
+
+version = '0.1'
+
+long_description = (
+    open('README.txt').read()
+    + '\n' +
+    open('CHANGES.txt').read()
+    + '\n')
+
+setup(name='five.z2monitor',
+      version=version,
+      description="Enable zc.monitor with Zope 2",
+      long_description=long_description,
+      classifiers=[
+        "Programming Language :: Python",
+        "License :: OSI Approved :: Zope Public License",
+        "Programming Language :: Python",
+        "Topic :: System :: Monitoring",
+        ],
+      keywords='Zope zc.monitor monitoring',
+      author='Zope Corporation and contributors',
+      author_email='zope-dev at zope.org',
+      url='http://pypi.python.org/pypi/five.monitor',
+      license='ZPL',
+      packages=find_packages('src'),
+      package_dir = {'': 'src'},
+      namespace_packages=['five'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+          'zc.monitor',
+          'zc.z3monitor',
+          'ZODB3',
+          'zope.component',
+          'zope.processlifetime'
+      ])

Added: five.z2monitor/trunk/sources.cfg
===================================================================
--- five.z2monitor/trunk/sources.cfg	                        (rev 0)
+++ five.z2monitor/trunk/sources.cfg	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,5 @@
+[remotes]
+zope = svn+ssh
+#zope = svn
+[sources]
+Products.ZNagios = svn ${remotes:zope}://svn.zope.org/repos/main/Products.ZNagios/trunk

Added: five.z2monitor/trunk/src/five/__init__.py
===================================================================
--- five.z2monitor/trunk/src/five/__init__.py	                        (rev 0)
+++ five.z2monitor/trunk/src/five/__init__.py	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)

Added: five.z2monitor/trunk/src/five/z2monitor/__init__.py
===================================================================
--- five.z2monitor/trunk/src/five/z2monitor/__init__.py	                        (rev 0)
+++ five.z2monitor/trunk/src/five/z2monitor/__init__.py	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,73 @@
+##############################################################################
+#
+# Copyright (c) 2005-2012 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import re
+
+import ZODB.ActivityMonitor
+import ZODB.interfaces
+import zope.component
+import zc.monitor
+
+from App.config import getConfiguration
+
+
+def getZCMonitorConfiguration():
+    config = getConfiguration()
+    if not hasattr(config, 'product_config'):
+        return
+    product_config = config.product_config
+    if config is None:
+        return
+    return product_config.get('five.z2monitor', None)
+
+
+def registerDB(db):
+    dbname = db.database_name
+    zope.component.provideUtility(db, ZODB.interfaces.IDatabase, name=dbname)
+
+
+def initialize(opened_event):
+    config = getZCMonitorConfiguration()
+    if config is None:
+        return
+    registerDB(opened_event.database)
+    for name, db in zope.component.getUtilitiesFor(ZODB.interfaces.IDatabase):
+        if db.getActivityMonitor() is None:
+            db.setActivityMonitor(ZODB.ActivityMonitor.ActivityMonitor())
+
+    try:
+        #being backwards compatible here and not passing address if not given
+        port = int(config['port'])
+        zc.monitor.start(port)
+    except KeyError:
+        #new style bind
+        try:
+            bind = config['bind']
+            bind = bind.strip()
+            m = re.match(r'^(?P<addr>\S+):(?P<port>\d+)$', bind)
+            if m:
+                #we have an address:port
+                zc.monitor.start((m.group('addr'), int(m.group('port'))))
+                return
+
+            m = re.match(r'^(?P<port>\d+)$', bind)
+            if m:
+                #we have a port
+                zc.monitor.start(int(m.group('port')))
+                return
+
+            #we'll consider everything else as a domain socket
+            zc.monitor.start(bind)
+        except KeyError:
+            #no bind config no server
+            pass

Added: five.z2monitor/trunk/src/five/z2monitor/configure.zcml
===================================================================
--- five.z2monitor/trunk/src/five/z2monitor/configure.zcml	                        (rev 0)
+++ five.z2monitor/trunk/src/five/z2monitor/configure.zcml	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,10 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+  i18n_domain="monitoring">
+
+    <include package="zc.z3monitor"/>
+
+    <subscriber
+      for="zope.processlifetime.IDatabaseOpenedWithRoot"
+      handler=".initialize"/>
+
+</configure>

Added: five.z2monitor/trunk/versions.cfg
===================================================================
--- five.z2monitor/trunk/versions.cfg	                        (rev 0)
+++ five.z2monitor/trunk/versions.cfg	2012-11-05 16:02:09 UTC (rev 128174)
@@ -0,0 +1,16 @@
+[versions]
+Products.ZNagios = 0.5
+collective.recipe.omelette = 0.15
+gocept.munin = 0.1
+mailinglogger = 3.7.0
+mock = 0.8.0
+plone.recipe.zope2instance = 4.2.3
+threadframe = 0.2
+zc.monitor = 0.3.1
+zc.monitorcache = 0.1.0
+zc.monitorlogstats = 0.1.0
+zc.ngi = 2.0.1
+zc.z3monitor = 0.8.0
+zope.app.appsetup = 3.14.0
+zope.app.publication = 3.12.0
+ztfy.monitor = 0.1



More information about the checkins mailing list