CountTickets

From Request Tracker Wiki
Jump to navigation Jump to search

This script, written in BASH, will query for how many tickets there are in the DB for either all status (configurable inside the script) or a supplied argument naming a queue.

<pre>
 #!/bin/bash
 
 Statuses=( new open stalled resolved rejected deleted )
 if [ $1 ] ; then Statuses=( $* ) ; fi
 
 for Status in ${Statuses[@]} ; do
   echo -en "$Status:\t"
   if [ ${#Status} -lt 7 ] ; then echo -en "\t" ; fi
   count=`echo "select count(*) from Tickets where Tickets.Status=\"$Status\";" | mysql rt3`
   count=`echo $count | awk '{print $2}'`
   echo -e "$count\t`date -d '7 hours ago' '+%D %T'`"
 done
 
</pre>

I echo the time after each entry in case it takes a while for each query to finish - for use in timing ticket count changes (perhaps while watching RTx-Shredder at work).

This is especially handy for 'deleted' tickets. Those aren't searchable via the RT interface.