Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make trac_tickets.py a module so it can be imported.

  • Loading branch information...
commit 5a6f90cfe179e35eb44a702733b7a5d9952df929 1 parent 2020e48
@jacobian jacobian authored
Showing with 54 additions and 53 deletions.
  1. +0 −53 trac_tickets
  2. +1 −0  trac_tickets
  3. +53 −0 trac_tickets.py
View
53 trac_tickets
@@ -1,53 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import munin
-
-class TracTickets(munin.Plugin):
-
- # Queries to perform. Syntax is (label, info, query)
- queries = [
- ('unreviewed', 'Unreviewed', 'status=new|assigned|reopened&stage=Unreviewed'),
- ('design', 'Design decision needed', 'status=new|assigned|reopened&stage=Design decision needed'),
- ('accepted', 'Accepted', 'status=new|assigned|reopened&stage=Accepted'),
- ('ready', 'Ready for checkin', 'status=new|assigned|reopened&stage=Ready for checkin'),
- ]
-
- def fetch(self):
- from trac.ticket.query import Query
-
- env = self._connect()
- cursor = env.get_db_cnx().cursor()
-
- for label, info, query in self.queries:
- 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" % info, info)
- yield ("%s.type" % type, "GAUGE")
-
- 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)
View
1  trac_tickets
View
53 trac_tickets.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+import sys
+import munin
+
+class TracTickets(munin.Plugin):
+
+ # Queries to perform. Syntax is (label, info, query)
+ queries = [
+ ('unreviewed', 'Unreviewed', 'status=new|assigned|reopened&stage=Unreviewed'),
+ ('design', 'Design decision needed', 'status=new|assigned|reopened&stage=Design decision needed'),
+ ('accepted', 'Accepted', 'status=new|assigned|reopened&stage=Accepted'),
+ ('ready', 'Ready for checkin', 'status=new|assigned|reopened&stage=Ready for checkin'),
+ ]
+
+ def fetch(self):
+ from trac.ticket.query import Query
+
+ env = self._connect()
+ cursor = env.get_db_cnx().cursor()
+
+ for label, info, query in self.queries:
+ 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" % info, info)
+ yield ("%s.type" % type, "GAUGE")
+
+ 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)
Please sign in to comment.
Something went wrong with that request. Please try again.