Cron job for creating tickets and child tickets

I’m trying to set up a cron job which will send an email to RT. This ticket
should spawn three child tickets. Technically, it works. The child tickets are
spawned however, it enters a loop and continuously spawns child tickets. I
think it is due to the condition I’ve created but I’m not sure.

I’ve created the following template

===Create-Ticket: Patch Testing for Windows - Child
Parents: TOP
Queue: SysEng
Type: ticket
Content: Time to test patches for our next Windows patch cycle
ENDOFCONTENT

===Create-Ticket: Patch Testing for Solaris - Child
Parents: TOP
Queue: SysEng
Type: ticket
Content: Time to test patches for our next Solaris patch cycle
ENDOFCONTENT

===Create-Ticket: Patch Testing for Linux - Child
Parents: TOP
Queue: SysEng
Type: ticket
Content: Time to test patches for our next Linux patch cycle
ENDOFCONTENT

and the following scrip

Condition: User Defined
Action: Create Tickets
Template: PatchTestingChildren
Stage: TransactionCreate

Custom Condition:
if ($self->TransactionObj->Type eq “Create” && $self->TicketObj->Subject =~
/^Patch Testing for\s?/){
return 1;
} else {
return 0;
}

This is the script I’m running as my cron job:

#!/usr/bin/perl

use warnings;
use strict;
use MIME::Lite;
use DateTime;

my $dt = DateTime->now;
my $month_name = $dt->month_name;

my $emailTo = “sysengdev@rt-devel.ops.servervault.com”;
my $emailFrom = “msnyder@servervault.com”;

my $emailSubj = “Patch Testing for $month_name”;
my $emailMsg = “Time to start testing patches for our next patch cycle.”;

my $fullEmail = new MIME::Lite(From => $emailFrom,
To => $emailTo,
Subject => $emailSubj,
Data => $emailMsg);

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

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

Anyone have any thoughts on this?

Keep up with my goings on at http://theillien.blogspot.com

Mathew Snyder wrote:

Try changing:

Custom Condition:
if ($self->TransactionObj->Type eq “Create” && $self->TicketObj->Subject =~ /^Patch Testing for\s?/){

To:

Custom Condition:
if ($self->TransactionObj->Type eq “Create” && $self->TicketObj->Subject =~ /^Patch Testing for\s?/ && $self->TicketObj->Subject !~ /Child$/){

It looks like each child ticket matches your original condition, and the custom condition will match each of them, when it runs, creating new child tickets, etc, etc, etc. Just a thought.

Jacob Helwig
PC Technician
Busch’s Help Desk
Desk: x35221
Direct: 734-214-8221From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Mathew
Sent: Thursday, September 27, 2007 2:18 PM
To: RT Users
Subject: Re: [rt-users] cron job for creating tickets and child tickets

Anyone have any thoughts on this?

Keep up with my goings on at http://theillien.blogspot.com

Mathew Snyder wrote:

I’m trying to set up a cron job which will send an email to RT. This ticket
should spawn three child tickets. Technically, it works. The child tickets are
spawned however, it enters a loop and continuously spawns child tickets. I
think it is due to the condition I’ve created but I’m not sure.

I’ve created the following template

===Create-Ticket: Patch Testing for Windows - Child
Subject: {$Tickets{‘TOP’}->Subject} - Windows - Child
Parents: TOP
Queue: SysEng
Type: ticket
Content: Time to test patches for our next Windows patch cycle
ENDOFCONTENT

===Create-Ticket: Patch Testing for Solaris - Child
Subject: {$Tickets{‘TOP’}->Subject} - Solaris - Child
Parents: TOP
Queue: SysEng
Type: ticket
Content: Time to test patches for our next Solaris patch cycle
ENDOFCONTENT

===Create-Ticket: Patch Testing for Linux - Child
Subject: {$Tickets{‘TOP’}->Subject} - Linux - Child
Parents: TOP
Queue: SysEng
Type: ticket
Content: Time to test patches for our next Linux patch cycle
ENDOFCONTENT

and the following scrip

Condition: User Defined
Action: Create Tickets
Template: PatchTestingChildren
Stage: TransactionCreate

Custom Condition:
if ($self->TransactionObj->Type eq “Create” && $self->TicketObj->Subject =~
/^Patch Testing for\s?/){
return 1;
} else {
return 0;
}

This is the script I’m running as my cron job:

#!/usr/bin/perl

use warnings;
use strict;
use MIME::Lite;
use DateTime;

my $dt = DateTime->now;
my $month_name = $dt->month_name;

my $emailTo = “sysengdev@rt-devel.ops.servervault.com”;
my $emailFrom = “msnyder@servervault.com”;

my $emailSubj = “Patch Testing for $month_name”;
my $emailMsg = “Time to start testing patches for our next patch cycle.”;

my $fullEmail = new MIME::Lite(From => $emailFrom,
To => $emailTo,
Subject => $emailSubj,
Data => $emailMsg);

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

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Thanks. I’ll give that a try.

Keep up with my goings on at http://theillien.blogspot.com

Jacob Helwig wrote:

That extra condition did the trick. Thanks.

Mathew
Keep up with my goings on at http://theillien.blogspot.com

Jacob Helwig wrote: