2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/zope/scripts_zodb/munin_db_activity.py

35 lines
878 B
Python
Raw Normal View History

## 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