Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Users

help in creating Scrips (Nagios autoclose)

 

 

Request Tracker users RSS feed   Index | Next | Previous | View Threaded


rodolphe.alt at gmail

Nov 2, 2009, 3:00 AM

Post #1 of 10 (141 views)
Permalink
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;









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


rodolphedj at gmail

Nov 2, 2009, 3:00 AM

Post #2 of 10 (134 views)
Permalink
help in creating Scrips (Nagios autoclose) [In reply to]

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

<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;









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


Richard.Foley at rfi

Nov 2, 2009, 3:06 AM

Post #3 of 10 (134 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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/

On Monday 02 November 2009 12:00:07 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;
>
>
>
>
>
>
>
>
>
> ----------------
>


_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales[at]bestpractical.com


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


sunnavy at bestpractical

Nov 2, 2009, 3:31 AM

Post #4 of 10 (134 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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;
>
>
>
>
>
>
>
>
>
> ----------------

> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales[at]bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
Attachments: RT-Extension-Nagios-0.01.tar.gz (20.8 KB)


rodolphe.alt at gmail

Nov 2, 2009, 6:16 AM

Post #5 of 10 (123 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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[at]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;
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ----------------
>
> > _______________________________________________
> > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> >
> > Community help: http://wiki.bestpractical.com
> > Commercial support: sales[at]bestpractical.com
> >
> >
> > Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> > Buy a copy at http://rtbook.bestpractical.com
>
>


rodolphe.alt at gmail

Nov 2, 2009, 6:45 AM

Post #6 of 10 (123 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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

2009/11/2 Richard Foley <Richard.Foley[at]rfi.net>

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/
>
> On Monday 02 November 2009 12:00:07 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;
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ----------------
> >
>
>
>


sunnavy at bestpractical

Nov 2, 2009, 6:08 PM

Post #7 of 10 (119 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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[at]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;
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ----------------
> >
> > > _______________________________________________
> > > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> > >
> > > Community help: http://wiki.bestpractical.com
> > > Commercial support: sales[at]bestpractical.com
> > >
> > >
> > > Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> > > Buy a copy at http://rtbook.bestpractical.com
> >
> >
Attachments: RT-Extension-Nagios-0.02.tar.gz (20.9 KB)


rodolphedj at gmail

Nov 3, 2009, 6:13 AM

Post #8 of 10 (111 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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[at]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[at]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;
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ----------------
> > >
> > > > _______________________________________________
> > > > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> > > >
> > > > Community help: http://wiki.bestpractical.com
> > > > Commercial support: sales[at]bestpractical.com
> > > >
> > > >
> > > > Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> > > > Buy a copy at http://rtbook.bestpractical.com
> > >
> > >
>


rodolphedj at gmail

Nov 3, 2009, 8:41 AM

Post #9 of 10 (108 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

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[at]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[at]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[at]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;
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > ----------------
>> > >
>> > > > _______________________________________________
>> > > > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>> > > >
>> > > > Community help: http://wiki.bestpractical.com
>> > > > Commercial support: sales[at]bestpractical.com
>> > > >
>> > > >
>> > > > Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>> > > > Buy a copy at http://rtbook.bestpractical.com
>> > >
>> > >
>>
>
>


sunnavy at bestpractical

Nov 3, 2009, 9:45 PM

Post #10 of 10 (103 views)
Permalink
Re: help in creating Scrips (Nagios autoclose) [In reply to]

Hi Rodolphe

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

best wishes
sunnavy

On 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[at]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[at]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[at]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;
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > ----------------
> >> > >
> >> > > > _______________________________________________
> >> > > > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> >> > > >
> >> > > > Community help: http://wiki.bestpractical.com
> >> > > > Commercial support: sales[at]bestpractical.com
> >> > > >
> >> > > >
> >> > > > Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> >> > > > Buy a copy at http://rtbook.bestpractical.com
> >> > >
> >> > >
> >>
> >
> >
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales[at]bestpractical.com


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

Request Tracker users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.