<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>A MRTG script for Request Tracker : MySQL</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Thanks Stephane for your MRTG script.</FONT>
</P>
<P><FONT SIZE=2>I have ported it to MySQL quite easily. The steps are :</FONT>
</P>
<P><FONT SIZE=2>Install MySQL-python.0.9.1 (can be found at www.mysql.com)</FONT>
<BR><FONT SIZE=2>Install Distutils.1.0.2 if your Python version is too old (can be found any Python archive)</FONT>
</P>
<P><FONT SIZE=2>Use the modified script below. Note that SQL statements are case sensitive.</FONT>
</P>
<P><FONT SIZE=2>#!/usr/bin/python</FONT>
</P>
<P><FONT SIZE=2># $Id: rt2mrtg.py,v 1.1 2002/04/29 10:59:46 bortzmeyer Exp $</FONT>
</P>
<P><FONT SIZE=2>import string</FONT>
<BR><FONT SIZE=2>import MySQLdb</FONT>
</P>
<P><FONT SIZE=2>dsn = "rt2"</FONT>
<BR><FONT SIZE=2>db = MySQLdb.connect(user="rt_user", passwd="xxxx", db=dsn)</FONT>
<BR><FONT SIZE=2>st = db.cursor()</FONT>
</P>
<P><FONT SIZE=2>st.execute("SELECT count(id) FROM Tickets WHERE status = 'open' OR status = 'new'")</FONT>
<BR><FONT SIZE=2>res = st.fetchone()</FONT>
<BR><FONT SIZE=2>all_tickets = res[0]</FONT>
</P>
<P><FONT SIZE=2># If you are not using priorities, display something else, such as</FONT>
<BR><FONT SIZE=2># tickets older than a month.</FONT>
<BR><FONT SIZE=2>st.execute("SELECT count(id) FROM Tickets WHERE (status = 'open' OR status = 'new') AND priority > 0")</FONT>
<BR><FONT SIZE=2>res = st.fetchone()</FONT>
<BR><FONT SIZE=2>high_pri_tickets = res[0]</FONT>
</P>
<P><FONT SIZE=2>print high_pri_tickets</FONT>
<BR><FONT SIZE=2>print all_tickets</FONT>
<BR><FONT SIZE=2>print "uptime is not meaningful for Request Tracker"</FONT>
<BR><FONT SIZE=2>print "database " + dsn</FONT>
</P>
<P><FONT SIZE=2>-----------------------------------------------</FONT>
<BR><FONT SIZE=2>The MRTG script provided with the Postgres version does not need any change.</FONT>
</P>
<BR>
<P><FONT SIZE=2>Blaise Thauvin</FONT>
<BR><FONT SIZE=2>Blaise@fdn.Fr</FONT>
</P>
</BODY>
</HTML>