mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Extract tarballs committed to git as plugins.
This commit is contained in:
parent
2dad4c6f70
commit
038c3ce96b
15 changed files with 352 additions and 0 deletions
36
plugins/zope/zodb/README
Normal file
36
plugins/zope/zodb/README
Normal file
|
@ -0,0 +1,36 @@
|
|||
These are 2 rather crude munin plugins to get at data about zopes ZODB.
|
||||
They have proved very usefull, together with the process_memory
|
||||
plugin, in tweaking the zodb cache-size for performance.
|
||||
|
||||
There is no config, auto or otherwise, you have to edit the scripts to change anything.
|
||||
Should not be to hard however :)
|
||||
|
||||
|
||||
To install you have to copy the two scripts in the "scripts_python"
|
||||
folder into zope. Probably easiest just to paste them into an
|
||||
appropriately named new script in the ZMI.
|
||||
|
||||
Click on the proxy tab, and give them the "Manager" role.
|
||||
|
||||
You can test them like this:
|
||||
wget --delete-after -q -O - localhost:8080/<your path>/munin_db_activity.py
|
||||
wget --delete-after -q -O - localhost:8080/<your path>/munin_cache_parameters.py
|
||||
|
||||
Edit zope_db_activity and zope_cache_parameters scripts to reflect
|
||||
<your path> and your instance(s) ports.
|
||||
|
||||
Then move them into your munin plugins lib, and create a symlink under etc according to the
|
||||
usual munin custom:
|
||||
|
||||
mv zope_* /opt/munin/lib/plugins/
|
||||
|
||||
ln -s /opt/munin/lib/plugins/zope_* /etc/opt/munin/plugins/
|
||||
|
||||
Test them with:
|
||||
/opt/munin/sbin/munin-run zope_db_activity
|
||||
/opt/munin/sbin/munin-run zope_cache_parameters
|
||||
|
||||
Restart your munin-node and the graphs should appear shortly.
|
||||
|
||||
If you make any improvements (which should be easy), please update
|
||||
the munin exhange entry, or mail me at gaute(at)pht(dot)no
|
27
plugins/zope/zodb/scripts_python/munin_cache_parameters.py
Normal file
27
plugins/zope/zodb/scripts_python/munin_cache_parameters.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
## Script (Python) "munin_cache_parameters.py"
|
||||
##bind container=container
|
||||
##bind context=context
|
||||
##bind namespace=
|
||||
##bind script=script
|
||||
##bind subpath=traverse_subpath
|
||||
##parameters=
|
||||
##title=
|
||||
##
|
||||
"""
|
||||
Fetches data about the ZODB for the munin plugin "zope_cache_parameters".
|
||||
Needs the Manager proxy role to work.
|
||||
Only answers requests from localhost directly to zopes port.
|
||||
"""
|
||||
|
||||
req = context.REQUEST
|
||||
|
||||
if req['HTTP_X_FORWARDED_FOR'] or req['REMOTE_ADDR'] != '127.0.0.1':
|
||||
return "This script can only be called frm localhost"
|
||||
|
||||
maindb = context.restrictedTraverse('/Control_Panel/Database/main')
|
||||
|
||||
print maindb.database_size(), # Total number of objects in the database
|
||||
print maindb.cache_length(), # Total number of objects in memory from all caches
|
||||
print len(maindb.cache_detail_length()) * maindb.cache_size() # Target number of objects in memory sum total
|
||||
|
||||
return printed
|
34
plugins/zope/zodb/scripts_python/munin_db_activity.py
Normal file
34
plugins/zope/zodb/scripts_python/munin_db_activity.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
## Script (Python) "munin_db_activity.py"
|
||||
##bind container=container
|
||||
##bind context=context
|
||||
##bind namespace=
|
||||
##bind script=script
|
||||
##bind subpath=traverse_subpath
|
||||
##parameters=
|
||||
##title=
|
||||
##
|
||||
"""
|
||||
Fetches data about the ZODB for the munin plugin "zope_db_activity".
|
||||
Needs the Manager proxy role to work.
|
||||
Only answers requests from localhost directly to zopes port.
|
||||
"""
|
||||
|
||||
req = context.REQUEST
|
||||
|
||||
if req['HTTP_X_FORWARDED_FOR'] or req['REMOTE_ADDR'] != '127.0.0.1':
|
||||
return "This script can only be called frm localhost"
|
||||
|
||||
sec = 60*5 # 5 min is munins update frequency
|
||||
|
||||
now = float(DateTime())
|
||||
then = now-sec
|
||||
|
||||
request = dict(chart_start=then,
|
||||
chart_end=now)
|
||||
|
||||
maindb = context.restrictedTraverse('/Control_Panel/Database/main')
|
||||
cd = maindb.getActivityChartData(200, request)
|
||||
|
||||
print cd['total_load_count'],cd['total_store_count'],cd['total_connections']
|
||||
|
||||
return printed
|
43
plugins/zope/zodb/zope_cache_parameters
Executable file
43
plugins/zope/zodb/zope_cache_parameters
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from sys import argv
|
||||
import httplib
|
||||
conns = []
|
||||
|
||||
# this should really go in plugins.conf
|
||||
conns.append(httplib.HTTPConnection("localhost",8080))
|
||||
conns.append(httplib.HTTPConnection("localhost",8070))
|
||||
|
||||
|
||||
url = "/munin_cache_parameters.py"
|
||||
|
||||
if len(argv) > 1 and argv[1] == 'config':
|
||||
|
||||
# there is probably a better way to display this cached vs targed graph
|
||||
# as a percentage of target possibly..
|
||||
|
||||
print """graph_title Zope cache parameters
|
||||
graph_category Zope
|
||||
graph_info A grap of the main data on the "Cache Parameters" tab of the main DB in the zope control panel.""".replace("\n ","\n")
|
||||
for i in range(0,len(conns)):
|
||||
print """obs_in_db%(i)s.label Z%(i)s Obs in DB
|
||||
obs_cached%(i)s.label Z%(i)s obs in all caches
|
||||
obs_target%(i)s.label Z%(i)s cached obs target""".replace("\n ","\n") % dict(i=i)
|
||||
else:
|
||||
for i in range(0,len(conns)):
|
||||
conns[i].request("GET", url)
|
||||
|
||||
r1 = conns[i].getresponse()
|
||||
#print r1.status, r1.reason
|
||||
#200 OK
|
||||
data = r1.read().strip()
|
||||
conns[i].close()
|
||||
(obs_in_db, obs_cached, obs_target) = data.split()
|
||||
id = dict(i=i)
|
||||
print 'obs_in_db%(i)s.value' % id, obs_in_db
|
||||
print 'obs_cached%(i)s.value'% id, obs_cached
|
||||
print 'obs_target%(i)s.value'% id, obs_target
|
||||
|
||||
|
||||
|
||||
|
41
plugins/zope/zodb/zope_db_activity
Executable file
41
plugins/zope/zodb/zope_db_activity
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from sys import argv
|
||||
import httplib
|
||||
conns = []
|
||||
|
||||
# this should really go in plugins.conf
|
||||
conns.append(httplib.HTTPConnection("localhost",8080))
|
||||
conns.append(httplib.HTTPConnection("localhost",8070))
|
||||
|
||||
|
||||
url = "/munin_db_activity.py"
|
||||
|
||||
if len(argv) > 1 and argv[1] == 'config':
|
||||
|
||||
print """graph_title Zope Database Activity
|
||||
graph_vlabel Count / 5 min.
|
||||
graph_category Zope
|
||||
graph_info The number of Reads, Stores, and Connections that happens in the ZODB backend. The data comes from the same source as that in the "Recent Database Activity" tab in the zope control panel.""".replace("\n ","\n")
|
||||
for i in range(0,len(conns)):
|
||||
print """load_count%(i)s.label Z%(i)s Loads
|
||||
store_count%(i)s.label Z%(i)s Stores
|
||||
connections%(i)s.label Z%(i)s Connections""".replace("\n ","\n") % dict(i=i)
|
||||
else:
|
||||
for i in range(0,len(conns)):
|
||||
conns[i].request("GET", url)
|
||||
|
||||
r1 = conns[i].getresponse()
|
||||
#print r1.status, r1.reason
|
||||
#200 OK
|
||||
data = r1.read().strip()
|
||||
conns[i].close()
|
||||
(total_load_count, total_store_count, total_connections) = data.split()
|
||||
id = dict(i=i)
|
||||
print 'load_count%(i)s.value' % id, total_load_count
|
||||
print 'store_count%(i)s.value'% id, total_store_count
|
||||
print 'connections%(i)s.value'% id, total_connections
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue