<div>Hi All,</div>
<div> </div>
<div>I adjusted my scrip to below in order for to have auto merging of tickets: </div>
<div> </div>
<div>The scrip</div>
<div>- merge ticket with the same subject</div>
<div>
<div>- merge the same nagios PROBLEM alert </div>
<div>- merge nagios RECOVERY alert to corresponding PROBLEM alert </div>
<div>- merge ticket with new ticket RE: and FW: on the subject with similar subject. </div>
<div> </div>
<div>However some email clients append Re instead of RE and Fw: instead of FW:. Im figuring it out, but nothing came up yet. </div>
<div><br>Any help to adjust the script to accept that condition?</div>
<div> </div>
<div> </div>
<div>Thanks!</div>
<div> </div>
<div> </div></div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div># If the subject of the ticket matches a pattern suggesting<br># that this is a Nagios RECOVERY message AND there is<br># an existing ticket (open or new) in the "IT" queue with a matching<br># "problem description", (that is not this ticket)<br>
# merge this ticket into that ticket<br>#<br># Based on <a href="http://marc.free.net.ph/message/20040319.180325.27528377.en.html">http://marc.free.net.ph/message/20040319.180325.27528377.en.html</a></div>
<div>my $problem_desc = undef;</div>
<div>my $Transaction = $self->TransactionObj;<br>my $subject = $Transaction->Attachments->First->GetHeader('Subject');</div>
<div>if (($subject =~ /\*\* RECOVERY (\w+) - (.*) OK \*\*/) || ($subject =~ /\*\* PROBLEM (\w+) - (.*) CRITICAL \*\*/)) {<br> # This looks like a nagios recovery message<br> $problem_desc = $2;</div>
<div> # Ok, now let's merge this ticket with it's PROBLEM msg.<br> my $search = RT::Tickets->new($RT::SystemUser);<br> $search->LimitQueue(VALUE => 'IT');<br> $search->LimitStatus(VALUE => 'new', OPERATOR => '=', ENTRYAGGREGATOR => 'or');<br>
$search->LimitStatus(VALUE => 'open', OPERATOR => '=');</div>
<div> if ($search->Count == 0) { return 1; }<br> my $id = undef;<br> while (my $ticket = $search->Next) {<br> # Ignore the ticket that opened this transation (the recovery one...)<br> next if $self->TicketObj->Id == $ticket->Id;<br>
# Look for nagios PROBLEM warning messages...<br> if ( $ticket->Subject =~ /\*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ ) {<br> if ($2 eq $problem_desc){<br> # Aha! Found the Problem TICKET corresponding to this RECOVERY<br>
# ticket<br> $id = $ticket->Id;<br> # Nagios may send more then one PROBLEM message, right?<br> #$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into $id because of OA number match.");<br>
$self->TicketObj->MergeInto($id);<br> <br> # Keep looking for more PROBLEM tickets...<br> }<br> } <br> } <br> $id || return 1;<br>
<br> # Auto-close/resolve this whole thing<br> #$self->TicketObj->SetStatus( "resolved" );<br> 1;</div>
<div>} else {</div>
<div> my $notnagios_desc = undef;</div>
<div> my $Transaction = $self->TransactionObj;<br> my $subject = $Transaction->Attachments->First->GetHeader('Subject');</div>
<div> $notnagios_desc = $subject;<br> <br> # look for same subject on existing tickets <br> my $search = RT::Tickets->new($RT::SystemUser);<br> $search->LimitQueue(VALUE => 'IT');<br> $search->LimitStatus(VALUE => 'new', OPERATOR => '=', ENTRYAGGREGATOR => 'or');<br>
$search->LimitStatus(VALUE => 'open', OPERATOR => '=');</div>
<div> if ($search->Count == 0) { return 1; }<br> my $id = undef;<br> my $same_desc = undef; <br> my $same_desc_re = undef; <br> my $same_desc_fw = undef; </div>
<div> while (my $ticket = $search->Next) {<br> # Ignore this ticket that opened this transaction <br> next if $self->TicketObj->Id == $ticket->Id;<br> $same_desc=$ticket->Subject;<br> $same_desc_re="RE: ". $same_desc; <br>
$same_desc_fw="FW: ". $same_desc; </div>
<div> if (($notnagios_desc eq $same_desc) || ($notnagios_desc eq $same_desc_re) || ($notnagios_desc eq $same_desc_fw)) {<br> # Found the same subject <br> $id = $ticket->Id;<br> $self->TicketObj->MergeInto($id);<br>
}<br> }</div>
<div> $id || return 1;<br> 1;</div>
<div>}</div>
<div> </div>
<div>===<br><br></div>
<div class="gmail_quote">On Mon, Aug 17, 2009 at 3:49 PM, rmp dmd <span dir="ltr"><<a href="mailto:rmp.dmd1229@gmail.com">rmp.dmd1229@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>Thanks for the help. I was able to make the scrip below work.</div>
<div> </div>
<div>The scrip was able to merge new ticket with Subject: "Test Ticket Subject" to an existing ticket with the same subject. </div>
<div><br>Just few more questions: </div>
<div>- 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 </div>
<div>- 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? </div>
<div> </div>
<div>All help will be greatly appreciated.</div>
<div> </div>
<div><br>Thanks!</div>
<div>===== </div>
<div>my $problem_desc = undef;</div>
<div>my $Transaction = $self->TransactionObj;<br>my $subject = $Transaction->Attachments->First->GetHeader('Subject');</div>
<div>$problem_desc = $subject;<br>$RT::Logger->debug("This is the subject to match: $problem_desc");</div>
<div># look for subject on existing tickets <br>my $search = RT::Tickets->new($RT::SystemUser);<br>$search->LimitQueue(VALUE => 'IT');<br>$search->LimitStatus(VALUE => 'new', OPERATOR => '=', ENTRYAGGREGATOR => 'or');<br>
$search->LimitStatus(VALUE => 'open', OPERATOR => '=');</div>
<div>if ($search->Count == 0) { return 1; }<br>my $id = undef;<br>my $same_desc = undef;<br>while (my $ticket = $search->Next) {<br> # Ignore this ticket that opened this transaction <br> next if $self->TicketObj->Id == $ticket->Id;<br>
$same_desc=$ticket->Subject;<br> #if ($same_desc eq $problem_desc){<br> if ($problem_desc eq $same_desc){<br> # Found the same subject <br> $RT::Logger->debug("SAME $same_desc and $problem_desc"); <br>
$id = $ticket->Id;<br> $RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into $id because of OA number match.");<br> $self->TicketObj->MergeInto($id);<br>
} <br>}</div>
<div>$id || return 1;<br>1;</div>
<div><br> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div><br> </div>
<div class="gmail_quote">On Fri, Aug 14, 2009 at 9:41 AM, Rémi <span dir="ltr"><<a href="mailto:mirebob@gmail.com" target="_blank">mirebob@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">hi
<div><br></div>
<div>try using <span style="FONT-FAMILY: monospace; WHITE-SPACE: pre; FONT-SIZE: 13px">$TicketObj->SetSubject() function,</span></div>
<div><span style="FONT-SIZE: 13px"></span><font face="monospace"><span style="WHITE-SPACE: pre"><span style="FONT-FAMILY: sans-serif; WHITE-SPACE: normal; FONT-SIZE: 13px"><pre>$TicketObj->Subject is just an accessor method</pre>
<pre>Rémi</pre></span></span></font>
<div><br>
<div class="gmail_quote">2009/8/13 rmp dmd <span dir="ltr"><<a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a>></span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div></div>
<div>
<div>Hi,</div>
<div> </div>
<div>I'm using the scrip below to merge newly created ticket with existing ticket with the same subject. However, im getting</div>
<div> </div>
<div>Scrip 36 Commit failed: Can't modify non-lvalue subroutine call at (eval 1311) line 21.</div>
<div> </div>
<div>code for line 21 is : </div>
<div>$ticket->Subject = $same_desc;</div>
<div> </div>
<div>Im not exactly sure what the error means. Please help in making the scrip work. </div>
<div> </div>
<div> </div>
<div>Thanks!</div>
<div> </div>
<div> </div>
<div> </div>
<div>====</div>
<div> </div>
<div>my $problem_desc = undef;</div>
<div>my $Transaction = $self->TransactionObj;<br>my $subject = $Transaction->Attachments->First->GetHeader('Subject');</div>
<div>$problem_desc = $subject;<br>$RT::Logger->debug("This is the subject to match: $problem_desc");</div>
<div># look for subject on existing tickets <br>my $search = RT::Tickets->new($RT::SystemUser);<br>$search->LimitQueue(VALUE => 'IT');<br>$search->LimitStatus(VALUE => 'new', OPERATOR => '=', ENTRYAGGREGATOR => 'or');<br>
$search->LimitStatus(VALUE => 'open', OPERATOR => '=');</div>
<div>if ($search->Count == 0) { return 1; }<br>my $id = undef;<br>my $same_desc = undef;<br>while (my $ticket = $search->Next) {<br> # Ignore this ticket that opened this transaction <br> next if $self->TicketObj->Id == $ticket->Id;<br>
$ticket->Subject = $same_desc;<br> if ($same_desc eq $problem_desc){<br> # Found the same subject <br> $RT::Logger->debug("SAME $same_desc and $problem_desc"); <br> $id = $ticket->Id;<br>
$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into $id because of OA number match.");<br> $self->TicketObj->MergeInto($id);<br> } <br>}</div>
<div>$id || return 1;<br>1;<br> <br></div><br></div></div>_______________________________________________<br><a href="http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users" target="_blank">http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users</a><br>
<br>Community help: <a href="http://wiki.bestpractical.com/" target="_blank">http://wiki.bestpractical.com</a><br>Commercial support: <a href="mailto:sales@bestpractical.com" target="_blank">sales@bestpractical.com</a><br>
<br><br>Discover RT's hidden secrets with RT Essentials from O'Reilly Media.<br>Buy a copy at <a href="http://rtbook.bestpractical.com/" target="_blank">http://rtbook.bestpractical.com</a><br></blockquote></div><br>
</div></div></blockquote></div><br></blockquote></div><br>