CountTickets

From Request Tracker Wiki
Jump to: navigation, 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.

#!/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=<code>echo "select count(*) from Tickets where Tickets.Status=\"$Status\";" | mysql rt3</code> count=<code>echo $count | awk '{print $2}'</code> echo -e "$count\t<code>date -d '7 hours ago' '+%D %T'</code>" done

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.