[Bps-public-commit] RT-Extension-Nagios branch, master, updated. c87f861beb8a6c1172ac5eee78bce99d6dccd8a7

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Sep 28 01:56:31 EDT 2009


The branch, master has been updated
       via  c87f861beb8a6c1172ac5eee78bce99d6dccd8a7 (commit)
      from  217654cbb8b8e2842bb5cbc15ebd5e2a55ebae20 (commit)

Summary of changes:
 lib/RT/Action/Nagios.pm    |   43 +++++++++++++++++++++++++++++++++----------
 lib/RT/Extension/Nagios.pm |    8 ++++----
 2 files changed, 37 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit c87f861beb8a6c1172ac5eee78bce99d6dccd8a7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 28 13:56:23 2009 +0800

    add NagiosMergeTickets config

diff --git a/lib/RT/Action/Nagios.pm b/lib/RT/Action/Nagios.pm
index cf34ccd..0df67ea 100644
--- a/lib/RT/Action/Nagios.pm
+++ b/lib/RT/Action/Nagios.pm
@@ -50,26 +50,49 @@ subject with values $type, $category, $host, $problem_type and $problem_severity
             ENTRYAGGREGATOR => 'or'
         );
         $tickets->LimitStatus( VALUE => 'stalled', OPERATOR => '=' );
-
-        while ( my $ticket = $tickets->Next ) {
-            next if $ticket->id == $new_ticket_id;
-            my ( $ret, $msg ) = $ticket->MergeInto($new_ticket_id);
-            if ( !$ret ) {
-                $RT::Logger->error( 'failed to merge ticket '
-                      . $ticket->id
-                      . " into $new_ticket_id:$msg" );
+        if ( RT->Config->Get('NagiosMergeTickets') ) {
+            while ( my $ticket = $tickets->Next ) {
+                next if $ticket->id == $new_ticket_id;
+                my ( $ret, $msg ) = $ticket->MergeInto($new_ticket_id);
+                if ( !$ret ) {
+                    $RT::Logger->error( 'failed to merge ticket '
+                          . $ticket->id
+                          . " into $new_ticket_id: $msg" );
+                }
             }
 
+            if ( $type eq 'RECOVERY' ) {
+                my ( $ret, $msg ) = $new_ticket->Resolve();
+                if ( !$ret ) {
+                    $RT::Logger->error( 'failed to resolve ticket '
+                          . $new_ticket->id
+                          . ":$msg" );
+                }
+            }
         }
+        elsif ( $type eq 'RECOVERY' ) {
+            while ( my $ticket = $tickets->Next ) {
+                my ( $ret, $msg ) = $ticket->Comment(
+                    Content => 'going to be resolved by ' . $new_ticket_id,
+                    Status => 'resolved',
+                    );
+                if ( !$ret ) {
+                    $RT::Logger->error(
+                        'failed to comment ticket ' . $ticket->id . ": $msg" );
+                }
 
-        if ( $type eq 'RECOVERY' ) {
+                my ( $ret, $msg ) = $ticket->Resolve();
+                if ( !$ret ) {
+                    $RT::Logger->error(
+                        'failed to resolve ticket ' . $ticket->id . ": $msg" );
+                }
+            }
             my ( $ret, $msg ) = $new_ticket->Resolve();
             if ( !$ret ) {
                 $RT::Logger->error(
                     'failed to resolve ticket ' . $new_ticket->id . ":$msg" );
             }
         }
-
     }
 }
 
diff --git a/lib/RT/Extension/Nagios.pm b/lib/RT/Extension/Nagios.pm
index 6066ef0..40e5bdf 100644
--- a/lib/RT/Extension/Nagios.pm
+++ b/lib/RT/Extension/Nagios.pm
@@ -40,11 +40,11 @@ PROBLEM, Service, localhost, Root Partition and WARNING
 ( Currently, we don't make use of problem_severity actually )
 
 After the new ticket is created, the following is done:
-find all the other active tickets in the same queue,
-with the same values of $2, $3 and $4 in subject and merge all of them into
-the new ticket.
+find all the other active tickets in the same queue with the same values of
+$category, $host and $problem_type, if C<RT->Config->Get('NagiosMergeTickets')>
+is true, merge all of them into the new ticket.
 
-If $1 is 'RECOVERY', resolve the new ticket
+If $type is 'RECOVERY', resolve the new ticket
 
 =head1 AUTHOR
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list