Follow-up question on Merge Ticket with existing ticket with the same subject

Thanks for the help. I was able to make the scrip below work.

The scrip was able to merge new ticket with Subject: "Test Ticket Subject"
to an existing ticket with the same subject.

Just few more questions:

  • what to add on the scrip to ignore preceeding characters such as RE: and
    FWD:? A new ticket with subject: “RE: Test Ticket Subject” to an existing
    ticket with the same subject
  • the scrip does not merge new ticket with subject: “** PROBLEM alert -
    Saturn backup server/DNS is CRITICAL **” to an existing ticket with the same
    subject. Is there a syntax that I need to add for this?

All help will be greatly appreciated.

Thanks!
my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$problem_desc = $subject;
$RT::Logger->debug(“This is the subject to match: $problem_desc”);

look for subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
# Ignore this ticket that opened this transaction
next if $self->TicketObj->Id == $ticket->Id;
$same_desc=$ticket->Subject;
#if ($same_desc eq $problem_desc){
if ($problem_desc eq $same_desc){
# Found the same subject
$RT::Logger->debug(“SAME $same_desc and $problem_desc”);
$id = $ticket->Id;
$RT::Logger->debug(“Merging ticket " . $self->TicketObj->Id . " into
$id because of OA number match.”);
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;On Fri, Aug 14, 2009 at 9:41 AM, Rémi mirebob@gmail.com wrote:

hi
try using $TicketObj->SetSubject() function,

$TicketObj->Subject is just an accessor method

Rémi

2009/8/13 rmp dmd rmp.dmd1229@gmail.com

Hi,

I’m using the scrip below to merge newly created ticket with existing
ticket with the same subject. However, im getting

Scrip 36 Commit failed: Can’t modify non-lvalue subroutine call at (eval
1311) line 21.

code for line 21 is :
$ticket->Subject = $same_desc;

Im not exactly sure what the error means. Please help in making the scrip
work.

Thanks!

====

my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$problem_desc = $subject;
$RT::Logger->debug(“This is the subject to match: $problem_desc”);

look for subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
# Ignore this ticket that opened this transaction
next if $self->TicketObj->Id == $ticket->Id;
$ticket->Subject = $same_desc;
if ($same_desc eq $problem_desc){
# Found the same subject
$RT::Logger->debug(“SAME $same_desc and $problem_desc”);
$id = $ticket->Id;
$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . “
into $id because of OA number match.”);
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;


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

Experts,

I hope you can help me on below.

I’ve been trying some modifications, but I could not get it working.

Thanks!
RoehlOn Mon, Aug 17, 2009 at 3:49 PM, rmp dmd rmp.dmd1229@gmail.com wrote:

Thanks for the help. I was able to make the scrip below work.

The scrip was able to merge new ticket with Subject: "Test Ticket Subject"
to an existing ticket with the same subject.

Just few more questions:

  • what to add on the scrip to ignore preceeding characters such as RE: and
    FWD:? A new ticket with subject: “RE: Test Ticket Subject” to an existing
    ticket with the same subject
  • the scrip does not merge new ticket with subject: “** PROBLEM alert -
    Saturn backup server/DNS is CRITICAL **” to an existing ticket with the same
    subject. Is there a syntax that I need to add for this?

All help will be greatly appreciated.

Thanks!

my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$problem_desc = $subject;
$RT::Logger->debug(“This is the subject to match: $problem_desc”);

look for subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
# Ignore this ticket that opened this transaction
next if $self->TicketObj->Id == $ticket->Id;
$same_desc=$ticket->Subject;
#if ($same_desc eq $problem_desc){
if ($problem_desc eq $same_desc){
# Found the same subject
$RT::Logger->debug(“SAME $same_desc and $problem_desc”);
$id = $ticket->Id;
$RT::Logger->debug(“Merging ticket " . $self->TicketObj->Id . " into
$id because of OA number match.”);
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;

On Fri, Aug 14, 2009 at 9:41 AM, Rémi mirebob@gmail.com wrote:

hi
try using $TicketObj->SetSubject() function,

$TicketObj->Subject is just an accessor method

Rémi

2009/8/13 rmp dmd rmp.dmd1229@gmail.com

Hi,

I’m using the scrip below to merge newly created ticket with existing
ticket with the same subject. However, im getting

Scrip 36 Commit failed: Can’t modify non-lvalue subroutine call at (eval
1311) line 21.

code for line 21 is :
$ticket->Subject = $same_desc;

Im not exactly sure what the error means. Please help in making the scrip
work.

Thanks!

====

my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$problem_desc = $subject;
$RT::Logger->debug(“This is the subject to match: $problem_desc”);

look for subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
# Ignore this ticket that opened this transaction
next if $self->TicketObj->Id == $ticket->Id;
$ticket->Subject = $same_desc;
if ($same_desc eq $problem_desc){
# Found the same subject
$RT::Logger->debug(“SAME $same_desc and $problem_desc”);
$id = $ticket->Id;
$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . “
into $id because of OA number match.”);
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;


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

Hi All,

I adjusted my scrip to below in order for to have auto merging of tickets:

The scrip

  • merge ticket with the same subject
  • merge the same nagios PROBLEM alert
  • merge nagios RECOVERY alert to corresponding PROBLEM alert
  • merge ticket with new ticket RE: and FW: on the subject with similar
    subject.

However some email clients append Re instead of RE and Fw: instead of FW:.
Im figuring it out, but nothing came up yet.

Any help to adjust the script to accept that condition?

Thanks!

If the subject of the ticket matches a pattern suggesting

that this is a Nagios RECOVERY message AND there is

an existing ticket (open or new) in the “IT” queue with a matching

“problem description”, (that is not this ticket)

merge this ticket into that ticket

Based on http://marc.free.net.ph/message/20040319.180325.27528377.en.html

my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if (($subject =~ /** RECOVERY (\w+) - (.) OK **/) || ($subject =~ /**
PROBLEM (\w+) - (.
) CRITICAL **/)) {
# This looks like a nagios recovery message
$problem_desc = $2;
# Ok, now let’s merge this ticket with it’s PROBLEM msg.
my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
while (my $ticket = $search->Next) {
# Ignore the ticket that opened this transation (the recovery
one…)
next if $self->TicketObj->Id == $ticket->Id;
# Look for nagios PROBLEM warning messages…
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
if ($2 eq $problem_desc){
# Aha! Found the Problem TICKET corresponding to this
RECOVERY
# ticket
$id = $ticket->Id;
# Nagios may send more then one PROBLEM message, right?
#$RT::Logger->debug(“Merging ticket " . $self->TicketObj->Id
. " into $id because of OA number match.”);
$self->TicketObj->MergeInto($id);

            # Keep looking for more PROBLEM tickets...
        }
    }
    }

$id || return 1;

Auto-close/resolve this whole thing

#$self->TicketObj->SetStatus( “resolved” );
1;
} else {
my $notnagios_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$notnagios_desc = $subject;

look for same subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
my $same_desc_re = undef;
my $same_desc_fw = undef;
while (my $ticket = $search->Next) {

Ignore this ticket that opened this transaction

 next if $self->TicketObj->Id == $ticket->Id;
 $same_desc=$ticket->Subject;
 $same_desc_re="RE: ". $same_desc;
 $same_desc_fw="FW: ". $same_desc;
   if (($notnagios_desc eq $same_desc) || ($notnagios_desc eq

$same_desc_re) || ($notnagios_desc eq $same_desc_fw)) {
# Found the same subject
$id = $ticket->Id;
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;
}On Mon, Aug 17, 2009 at 3:49 PM, rmp dmd rmp.dmd1229@gmail.com wrote:

Thanks for the help. I was able to make the scrip below work.

The scrip was able to merge new ticket with Subject: "Test Ticket Subject"
to an existing ticket with the same subject.

Just few more questions:

  • what to add on the scrip to ignore preceeding characters such as RE: and
    FWD:? A new ticket with subject: “RE: Test Ticket Subject” to an existing
    ticket with the same subject
  • the scrip does not merge new ticket with subject: “** PROBLEM alert -
    Saturn backup server/DNS is CRITICAL **” to an existing ticket with the same
    subject. Is there a syntax that I need to add for this?

All help will be greatly appreciated.

Thanks!

my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$problem_desc = $subject;
$RT::Logger->debug(“This is the subject to match: $problem_desc”);

look for subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
# Ignore this ticket that opened this transaction
next if $self->TicketObj->Id == $ticket->Id;
$same_desc=$ticket->Subject;
#if ($same_desc eq $problem_desc){
if ($problem_desc eq $same_desc){
# Found the same subject
$RT::Logger->debug(“SAME $same_desc and $problem_desc”);
$id = $ticket->Id;
$RT::Logger->debug(“Merging ticket " . $self->TicketObj->Id . " into
$id because of OA number match.”);
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;

On Fri, Aug 14, 2009 at 9:41 AM, Rémi mirebob@gmail.com wrote:

hi
try using $TicketObj->SetSubject() function,

$TicketObj->Subject is just an accessor method

Rémi

2009/8/13 rmp dmd rmp.dmd1229@gmail.com

Hi,

I’m using the scrip below to merge newly created ticket with existing
ticket with the same subject. However, im getting

Scrip 36 Commit failed: Can’t modify non-lvalue subroutine call at (eval
1311) line 21.

code for line 21 is :
$ticket->Subject = $same_desc;

Im not exactly sure what the error means. Please help in making the scrip
work.

Thanks!

====

my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
$problem_desc = $subject;
$RT::Logger->debug(“This is the subject to match: $problem_desc”);

look for subject on existing tickets

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘IT’);
$search->LimitStatus(VALUE => ‘new’, OPERATOR => ‘=’, ENTRYAGGREGATOR =>
‘or’);
$search->LimitStatus(VALUE => ‘open’, OPERATOR => ‘=’);
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
# Ignore this ticket that opened this transaction
next if $self->TicketObj->Id == $ticket->Id;
$ticket->Subject = $same_desc;
if ($same_desc eq $problem_desc){
# Found the same subject
$RT::Logger->debug(“SAME $same_desc and $problem_desc”);
$id = $ticket->Id;
$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . “
into $id because of OA number match.”);
$self->TicketObj->MergeInto($id);
}
}
$id || return 1;
1;


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