Ticket announce email

I’m considering implementing a method of telling those that need to know when a
ticket has been in our triage queue untouched for a predetermined amount of time
(say, five minutes). I’d like to poll this queue and, if a ticket which meets
these requirements exists, send an email out telling people to act on it.

Has anyone done this before and if so, which method did you use?

Keep up with me and what I’m up to: http://theillien.blogspot.com

I do it using days, not minutes, but the concept is the same. Try using a
cron job that runs every 2 minutes. The perl API makes it easy to read
ticket values, so it would be pretty straightforward to compare Updated to
now() and send an e-mail if the difference is > 5min. It’s possible this
way to have a ticket languish for up to 6 minutes, but you could run the
cron every minute if it’s that critical.

Regards,
Gene

At 01:33 PM 11/27/2007, Mathew Snyder wrote:

I’m considering implementing a method of telling those that need to know
when a
ticket has been in our triage queue untouched for a predetermined amount
of time
(say, five minutes). I’d like to poll this queue and, if a ticket which meets
these requirements exists, send an email out telling people to act on it.

Has anyone done this before and if so, which method did you use?

Gene LeDuc, GSEC
Security Analyst
San Diego State University

I too do it on a daily basis… but I used the rt-remind script.

http://www.cs.kent.ac.uk/people/staff/tdb/rt3/

they have a few scripts, and I use them all on my 3.6 box.On Tue, 27 Nov 2007 16:33:50 -0500 Mathew Snyder theillien@yahoo.com wrote:

I’m considering implementing a method of telling those that need to know when a
ticket has been in our triage queue untouched for a predetermined amount of time
(say, five minutes). I’d like to poll this queue and, if a ticket which meets
these requirements exists, send an email out telling people to act on it.

Has anyone done this before and if so, which method did you use?

http://gentgeen.homelinux.org

Associate yourself with men of good quality if you esteem
your own reputation; for 'tis better to be alone then in bad
company. - George Washington, Rules of Civility

This is the script I came up with:
#!/usr/bin/perl

use warnings;
use strict;
use lib ‘/usr/local/rt3/lib’;
use lib ‘/usr/local/rt3/local/lib’;
use RT;
use RT::Tickets;
use RT::Users;
use MIME::Lite;
use Date::Parse;

RT::LoadConfig();
RT::Init();

my $tix = new RT::Tickets(RT::SystemUser);
$tix->FromSQL(‘Queue = “CustomerCare” AND Status = “new” AND Owner = “Nobody”’);

while (my $ticket = $tix->Next) {
my $diff = time - str2time($ticket->Created);
print $ticket->id . ": " . str2time($ticket->Created) . “\n”;
print time . “\n”;
print "diff: " . $diff . “\n”;
if (($diff/60) >= 5) {
print "diff adjusted: " . ($diff/60) . “\n”;
&email();
exit;
}
}

sub email {
my $emailTo = ‘msnyder@company.com’;
my $emailFrom = ‘RT-devel’;
my $emailSubj = ‘Tickets In CustomerCare Need Your Attention
TEST-DISREGARD’;
#my $emailMsg = ‘There are tickets in CustomerCare that are 5 or
more minutes old. These tickets require action even if it is placing them in
the appropriate queue. Please attend to these tickets.\n\nThank You’;
my $emailMsg = ‘This is a test message for a script I am working on.’;

    my $fullEmail    = new MIME::Lite(From    => $emailFrom,
                                      To      => $emailTo,
                                      Subject => $emailSubj,
                                      Type    => "multipart/mixed"
                                      );

    $fullEmail->attach(Type            => "TEXT",
                       Data            => $emailMsg
                      );

    $fullEmail->send("sendmail", "/usr/sbin/sendmail -t");

}

This refuses to work though. If I leave it as is I get a negative number for
$diff/60 because $ticket->Created indicates a number greater than time(). I can
only guess it has something to do with timezones but I don’t know. If I reverse
the operands and subtract time from the ticket creation I get a number in the
200s but which is always shrinking and will end up in the negatives because I
shouldn’t be subtracting time from teh created time anyway.

This is sampler output when subtracting ticket created time from time():
Ticket Created Time: 1196291034
time(): 1196273826
diff: -17208

and when subtracting time() from the ticket creation time:
Ticket Created Time: 1196291034
time(): 1196273872
diff: 17162On top of all this, even when the number comes out positive, dividing by 60 (which I’m assuming I have to do as time and str2time output time since the epoch as seconds) spits out a number that doesn’t even correlate. Can someone take a look at this and help me out. Thanks. Keep up with me and what I’m up to: http://theillien.blogspot.com Gene LeDuc wrote:

