q = Query.from_string(env, query)
            cursor.execute(*q.get_sql())
            yield ("%s.value" % label, len(list(cursor)))
    
    def config(self):
        yield ('graph_title', 'Trac tickets')
        yield ('graph_args', '-l 0 --base 1000')
        yield ('graph_vlabel', 'Tickets')
        yield ('graph_scale', 'no')
        yield ('graph_category', 'Trac')
        yield ('graph_info', 'Shows current Trac ticket counts')
        for label, info, query in self.queries:
            yield ("%s.label" % label, label)
            yield ("%s.info" % label, info)

    def _connect(self):
        # Both of the below won't work if PYTHONPATH and TRAC_ENV aren't
        # set in the munin-node plugin conf.
        import trac.env
        return trac.env.open_environment()
        
    def autoconf(self):
        try:
            self._connect()
        except:
            return False
        return True

if __name__ == '__main__':
    munin.run(TracTickets)
Exemple #2
0
            yield ('%s.value' % slugify(result.test.slug), result.duration)
    
    def config(self):
        yield ('graph_title', 'LJWorld')
        yield ('graph_args', '-l 0 --base 1000')
        yield ('graph_vlabel', 'Duration')
        yield ('graph_scale', 'no')
        yield ('graph_category', 'kong')
        yield ('graph_info', 'Shows the duration of Kong tests.')
        for test in  self.tests:
            yield ("%s.label" % slugify(test.slug), test.name)
            yield ("%s.info" % slugify(test.slug), test.name)
            yield ("%s.draw" % slugify(test.slug), "LINE1")
 
if __name__ == '__main__':
    munin.run(KongDuration)

########NEW FILE########
__FILENAME__ = munin
"""
Originally from: http://github.com/jacobian/munin-plugins/blob/master/munin.py

Microframework for writing Munin plugins with Python.

Howto:

    * Subclass ``Plugin``.
    
    * Define at least ``fetch`` and ``config``, and possibly others (see
      below).
    
Exemple #3
0

def slugify(string):
    return string.replace('-', '_')


class KongDuration(munin.Plugin):
    tests = Test.objects.all()

    def fetch(self):
        limit = len(self.tests) - 1
        results = TestResult.objects.filter(site__pk=2)[:limit]
        for result in results:
            yield ('%s.value' % slugify(result.test.slug), result.duration)

    def config(self):
        yield ('graph_title', 'LJWorld')
        yield ('graph_args', '-l 0 --base 1000')
        yield ('graph_vlabel', 'Duration')
        yield ('graph_scale', 'no')
        yield ('graph_category', 'kong')
        yield ('graph_info', 'Shows the duration of Kong tests.')
        for test in self.tests:
            yield ("%s.label" % slugify(test.slug), test.name)
            yield ("%s.info" % slugify(test.slug), test.name)
            yield ("%s.draw" % slugify(test.slug), "LINE1")


if __name__ == '__main__':
    munin.run(KongDuration)
Exemple #4
0
            cursor.execute(*q.get_sql())
            yield ("%s.value" % label, len(list(cursor)))

    def config(self):
        yield ('graph_title', 'Trac tickets')
        yield ('graph_args', '-l 0 --base 1000')
        yield ('graph_vlabel', 'Tickets')
        yield ('graph_scale', 'no')
        yield ('graph_category', 'Trac')
        yield ('graph_info', 'Shows current Trac ticket counts')
        for label, info, query in self.queries:
            yield ("%s.label" % label, label)
            yield ("%s.info" % label, info)

    def _connect(self):
        # Both of the below won't work if PYTHONPATH and TRAC_ENV aren't
        # set in the munin-node plugin conf.
        import trac.env
        return trac.env.open_environment()

    def autoconf(self):
        try:
            self._connect()
        except:
            return False
        return True


if __name__ == '__main__':
    munin.run(TracTickets)