=====================
Munin statistic views
=====================

The LMS provides views that show performance data about the system which can
be graphed in e.g. Munin [#functionaltest]_.

Access is only granted with a special permission, anonymous user's cant access
those views.

Size of queue
=============

The current (approximate) size of the queue can be displayed:

>>> from zope.testbrowser.testing import Browser
>>> browser = Browser()
>>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
>>> browser.open('http://localhost/app/@@munin-queuesize')
>>> browser.handleErrors = False
>>> print browser.contents
queue-size:0

Let's put something into the queue:

>>> from zope.component import getUtility
>>> from zc.queue.interfaces import IQueue
>>> queue = getUtility(IQueue, name='check')
>>> queue.put(1)

Now, the size is 1:

>>> browser.reload()
>>> print browser.contents
queue-size:1


Number of threads
=================

The number of threads needs to be retrieved from the scheduler process.  This
process writes this number into the database in the statistics object:

>>> root['app'].getSiteManager()['statistics'].thread_pool
0

The corresponding view simply returns this number:

>>> browser.open('http://localhost/app/@@munin-threadpool')
>>> print browser.contents
thread-pool:0

>>> root['app'].getSiteManager()['statistics'].thread_pool = 27
>>> browser.reload()
>>> print browser.contents
thread-pool:27


.. [#functionaltest] Setup functional test

    >>> import gocept.lms.app
    >>> root = getRootFolder()
    >>> import zope.app.component.hooks
    >>> old_site = zope.app.component.hooks.getSite()
    >>> zope.app.component.hooks.setSite(root)

    >>> root['app'] = gocept.lms.app.LMS()
    >>> zope.app.component.hooks.setSite(root['app'])
