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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Sep 27 23:16:27 EDT 2009


The branch, master has been updated
       via  420f51f3ef8b03a76b21cf412deb6791076a1ce0 (commit)
      from  fd1952e8feeb1f5919f6b1c1785e77fcb56ec23f (commit)

Summary of changes:
 lib/RT/Action/Nagios.pm |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

- Log -----------------------------------------------------------------
commit 420f51f3ef8b03a76b21cf412deb6791076a1ce0
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 28 10:49:42 2009 +0800

    code refactor

diff --git a/lib/RT/Action/Nagios.pm b/lib/RT/Action/Nagios.pm
index 4fc4ff6..11f7da5 100644
--- a/lib/RT/Action/Nagios.pm
+++ b/lib/RT/Action/Nagios.pm
@@ -1,10 +1,9 @@
 package RT::Action::Nagios;
-require RT::Action::Generic;
 
 use strict;
 use warnings;
 
-use base qw(RT::Action::Generic);
+use base qw(RT::Action);
 
 sub Describe {
     my $self = shift;
@@ -31,9 +30,14 @@ sub Commit {
             \s+([^/]+)/(.*)\s+is\s+(\w+)}ix
       )
     {
-        $RT::Logger->error( $1, $2, $3, $4, $5 );
+        $RT::Logger->info(
+            "Extracted subject: $key, $category, $host, $type and $info" );
         my $tickets = RT::Tickets->new( $self->CurrentUser );
         $tickets->LimitQueue( VALUE => $new_ticket->Queue );
+        $tickets->LimitSubject(
+            VALUE    => "$category Alert: $host/$type",
+            OPERATOR => 'LIKE',
+        );
         $tickets->LimitStatus(
             VALUE           => 'new',
             OPERATOR        => '=',
@@ -48,15 +52,13 @@ sub Commit {
 
         while ( my $ticket = $tickets->Next ) {
             next if $ticket->id == $new_ticket_id;
-            if ( $ticket->Subject =~ m{$category\s+Alert:\s+$host/$type}i ) {
-                my ( $ret, $msg ) = $ticket->MergeInto($new_ticket_id);
-                if ( !$ret ) {
-                    $RT::Logger->error( 'failed to merge ticket '
-                          . $ticket->id
-                          . " into $new_ticket_id:$msg" );
-                }
-
+            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 ( $key eq 'RECOVERY' ) {

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



More information about the Bps-public-commit mailing list