[rt-users] merge ticket on Resolve
rmp dmd
rmp.dmd1229 at gmail.com
Fri Jul 3 11:11:21 EDT 2009
Hi,
Thanks for the numerous response and I was able to have a scrip that merges
RECOVERY alerts from nagios with PROBLEM tickets.
I need help again for minor modifications.I prefer to merge PROBLEM open
tickets to the RECOVERY alert ID.
Here's how the scrip goes:
An alert, ** PROBLEM alert - TESTONLYE DC2/check_test is CRITICAL **. RT
will assigned ID 2912
A new alert, ** PROBLEM alert - TESTONLYE DC2/check_test is CRITICAL **. RT
will assigned new ID 2913.
A recovery alert, ** RECOVERY alert - TESTONLYE DC2/check_test is OK **. RT
will assigned #2915.
The scrip will merge
ticket 2915 into 2912
ticket 2912 into 2913
I prefer to merge 2912 and 2913 into 2915. So when I lookup tickets, it'll
be easier for us.
I've been playing around with the scrips but nothing came out right.
Need help. Thanks!
The working scrip is below.
# 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 \*\*/) {
# This looks like a nagios recovery message
$problem_desc = $2;
$RT::Logger->debug("Found a recovery msg: $problem_desc");
} else {
return 1;
}
# 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;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090703/7afac242/attachment.htm>
More information about the rt-users
mailing list