[Checkins] SVN: Products.ZNagios/trunk/ make it possible to specify which database to fetch metrics for
David Glick
davidglick at onenw.org
Mon Mar 14 15:37:30 EDT 2011
Log message for revision 120919:
make it possible to specify which database to fetch metrics for
Changed:
U Products.ZNagios/trunk/CHANGES.txt
U Products.ZNagios/trunk/Products/ZNagios/__init__.py
U Products.ZNagios/trunk/Products/ZNagios/munin_client.py
U Products.ZNagios/trunk/README.txt
-=-
Modified: Products.ZNagios/trunk/CHANGES.txt
===================================================================
--- Products.ZNagios/trunk/CHANGES.txt 2011-03-14 19:19:22 UTC (rev 120918)
+++ Products.ZNagios/trunk/CHANGES.txt 2011-03-14 19:37:29 UTC (rev 120919)
@@ -1,6 +1,12 @@
Changelog
=========
+0.5 - unreleased
+----------------
+
+- `munin_client.py` can handle multiple databases now.
+ [davisagli]
+
0.4.2 - 2010-10-21
------------------
Modified: Products.ZNagios/trunk/Products/ZNagios/__init__.py
===================================================================
--- Products.ZNagios/trunk/Products/ZNagios/__init__.py 2011-03-14 19:19:22 UTC (rev 120918)
+++ Products.ZNagios/trunk/Products/ZNagios/__init__.py 2011-03-14 19:37:29 UTC (rev 120919)
@@ -86,7 +86,7 @@
return result
-def munin(self):
+def munin(self, db='main'):
"""Return munin-compatible statistic data."""
data = {}
@@ -98,21 +98,21 @@
# ... total number of objects referenced
data['refcount-total'] = get_refcount(self)
- main_db = self.Control_Panel.Database['main']
+ db = self.Control_Panel.Database[db]
# Database size
# ... in bytes
- data['db-bytes'] = main_db._getDB()._storage.getSize()
+ data['db-bytes'] = db._getDB()._storage.getSize()
# ... in number of objects
- data['db-objects'] = main_db.database_size()
+ data['db-objects'] = db.database_size()
# Cache information (whole process)
# ... total number of objects in all caches
- data['db-cache-total-size'] = main_db.cache_length()
+ data['db-cache-total-size'] = db.cache_length()
# Cache information (per connection/thread)
# ... target size
- data['db-cache-target-size'] = main_db.cache_size()
- for i, connection in enumerate(main_db.cache_detail_length()):
+ data['db-cache-target-size'] = db.cache_size()
+ for i, connection in enumerate(db.cache_detail_length()):
# ... active objects for the connect
data['db-cache-conn%s-active-objects' % i] = connection['ngsize']
# ... total objects (active and inactive) for the connection
@@ -120,7 +120,7 @@
# Activity information
# measured for the last 5 minutes, normalized per second
- activity = get_activity(main_db)
+ activity = get_activity(db)
# ... loads per second in the last 5 minutes
data['db-loads'] = activity['total_load_count'] / MUNIN_TIME_DELTA
# ... stores per second in the last 5 minutes
Modified: Products.ZNagios/trunk/Products/ZNagios/munin_client.py
===================================================================
--- Products.ZNagios/trunk/Products/ZNagios/munin_client.py 2011-03-14 19:19:22 UTC (rev 120918)
+++ Products.ZNagios/trunk/Products/ZNagios/munin_client.py 2011-03-14 19:37:29 UTC (rev 120919)
@@ -24,7 +24,11 @@
cmd = 'fetch'
script_name = os.path.basename(sys.argv[0])
-_, graph, server_index = script_name.split('_')
+try:
+ _, graph, server_index, dbname = script_name.split('_')
+except ValueError:
+ _, graph, server_index = script_name.split('_')
+ dbname = 'main'
URL = os.environ['MUNIN_ZOPE_HOST_%s' % server_index]
AUTHORIZATION = os.environ.get('MUNIN_ZOPE_AUTHENTICATE_%s' % server_index)
@@ -33,6 +37,7 @@
def _prepare_fetch(self):
+ URL = URL + '?db=%s' % dbname
request = urllib2.Request(URL)
if AUTHORIZATION:
request.add_header('Authorization', 'Basic %s' %
Modified: Products.ZNagios/trunk/README.txt
===================================================================
--- Products.ZNagios/trunk/README.txt 2011-03-14 19:19:22 UTC (rev 120918)
+++ Products.ZNagios/trunk/README.txt 2011-03-14 19:37:29 UTC (rev 120919)
@@ -93,11 +93,12 @@
plugins using munin_client.py are named like::
- /etc/munin/plugins/zope_<graph>_<server-index>
+ /etc/munin/plugins/zope_<graph>_<server-index>[_<dbname>]
eg:
/etc/munin/plugins/zope_uptime_instance1
/etc/munin/plugins/zope_uptime_instance2
+ /etc/munin/plugins/zope_activity_instance1_db2
plugins using zeo_munin.py are named like::
@@ -141,8 +142,6 @@
env.MUNIN_ZEO_PORT_ZEO1 8502
-
-
Credits
-------
@@ -155,3 +154,4 @@
- Florian Schulze (independent)
- Hanno Schlichting (Jarn)
- Harald Friessnegger (Webmeisterei)
+- David Glick (Groundwire)
More information about the checkins
mailing list