[Bps-public-commit] RT-Extension-Nagios branch, master, updated. 217654cbb8b8e2842bb5cbc15ebd5e2a55ebae20
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Mon Sep 28 01:08:35 EDT 2009
The branch, master has been updated
via 217654cbb8b8e2842bb5cbc15ebd5e2a55ebae20 (commit)
from 420f51f3ef8b03a76b21cf412deb6791076a1ce0 (commit)
Summary of changes:
lib/RT/Action/Nagios.pm | 15 ++++++++-------
lib/RT/Extension/Nagios.pm | 9 +++++----
2 files changed, 13 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit 217654cbb8b8e2842bb5cbc15ebd5e2a55ebae20
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Sep 28 13:08:23 2009 +0800
better names for extracted values
diff --git a/lib/RT/Action/Nagios.pm b/lib/RT/Action/Nagios.pm
index 11f7da5..cf34ccd 100644
--- a/lib/RT/Action/Nagios.pm
+++ b/lib/RT/Action/Nagios.pm
@@ -24,18 +24,19 @@ sub Commit {
my $subject = $attachment->GetHeader('Subject');
return unless $subject;
- if (
- my ( $key, $category, $host, $type, $info ) =
- $subject =~ m{(PROBLEM|RECOVERY) \s+ (Service|Host) \s+ Alert:
- \s+([^/]+)/(.*)\s+is\s+(\w+)}ix
+ if ( my ( $type, $category, $host, $problem_type, $problem_severity ) =
+ $subject =~
+ m{(PROBLEM|RECOVERY)\s+(Service|Host) Alert: ([^/]+)/(.*)\s+is\s+(\w+)}i
)
{
$RT::Logger->info(
- "Extracted subject: $key, $category, $host, $type and $info" );
+"Extracted type, category, host, problem_type and problem_severity from
+subject with values $type, $category, $host, $problem_type and $problem_severity"
+ );
my $tickets = RT::Tickets->new( $self->CurrentUser );
$tickets->LimitQueue( VALUE => $new_ticket->Queue );
$tickets->LimitSubject(
- VALUE => "$category Alert: $host/$type",
+ VALUE => "$category Alert: $host/$problem_type",
OPERATOR => 'LIKE',
);
$tickets->LimitStatus(
@@ -61,7 +62,7 @@ sub Commit {
}
- if ( $key eq 'RECOVERY' ) {
+ if ( $type eq 'RECOVERY' ) {
my ( $ret, $msg ) = $new_ticket->Resolve();
if ( !$ret ) {
$RT::Logger->error(
diff --git a/lib/RT/Extension/Nagios.pm b/lib/RT/Extension/Nagios.pm
index f8952e8..6066ef0 100644
--- a/lib/RT/Extension/Nagios.pm
+++ b/lib/RT/Extension/Nagios.pm
@@ -28,15 +28,16 @@ extension helps you merge and resolve them.
We identify email by its subject, so please keep it as the
default one or alike, i.e. subject should pass the regex:
-C<qr{(PROBLEM|RECOVERY) \s+ (Service|Host) \s+ Alert:
- \s+([^/]+)/(.*)\s+is\s+(\w+)}ix>
+C<qr{(PROBLEM|RECOVERY)\s+(Service|Host) Alert: ([^/]+)/(.+)\s+is\s+(\w+)}i>
e.g. "PROBLEM Service Alert: localhost/Root Partition is WARNING":
-There are 5 useful parts in subject( we call them $1..$5 ):
+There are 5 useful parts in subject( we call them type, category, host,
+problem_type and problem_severity ):
+
PROBLEM, Service, localhost, Root Partition and WARNING
-( Currently, we don't make use of $5 )
+( 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,
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list