Help in creating Scrips (Nagios autoclose)

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

http://exchange.nagios.org/directory/Addons/Helpdesk-and-Ticketing/RT/AutoCloseOnNagiosRecoveryMessages-%252D-RT-Integration/details

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like :
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397 of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval 2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is (\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe

ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is (\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’, RecordTransaction =>
0);

}
1;

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

http://goog_1257158193783

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like :
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397 of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval 2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is (\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe

ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is (\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’, RecordTransaction =>
0);

}
1;

You’ve got a dash (-) character in your regex which doesn’t appear in the
subject line of the mail.

Subject =~ /\*\* PROBLEM (\w+(?:\s*\d+)?) - (.*) is (\w+) \*\*/
                                          ^

Which might have something to do with it?

Richard Foley
Ciao - shorter than aufwiedersehen

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

Hi Rodolphe

Maybe you’re interested in the RT extension attached, which is based on the wiki you read.
I’m thinking of publishing it to CPAN soon.

best wishes
sunnavyOn 09-11-02 12:00, Rodolphe ALT wrote:

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

Nagios Exchange - Nagios Exchange

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like :
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397 of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval 2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is (\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is (\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’, RecordTransaction =>
0);

}
1;



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

RT-Extension-Nagios-0.01.tar.gz (20.8 KB)

Hi Sunnavy,

Thanks a lot for this tip, because on the link (
http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages) it was
not wrote.

I have read the file README.

After make and install, I have add this line in file
/opt/rt3/etc/RT_SiteConfig.pm
Set(@Plugins,qw(RT::Extension::Nagios));

But when I have initialized database (make initdb), i have a message error :
[Mon Nov 2 13:30:56 2009] [error]: Action ‘Nagios’ not found
(/opt/rt3/sbin/…/lib/RT/Handle.pm:987)

And the scrip after that doesn’t close always any messages. In the log :
[Mon Nov 2 13:45:32 2009] [debug]: Committing scrip #13 on txn #451 of
ticket #55 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 13:45:32 2009] [debug]: Found a recovery msg: ((eval 3253):18)

And that’s all.

Regards,

Rodolphe

