[rt-users] Scrip question
José de Paula Eufrásio Júnior
jose.junior at mds.gov.br
Tue Apr 10 11:02:28 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Erm, about scrips:
What the "transaction" field means anyway?
I'm basing my scrips on
http://wiki.bestpractical.com/index.cgi?AutoCloseOnNagiosRecoveryMessages,
but I want to auto-deal with Nagios and Cron-Apt automatic emails. Can
I create two different scrips and apply to the same 'thing' (onCreate)?
I tried that for the cron-apt emails, with no luck:
# Based on
http://marc.free.net.ph/message/20040319.180325.27528377.en.html
# Modificado por yves.junqueira at mds.gov.br para uso no cron-apt
# "CRON-APT completed on romario [/etc/cron-apt/config]"
my $update_host = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader('Subject');
if ($subject =~ m#CRON-APT completed on (\w+) \[/etc/cron-apt/config\]#) {
# This looks like a nagios recovery message
$update_host = $1;
$RT::Logger->debug("Encontrada atualização relacionada:
$update_host");
} else {
return 1;
}
# Ok, now let's merge this ticket with it's PROBLEM msg.
my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => 'rede');
$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 =~ m#CRON-APT completed on (\w+)
[/etc/cron-apt/config\]# ) {
if ($1 eq $update_host){
# 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( "stalled" );
1;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGG6cEv0TDyic/J4kRAh9kAJ47rTHOgM4rkaVam29vscJCmChrFwCfeVru
Qk/n9Ld83hiTIS/fEnrsKtY=
=2kAI
-----END PGP SIGNATURE-----
More information about the rt-users
mailing list