A MRTG script for Request Tracker

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 :slight_smile:

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]:

To do

System: rt.YOURDOMAIN
Maintainer: YOURADDRESS

We do sorta the same thing. But I wrote an snmp daemon for RT, and using
that, we just have MRTG poll the SNMP MIBs that I defined. Works great
for us.

a message of 3 lines which said:

We do sorta the same thing. But I wrote an snmp daemon for RT, and using
that, we just have MRTG poll the SNMP MIBs that I defined. Works great
for us.

Yes, I saw your work in, contrib/. Let’s say that your solution is
better if you have SNMP/MIB knowledge inside (the current MIB does not
provide a lot of objects so you have to extend it if you just want,
say, the tickets with a priority>0 ) and mine is preferrable if you
have SQL knowledge in your company.

|+ Yes, I saw your work in, contrib/. Let’s say that your solution is
|+ better if you have SNMP/MIB knowledge inside (the current MIB does not
|+ provide a lot of objects so you have to extend it if you just want,
|+ say, the tickets with a priority>0 ) and mine is preferrable if you
|+ have SQL knowledge in your company.

True. I wrote the MIB with room for people to expand it themselves. I
could have gone through and added a lot more MIBs for general use, but I
didn’t know who would want what. We currently have about 20 different
MIBs defined in ours, but other companies may only need 2 of those :slight_smile:

I guess I could write documentation on how to add other mibs to it.

-darrin (who is playing with your script on my testing server)

Just curious, what’s MRTG?
James.-----Original Message-----
From: Darrin Walton [mailto:darrinw@nixc.net]
Sent: Monday, April 29, 2002 6:51 AM
To: Stephane Bortzmeyer
Cc: rt-users@lists.fsck.com
Subject: Re: [rt-users] A MRTG script for Request Tracker

|+ Yes, I saw your work in, contrib/. Let’s say that your solution is
|+ better if you have SNMP/MIB knowledge inside (the current MIB does not
|+ provide a lot of objects so you have to extend it if you just want,
|+ say, the tickets with a priority>0 ) and mine is preferrable if you
|+ have SQL knowledge in your company.

True. I wrote the MIB with room for people to expand it themselves. I
could have gone through and added a lot more MIBs for general use, but I
didn’t know who would want what. We currently have about 20 different MIBs
defined in ours, but other companies may only need 2 of those :slight_smile:

I guess I could write documentation on how to add other mibs to it.

-darrin (who is playing with your script on my testing server)

rt-users mailing list
rt-users@lists.fsck.com http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

a message of 33 lines which said:

Just curious, what’s MRTG?

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg.html

Looks spiffy, but I fail to see how this is generating useful reports from
rt2. Any chance of seeing a screenshot of the output you guys are getting
from what you’ve written?

James.From: Stephane Bortzmeyer [mailto:bortzmeyer@netaktiv.com]
Sent: Monday, April 29, 2002 8:35 AM
To: James Satterfield
Cc: ‘Darrin Walton’; Stephane Bortzmeyer; rt-users@lists.fsck.com
Subject: Re: [rt-users] A MRTG script for Request Tracker

a message of 33 lines which said:

Just curious, what’s MRTG?

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg.html

James Satterfield JSatterfield@ciphergen.com �crit :

Just curious, what’s MRTG?

Multi router traffic grapher
URL:http://people.ee.ethz.ch/~oetiker/webtools/mrtg/, you can’t
live without it.

Marc Baudoin | Institut Pasteur
babafou@pasteur.fr | P�le informatique - syst�mes et r�seau

|+ Looks spiffy, but I fail to see how this is generating useful reports from
|+ rt2. Any chance of seeing a screenshot of the output you guys are getting
|+ from what you’ve written?

its basically jsut doing wht MRTG does for bandwidth utilization on router
links (such as we use here).

It just shows a graph of open tickets, closed tickets, new tickets, etc
and takes stats at 5 minutes intervals.

a message of 17 lines which said:

Multi router traffic grapher
URL:http://people.ee.ethz.ch/~oetiker/webtools/mrtg/, you can’t
live without it.

Some people rather live with Cricket :slight_smile:

http://cricket.sourceforge.net/