The scrip

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 “General” 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 **/) {
if ($subject =~ /** RECOVERY (.
) OK **/) {
# This looks like a nagios recovery message
$problem_desc = $2;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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;2009/11/2 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

Maybe you’re interested in the RT extension attached, which is based on the
wiki you read.
I’m thinking of publishing it to CPAN soon.

best wishes
sunnavy

On 09-11-02 12:00, Rodolphe ALT wrote:

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

http://exchange.nagios.org/directory/Addons/Helpdesk-and-Ticketing/RT/AutoCloseOnNagiosRecoveryMessages-%252D-RT-Integration/details

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not
analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like :
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397 of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval
2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is
(\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is
(\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id
avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’, RecordTransaction
=>
0);

}
1;



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi Richard,

I have try without dash. (thanks for that)

But it is always the same result (not detected)

Regex is :

Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) (.*) is (\w+) **/

Subject Email is:
Subject = ** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL

Regards,

Rodolphe

You’ve got a dash (-) character in your regex which doesn’t appear in the

My problem is solved.

I have used the soft : “Rad Software Regular Expression Designer” to find
the good sentence for Regex.

The final Scrip for Nagios AutoClose is :

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 “General” 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 $report_type = undef;
my $report_value = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
#if ($subject =~ /** RECOVERY (.) OK **/) {
if ($subject =~ /** RECOVERY (\w+(?:\s
\d+)?) (.*) is (\w+) **/) {
# This looks like a nagios recovery message
#$report_type = $1;
#$problem_desc = $3;
$report_type = $1;
$problem_desc = $2;
$report_value = $3;

$RT::Logger->debug("Found a recovery msg: $report_type -

$problem_desc");
} else {
$RT::Logger->debug(“Not a recovery msg: $report_type - $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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+(?:\s*\d+)?) (.*) is (\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;

if ($subject =~ /** RECOVERY (.*) OK **/) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
}
1;From: Rodolphe ALT rodolphe.alt@gmail.com
Date: 2009/11/2
Subject: Re: [rt-users] help in creating Scrips (Nagios autoclose)
To: RT-Users@lists.bestpractical.com
Cc: Richard.Foley@rfi.net

Hi Richard,

I have try without dash. (thanks for that)

But it is always the same result (not detected)

Regex is :

Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) (.*) is (\w+) **/

Subject Email is:
Subject = ** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL

Regards,

Rodolphe

You’ve got a dash (-) character in your regex which doesn’t appear in the

subject line of the mail.

Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is (\w+) **/
^
Which might have something to do with it?


Richard Foley
Ciao - shorter than aufwiedersehen

http://www.rfi.net/

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

Nagios Exchange - Nagios Exchange

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not
analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like :
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397 of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval
2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is
(\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is
(\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id
avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’, RecordTransaction
=>
0);

}
1;


Hi Rodolphe

It’s a bug, I’m sorry for that.
please test the new version attached.

best wishes
sunnavyOn 09-11-02 15:16, Rodolphe ALT wrote:

Hi Sunnavy,

Thanks a lot for this tip, because on the link (
http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages) it was
not wrote.

I have read the file README.

After make and install, I have add this line in file
/opt/rt3/etc/RT_SiteConfig.pm
Set(@Plugins,qw(RT::Extension::Nagios));

But when I have initialized database (make initdb), i have a message error :
[Mon Nov 2 13:30:56 2009] [error]: Action ‘Nagios’ not found
(/opt/rt3/sbin/…/lib/RT/Handle.pm:987)

And the scrip after that doesn’t close always any messages. In the log :
[Mon Nov 2 13:45:32 2009] [debug]: Committing scrip #13 on txn #451 of
ticket #55 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 13:45:32 2009] [debug]: Found a recovery msg: ((eval 3253):18)

And that’s all.

Regards,

Rodolphe

The scrip


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 “General” 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 **/) {
if ($subject =~ /** RECOVERY (.
) OK **/) {
# This looks like a nagios recovery message
$problem_desc = $2;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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;


2009/11/2 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

Maybe you’re interested in the RT extension attached, which is based on the
wiki you read.
I’m thinking of publishing it to CPAN soon.

best wishes
sunnavy

On 09-11-02 12:00, Rodolphe ALT wrote:

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

Nagios Exchange - Nagios Exchange

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not
analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like :
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397 of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval
2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is
(\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is
(\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id
avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’, RecordTransaction
=>
0);

}
1;



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

RT-Extension-Nagios-0.02.tar.gz (20.9 KB)

Hi sunnavy,

Setup seems good. No error message.

Thanks.

I am reading your documentation on url :
http://cpan.uwinnipeg.ca/htdocs/RT-Extension-Nagios/

Regards,

Rodolphe2009/11/3 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

It’s a bug, I’m sorry for that.
please test the new version attached.

best wishes
sunnavy

On 09-11-02 15:16, Rodolphe ALT wrote:

Hi Sunnavy,

Thanks a lot for this tip, because on the link (
http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages) it
was
not wrote.

I have read the file README.

After make and install, I have add this line in file
/opt/rt3/etc/RT_SiteConfig.pm
Set(@Plugins,qw(RT::Extension::Nagios));

But when I have initialized database (make initdb), i have a message
error :
[Mon Nov 2 13:30:56 2009] [error]: Action ‘Nagios’ not found
(/opt/rt3/sbin/…/lib/RT/Handle.pm:987)

And the scrip after that doesn’t close always any messages. In the log :
[Mon Nov 2 13:45:32 2009] [debug]: Committing scrip #13 on txn #451 of
ticket #55 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 13:45:32 2009] [debug]: Found a recovery msg: ((eval
3253):18)

And that’s all.

Regards,

Rodolphe

The scrip


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 “General” 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 **/) {
if ($subject =~ /** RECOVERY (.
) OK **/) {
# This looks like a nagios recovery message
$problem_desc = $2;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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;


2009/11/2 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

Maybe you’re interested in the RT extension attached, which is based on
the
wiki you read.
I’m thinking of publishing it to CPAN soon.

best wishes
sunnavy

On 09-11-02 12:00, Rodolphe ALT wrote:

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets
from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

Nagios Exchange - Nagios Exchange

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not
analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like
:
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397
of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14 ((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval
2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*) is
(\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*) is
(\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé
$ticket->Id
avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ )
{
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec
la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’,
RecordTransaction
=>
0);

}
1;



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

sunnavy,

Can you give us some examples in RT with your plugin ?

Because I don’t understand your documentation.

Thanks,

Rodolphe2009/11/3 Rodolphe A. rodolphedj@gmail.com

Hi sunnavy,

Setup seems good. No error message.

Thanks.

I am reading your documentation on url :
http://cpan.uwinnipeg.ca/htdocs/RT-Extension-Nagios/

Regards,

Rodolphe

2009/11/3 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

It’s a bug, I’m sorry for that.
please test the new version attached.

best wishes
sunnavy

On 09-11-02 15:16, Rodolphe ALT wrote:

Hi Sunnavy,

Thanks a lot for this tip, because on the link (
http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages)
it was
not wrote.

I have read the file README.

After make and install, I have add this line in file
/opt/rt3/etc/RT_SiteConfig.pm
Set(@Plugins,qw(RT::Extension::Nagios));

But when I have initialized database (make initdb), i have a message
error :
[Mon Nov 2 13:30:56 2009] [error]: Action ‘Nagios’ not found
(/opt/rt3/sbin/…/lib/RT/Handle.pm:987)

And the scrip after that doesn’t close always any messages. In the log :
[Mon Nov 2 13:45:32 2009] [debug]: Committing scrip #13 on txn #451 of
ticket #55 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 13:45:32 2009] [debug]: Found a recovery msg: ((eval
3253):18)

And that’s all.

Regards,

Rodolphe

The scrip


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 “General” 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 **/) {
if ($subject =~ /** RECOVERY (.
) OK **/) {
# This looks like a nagios recovery message
$problem_desc = $2;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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;


2009/11/2 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

Maybe you’re interested in the RT extension attached, which is based
on the
wiki you read.
I’m thinking of publishing it to CPAN soon.

best wishes
sunnavy

On 09-11-02 12:00, Rodolphe ALT wrote:

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets
from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

http://exchange.nagios.org/directory/Addons/Helpdesk-and-Ticketing/RT/AutoCloseOnNagiosRecoveryMessages-%252D-RT-Integration/details

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not
analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like
:
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397
of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14
((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval
2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*)
is
(\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject =
$Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*)
is
(\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé
$ticket->Id
avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ )
{
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec
la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’,
RecordTransaction
=>
0);

}
1;



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi Rodolphe

which part you don’t understand?
IMHO, the extension’s workflow is not complex at all.

best wishes
sunnavyOn 09-11-03 17:41, Rodolphe A. wrote:

sunnavy,

Can you give us some examples in RT with your plugin ?

Because I don’t understand your documentation.

Thanks,

Rodolphe

2009/11/3 Rodolphe A. rodolphedj@gmail.com

Hi sunnavy,

Setup seems good. No error message.

Thanks.

I am reading your documentation on url :
http://cpan.uwinnipeg.ca/htdocs/RT-Extension-Nagios/

Regards,

Rodolphe

2009/11/3 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

It’s a bug, I’m sorry for that.
please test the new version attached.

best wishes
sunnavy

On 09-11-02 15:16, Rodolphe ALT wrote:

Hi Sunnavy,

Thanks a lot for this tip, because on the link (
AutoCloseOnNagiosRecoveryMessages - Request Tracker Wiki)
it was
not wrote.

I have read the file README.

After make and install, I have add this line in file
/opt/rt3/etc/RT_SiteConfig.pm
Set(@Plugins,qw(RT::Extension::Nagios));

But when I have initialized database (make initdb), i have a message
error :
[Mon Nov 2 13:30:56 2009] [error]: Action ‘Nagios’ not found
(/opt/rt3/sbin/…/lib/RT/Handle.pm:987)

And the scrip after that doesn’t close always any messages. In the log :
[Mon Nov 2 13:45:32 2009] [debug]: Committing scrip #13 on txn #451 of
ticket #55 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 13:45:32 2009] [debug]: Found a recovery msg: ((eval
3253):18)