I do it using days, not minutes, but the concept is the same. Try using
a cron job that runs every 2 minutes. The perl API makes it easy to
read ticket values, so it would be pretty straightforward to compare
Updated to now() and send an e-mail if the difference is > 5min. It’s
possible this way to have a ticket languish for up to 6 minutes, but you
could run the cron every minute if it’s that critical.

Regards,
Gene

At 01:33 PM 11/27/2007, Mathew Snyder wrote:

I’m considering implementing a method of telling those that need to
know when a
ticket has been in our triage queue untouched for a predetermined
amount of time
(say, five minutes). I’d like to poll this queue and, if a ticket
which meets
these requirements exists, send an email out telling people to act on it.

Has anyone done this before and if so, which method did you use?

Hi Mathew,

Start by printing out the applicable elements ([0] - [5] and [8]) from
localtime(str2time($ticket->Created)) and comparing them to what you see in
RT, then print the same elements from localtime(time) and see what you
get. If it’s a timezone or DST issue you can compensate for it. Once you
get time values you can trust you work on the next issue.

Gene

At 10:25 AM 11/28/2007, Mathew Snyder wrote:

This is the script I came up with:
#!/usr/bin/perl

use warnings;
use strict;
use lib ‘/usr/local/rt3/lib’;
use lib ‘/usr/local/rt3/local/lib’;
use RT;
use RT::Tickets;
use RT::Users;
use MIME::Lite;
use Date::Parse;

RT::LoadConfig();
RT::Init();

my $tix = new RT::Tickets(RT::SystemUser);
$tix->FromSQL(‘Queue = “CustomerCare” AND Status = “new” AND Owner =
“Nobody”’);

while (my $ticket = $tix->Next) {
my $diff = time - str2time($ticket->Created);
print $ticket->id . ": " . str2time($ticket->Created) . “\n”;
print time . “\n”;
print "diff: " . $diff . “\n”;
if (($diff/60) >= 5) {
print "diff adjusted: " . ($diff/60) . “\n”;
&email();
exit;
}
}

sub email {
my $emailTo = ‘msnyder@company.com’;
my $emailFrom = ‘RT-devel’;
my $emailSubj = ‘Tickets In CustomerCare Need Your Attention
TEST-DISREGARD’;
#my $emailMsg = ‘There are tickets in CustomerCare that are 5 or
more minutes old. These tickets require action even if it is placing them in
the appropriate queue. Please attend to these tickets.\n\nThank You’;
my $emailMsg = ‘This is a test message for a script I am
working on.’;

    my $fullEmail    = new MIME::Lite(From    => $emailFrom,
                                      To      => $emailTo,
                                      Subject => $emailSubj,
                                      Type    => "multipart/mixed"
                                      );

    $fullEmail->attach(Type            => "TEXT",
                       Data            => $emailMsg
                      );

    $fullEmail->send("sendmail", "/usr/sbin/sendmail -t");

}

This refuses to work though. If I leave it as is I get a negative number for
$diff/60 because $ticket->Created indicates a number greater than
time(). I can
only guess it has something to do with timezones but I don’t know. If I
reverse
the operands and subtract time from the ticket creation I get a number in the
200s but which is always shrinking and will end up in the negatives because I
shouldn’t be subtracting time from teh created time anyway.

This is sampler output when subtracting ticket created time from time():
Ticket Created Time: 1196291034
time(): 1196273826
diff: -17208

and when subtracting time() from the ticket creation time:
Ticket Created Time: 1196291034
time(): 1196273872
diff: 17162

I do it using days, not minutes, but the concept is the same. Try using
a cron job that runs every 2 minutes. The perl API makes it easy to
read ticket values, so it would be pretty straightforward to compare
Updated to now() and send an e-mail if the difference is > 5min. It’s
possible this way to have a ticket languish for up to 6 minutes, but you
could run the cron every minute if it’s that critical.

Regards,
Gene

At 01:33 PM 11/27/2007, Mathew Snyder wrote:

I’m considering implementing a method of telling those that need to
know when a
ticket has been in our triage queue untouched for a predetermined
amount of time
(say, five minutes). I’d like to poll this queue and, if a ticket
which meets
these requirements exists, send an email out telling people to act on it.

Has anyone done this before and if so, which method did you use?

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Forgive my ignorance but, I’m not seeing how to compare them to what I see in RT.

Elements 0-5 and 8 from localtime(str2time($ticket->Created):
54 3 18 28 10 107 0

What the Created field for the ticket I’m looking at says:
Wed Nov 28 13:03:54 2007

Elements 0-5 and 8 from localtime(time());
52 47 14 28 10 107 0

Keep up with me and what I’m up to: http://theillien.blogspot.com

Gene LeDuc wrote: