Scrip questions

Hi,

I have rt version 3.0.9 and nagios 1.x . I have the following scenario:

nagios sends a mail to rt@domain with the subject “Problem: ." .
Using a custom scrip, the ticket it’s given to a user, and the state of
the ticket it’s changed to opened. This I have already done with a
custom scrip.
after some time, the problem is solved, and nagios sends another mail
with the subject "Recovery: .
” . Now, at this point I want to cancel
the creation of a new ticket , search trough the tickets list (the
tickets from the same queue), find the ticket opened earlier, add a
comment to the found ticket (eg: resolved), and close that ticket.

Did someone have any ideea how can I do this ? The main problem, it’s
how to cicle trough the tickets from the queue, and how to prevent the
creation of a new ticket.

signature.asc (256 Bytes)

How can you match the Recovery ticket with the Problem
ticket? Is there an ID in the subject or someting unique
you can use?

My system gets e-mail from a different (horrible, horrible)
ticketing system. Where store the ID from the foreign system
into a custom field. If a new ticket comes in and it has
an ID in the subject that matches an existing ticket custom
field, we merge the new ticket into the old one.

-ToddOn Fri, Mar 19, 2004 at 02:40:48PM +0200, Subredu Manuel wrote:

Hi,

I have rt version 3.0.9 and nagios 1.x . I have the following scenario:

nagios sends a mail to rt@domain with the subject “Problem: ." .
Using a custom scrip, the ticket it’s given to a user, and the state of
the ticket it’s changed to opened. This I have already done with a
custom scrip.
after some time, the problem is solved, and nagios sends another mail
with the subject "Recovery: .
” . Now, at this point I want to cancel
the creation of a new ticket , search trough the tickets list (the
tickets from the same queue), find the ticket opened earlier, add a
comment to the found ticket (eg: resolved), and close that ticket.

Did someone have any ideea how can I do this ? The main problem, it’s
how to cicle trough the tickets from the queue, and how to prevent the
creation of a new ticket.


rt-users mailing list
rt-users@lists.bestpractical.com
The rt-users Archives

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

Todd Chapman wrote:

How can you match the Recovery ticket with the Problem
ticket? Is there an ID in the subject or someting unique
you can use?

yes. the subject of the mail gives me the informations I need to match
tickets.

My system gets e-mail from a different (horrible, horrible)
ticketing system. Where store the ID from the foreign system
into a custom field. If a new ticket comes in and it has
an ID in the subject that matches an existing ticket custom
field, we merge the new ticket into the old one.

Can you give some hints about this ? If you can provide the scrip it’s
awsome :smiley:

signature.asc (256 Bytes)

Here is my scrip. You might also want to add a call to
SetStatus at the end: $self->TicketObj->SetStatus(‘resolved’)

Description: Merge Into Existing Ticket on match
Condition: OnCreate

Action: User Defined
Custom action preparation code:
1;
Custom action cleanup code:

If the subject of the ticket matches a pattern suggesting

that an OA request number is in the subject AND there is

an existing ticket is the OAReq queue with a matching

OAReqNum custom field, (that is not this ticket)

merge this ticket into that ticket

my $oa = undef;

my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader(‘Subject’);
#if ($subject =~ /(Pending|Approved|Fulfilled)\s*#\s*(\d\d\d\d\d\d?)/) {
if ($subject =~ /\D*(\d\d\d\d\d\d?)\D*/) {
$oa = $1;
#$RT::Logger->debug(“Found oa: $oa”);
}
else { return 1; }

my $TicketsObj = RT::Tickets->new($RT::SystemUser);
$TicketsObj->LimitQueue(VALUE => ‘Test’);
$TicketsObj->LimitCustomField(CUSTOMFIELD => ‘OAReqNum’, OPERATOR => ‘=’, VALUE => $oa);

if ($TicketsObj->Count == 0) { return 1; }
my $id = undef;
while (my $ticket = $TicketsObj->Next) {
next if $self->TicketObj->Id == $ticket->Id;
$id = $ticket->Id;
last;
}

$id || return 1;

$RT::Logger->debug(“Merging ticket " . $self->TicketObj->Id . " into $id because of OA number match.”);
$self->TicketObj->MergeInto($id);
1;
Stage: TransactionCreate
Template: Global template: BlankOn Fri, Mar 19, 2004 at 08:19:28PM +0200, Subredu Manuel wrote:

Todd Chapman wrote:

How can you match the Recovery ticket with the Problem
ticket? Is there an ID in the subject or someting unique
you can use?

yes. the subject of the mail gives me the informations I need to match
tickets.

My system gets e-mail from a different (horrible, horrible)
ticketing system. Where store the ID from the foreign system
into a custom field. If a new ticket comes in and it has
an ID in the subject that matches an existing ticket custom
field, we merge the new ticket into the old one.

Can you give some hints about this ? If you can provide the scrip it’s
awsome :smiley:

-Todd


rt-users mailing list
rt-users@lists.bestpractical.com
The rt-users Archives

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

Hi,

I have a need to change ownership of a ticket when the person working on the
ticket is not the owner via a scrip. But it won’t change the owner. I’ve
tried the following with no success.

$self->TicketObj->SetOwner( $StaffName,‘Force’)

$self->TicketObj->SetOwner( $StaffName,‘Steal’)

Also, how do I specify the encoding in the following:

$self->TicketObj->Comment( Content => $NewContent );

Thanks,
Roman

Hi,

I have a need to change ownership of a ticket when the person working on
the ticket is not the owner via a scrip. But it won’t change the owner.
I’ve tried the following with no success.

$self->TicketObj->SetOwner( $StaffName,‘Force’)

$self->TicketObj->SetOwner( $StaffName,‘Steal’)
my ($status, $msg) = $self->TicketObj->SetOwner( $StaffName,‘Force’);
die “Couldn’t change owner: $msg” unless $status;

Also, how do I specify the encoding in the following:

$self->TicketObj->Comment( Content => $NewContent );
Use MIMEObj argument instead if you want to tune the action.

Thanks,
Roman


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

We’re hiring! Come hack Perl for Best Practical:
Careers — Best Practical Solutions

Best regards, Ruslan.

Thanks Ruslan.

When I force the new owner, I now get the following result:

forcing owner change works, I see the transcation but then it gets reverted
back.

I’ve checked for other scrips which may do this, but they do not exist.

RT_System Owner forcibly changed from jane done to john doe

but then generates:

john doe - Given to jane doe

Thanks again,
RomanOn 5/27/06, Ruslan Zakirov ruslan.zakirov@gmail.com wrote:

On 5/12/06, Roman Steven romansteve@gmail.com wrote:

Hi,

I have a need to change ownership of a ticket when the person working
on
the ticket is not the owner via a scrip. But it won’t change the owner.
I’ve tried the following with no success.

$self->TicketObj->SetOwner( $StaffName,‘Force’)

$self->TicketObj->SetOwner( $StaffName,‘Steal’)
my ($status, $msg) = $self->TicketObj->SetOwner( $StaffName,‘Force’);
die “Couldn’t change owner: $msg” unless $status;

Also, how do I specify the encoding in the following:

$self->TicketObj->Comment( Content => $NewContent );
Use MIMEObj argument instead if you want to tune the action.

Thanks,
Roman


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

We’re hiring! Come hack Perl for Best Practical:
Careers — Best Practical Solutions


Best regards, Ruslan.