And that’s all.

Regards,

Rodolphe

The scrip


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 “General” 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 **/) {
if ($subject =~ /** RECOVERY (.
) OK **/) {
# This looks like a nagios recovery message
$problem_desc = $2;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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;


2009/11/2 sunnavy sunnavy@bestpractical.com

Hi Rodolphe

Maybe you’re interested in the RT extension attached, which is based
on the
wiki you read.
I’m thinking of publishing it to CPAN soon.

best wishes
sunnavy

On 09-11-02 12:00, Rodolphe ALT wrote:

Hi all,

I am trying create a scrip in RT3 for close automaticly the tickets
from
Nagios alert.

I am working from the scrips “AutoCloseOnNagiosRecoveryMessages - RT
Integration” from website

http://exchange.nagios.org/directory/Addons/Helpdesk-and-Ticketing/RT/AutoCloseOnNagiosRecoveryMessages-%252D-RT-Integration/details

http://wiki.bestpractical.com/view/AutoCloseOnNagiosRecoveryMessages

<goog_1257158193783>

https://wiki.koumbit.net/RequestTracker/NagiosBridge

But with RT3 3.8.6 and Nagios 3.2, The subject of the email is not
analyzed
correctly.

I mean when I have enabled debug log and this is a log messages like
:
[Mon Nov 2 10:30:33 2009] [debug]: Committing scrip #14 on txn #397
of
ticket #46 (/opt/rt3/bin/…/lib/RT/Scrips_Overlay.pm:190)
[Mon Nov 2 10:30:33 2009] [debug]: Message Lancement Scrip 14
((eval
2528):12)
[Mon Nov 2 10:30:33 2009] [debug]: Found a recovery msg: ((eval
2528):21)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 45 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 46 ((eval 2528):36)
[Mon Nov 2 10:30:33 2009] [debug]: Boucle 14 : 27 ((eval 2528):36)

And that’ all. not Merging ticket !

in scrip, I think this is the line who detect not the ticket :
if ( $ticket->Subject =~ /** PROBLEM (\w+(?:\s*\d+)?) - (.*)
is
(\w+)
**/ ) {

I have tested also without success :
if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ ) {

And the email subject is like :
** PROBLEM Service Alert: srv08.athome.local/Portail is CRITICAL **
** RECOVERY Service Alert: srv08.athome.local/Portail is OK **

Can you help me to resolve this code ?

Thanks,

Regards,

Rodolphe


ALL CODE of actual scrip is here :

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 “General” 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 $report_type = undef;

$RT::Logger->debug(“Message Lancement Scrip 14”);

my $Transaction = $self->TransactionObj;
my $subject =
$Transaction->Attachments->First->GetHeader(‘Subject’);
if ($subject =~ /** RECOVERY (.*) OK **/) {
# This looks like a nagios recovery message
$report_type = $1;
$problem_desc = $3;

$RT::Logger->debug("Found a recovery msg: $problem_desc");

} else {
$RT::Logger->debug(“Not a recovery msg: $problem_desc”);
return 1;
}

Ok, now let’s merge this ticket with it’s PROBLEM msg.

my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => ‘General’);
$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) {
$RT::Logger->debug("Boucle 14 : ".($ticket->Id));
# 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+(?:\s*\d+)?) - (.*)
is
(\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…
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé
$ticket->Id
avec
la régle 1!”);

    }
}

if ( $ticket->Subject =~ /** PROBLEM (\w+) - (.*) (\w+) **/ )
{
$RT::Logger->debug(“Scrip 14 : 1 ticket trouvé $ticket->Id avec
la
régle 2!”);
}
}

$id || return 1;

if ($report_type eq “RECOVERY”) {

Auto-close/resolve this whole thing

$self->TicketObj->SetStatus( “resolved” );
#$Ticket->_Set(Field => ‘Status’, Value => ‘resolved’,
RecordTransaction
=>
0);

}
1;



The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com