[rt-users] A MRTG script for Request Tracker
Stephane Bortzmeyer
bortzmeyer at netaktiv.com
Mon Apr 29 08:15:08 EDT 2002
One thing I like with Request Tracker is that it relies on a
RDBMS. So, anything which is not done by RT can be easily implemented
in SQL. (See the recurrent thread abou reporting.)
Today, a small Python program to gather statistics from the RT
database and to output them in MRTG format. That way, the managers
can spend the whole day watching the work of the support staff :-)
It uses PostgreSQL but the SQL is standard and it should work with
MySQL.
#!/usr/bin/python
# $Id: rt2mrtg.py,v 1.1 2002/04/29 10:59:46 bortzmeyer Exp $
import string
from pyPgSQL import PgSQL
dsn = "::rt2"
db = PgSQL.connect(dsn)
st = db.cursor()
st.execute("SELECT count(id) FROM tickets WHERE status = 'open' OR status = 'new'")
res = st.fetchone()
all_tickets = res[0]
# If you are not using priorities, display something else, such as
# tickets older than a month.
st.execute("SELECT count(id) FROM tickets WHERE (status = 'open' OR status = 'new') AND priority > 0")
res = st.fetchone()
high_pri_tickets = res[0]
print high_pri_tickets
print all_tickets
print "uptime is not meaningful for Request Tracker"
print "database " + dsn
##########
MRTG configuration:
Target[rt]: `python ./rt2mrtg.py`
MaxBytes[rt]: 10000000
Title[rt]: Tickets open in Request Tracker
Colours[rt]: orange#ff2222,blue#1111ff,DARK GREEN#006600,VIOLET#ff00ff
Options[rt]: growright,nopercent,gauge,noinfo
YLegend[rt]: Tickets
ShortLegend[rt]: tickets
LegendO[rt]: all
LegendI[rt]: high pri
Legend1[rt]: Tickets open (with priority>0)
Legend2[rt]: Tickets open
PageTop[rt]: <H1>To do
</H1>
<TABLE>
<TR><TD>System:</TD><TD><A HREF="http://rt.YOURDOMAIN/">rt.YOURDOMAIN</A></TD></TR>
<TR><TD>Maintainer:</TD><td>YOURADDRESS</TD></TR>
</TABLE>
More information about the rt-users
mailing list