I was just trying to get some stats for my boss concerning how quickly
I close tickets.
In looking through the data, I came up with this output from rt.
Created:Sat May 13 15:53:56 2000
Last User Contact:Wed Dec 31 19:00:00 1969
Due:Wed Dec 31 19:00:00 1969
Hmm, dates look wierd to me since standard format elsewhere is:
Taken by rouilj
For 2.0 the dates should really be standardized in the second format, it
life a bit easier.
Also it would be nice is to have the age field parameter in rtq unit
so you could get it in days, weeks, hours etc. There is a big difference
2 months and 2 months and 3 weeks. Putting the age in days or hours would
really well for graphing etc.
The age field should also become a duration field showing the time between
creation and resolution for resolved tickets. Currently it just seems to do:
TodayDate - CreationDate
which is kind of silly for resolved tickets. Is there a place in the
where the resolution time is cached (or zero if the ticket isn’t resolved)?
This would be faster than scanning all the transactions for their date
In any case this script might be of use for those who want to generate time
to resolution reports on tickets. Its a fast hack, but it seems to work. It
gnu date’s %s parameter to convert dates into seconds from 1/1/1970 and a
The script has two flags.
-u which sets output times for
d - days and quarters of days,
h - hours and quarter of hours,
m - minutes
-n - which lists the ticket number with the times.
I use it like:
~/bin/servicetime -n -u d
rtq -format '%n' -prio \> 49 -resolved | tail +4
Without the -n, I just get the times and not the ticket numbers in the left
Here is the script:
----- snip snip -----
given a series of rt ticket numbers, loop over them and find the time
it took to finally resolve them.
if [ $# -eq 0 ]; then
echo "Usage: $prog [-u m|h|s] [-n] rt_ticket_numbers"
getopt -o u:n \ --long units:number \ -n $prog -- "$@"
if [ $? != 0 ] ; then echo “$prog: Terminating…” >&2 ; exit 1 ; fi
eval set – “$GETOPTCMD”
while true ; do
case “$1” in
-u|–units) output_units=$2; shift 2 ;;
-n|–number) show_ticket_numbers=1; shift;;
–) shift; break;;
for i in $@
rt -show $i | \ egrep -B1 "Created:|Status changed to resolved" | \ egrep 'Date:|Created:'
echo $DATES | sed -ne 's/.*Created:....\([^:]*\)\(..:..:..\).\(....\).*/\2 \1\3/' -e '1p'
echo $DATES | tail -1 | sed -e 's/.*, \([^:]*\)\(..:..:..\).*/\2 \1/'
date +%s -d "$CreateDate"
date +%s -d "$ResolveDate"
expr $RDSec - $CDSec # some expr’s don’t handle ()'s.
expr $SecDiff / 60
if [ $show_ticket_numbers -ne 0 ]; then
case $output_units in
m) echo $ticketnum $MinDiff # report in minutes
expr $MinDiff / 60 # report in hours and .25 of hour
expr $MinDiff - $fullhour \* 60
for j in 0 1 2 3
expr 15 \* $j + 7 # round up/down to quarter hour
if [ $remainMin -lt $MaxVal ]; then
echo $ticketnum $fullhour.
expr 25 \* $j
expr $MinDiff / 60 # report in days and .25 of days
expr $HourDiff / 24
expr $HourDiff - $fulldays \* 24
for j in 0 1 2 3
expr 6 \* $j + 3 # round up/down to quarter day
if [ $remainHour -lt $MaxVal ]; then
echo $ticketnum $fulldays.
expr 25 \* $j
*) echo "Invalid unit parameter."
echo “Usage: $prog [-u m|h|s] [-n] rt_ticket_numbers”
---- end snip ------