Creating my own Scrip conditions

Hi all,

I have created a lib/RT/Condition/ZabbixEventStatusChange.pm which
contains the following (pruned down to the relevant part):

sub IsApplicable {
my $self = shift;
if ($self->TransactionObj->Field =~ /zabbix_event_status/) {
return(1);
}
else {
return(undef);
}
}

Also, I added

{

  Name                 => 'On zabbix_event_status Change',
          # loc
  Description          => 'Whenever a ticket\'s

zabbix_event_status changes’, # loc
ApplicableTransTypes => ‘Set’,
ExecModule => ‘ZabbixEventStatusChange’,
},

to @ScripConditions in etc/initialdata .

I have four questions regarding this:

  1. Is the this the correct thing to do? If not, what is the correct
    approach? The condition does not show up in RT, even after an Apache
    restart which included killing the mason cache, so I probably did
    something wrong.

  2. Is =~ /foo/ the correct thing to do, here? I decided to play it save
    and not match too narrowly, atm.

  3. What happens if a user sets his locale to, say, french, for which I
    did not provide a translation. Will RT fall back gracefully?

  4. Can I overlay .po files? I did not even try as I suspect that will
    not work, anyway.

All feedback extremely appreciated. RT fits our needs better and better,
I just need to iron out the last few things, including this one :slight_smile:

Richard

PS: If someone can tell me how to merge tickets from within the scrip I
am writing, that would be awesome. Else, I will just figure it out,
myself :slight_smile:

PPS: The goal is to merge all tickets our Zabbix instances create to
inform us of trigger changing to OFF into the tickets which set the
initial ON for the tuple of zabbix instance & event id. If anyone needs
such a thing for themselves, I will share, gladly.

Richard,

I'm not sure I understand WHY you are creating new conditions. If you 

are trying to create your own scrips for non-default situations, I would
recommend setting the Condition to “User-defined” and coding the correct
perl for that condition. I do not understand why you would want top mess
around with the code in the directories. Is there some condition you
need to look for that is not codable in perl?

Kenn
LBNLOn 10/20/2008 8:25 AM, Richard Hartmann wrote:

Hi all,

I have created a lib/RT/Condition/ZabbixEventStatusChange.pm which
contains the following (pruned down to the relevant part):

sub IsApplicable {
my $self = shift;
if ($self->TransactionObj->Field =~ /zabbix_event_status/) {
return(1);
}
else {
return(undef);
}
}

Also, I added

{

  Name                 => 'On zabbix_event_status Change',
          # loc
  Description          => 'Whenever a ticket\'s

zabbix_event_status changes’, # loc
ApplicableTransTypes => ‘Set’,
ExecModule => ‘ZabbixEventStatusChange’,
},

to @ScripConditions in etc/initialdata .

I have four questions regarding this:

  1. Is the this the correct thing to do? If not, what is the correct
    approach? The condition does not show up in RT, even after an Apache
    restart which included killing the mason cache, so I probably did
    something wrong.

  2. Is =~ /foo/ the correct thing to do, here? I decided to play it save
    and not match too narrowly, atm.

  3. What happens if a user sets his locale to, say, french, for which I
    did not provide a translation. Will RT fall back gracefully?

  4. Can I overlay .po files? I did not even try as I suspect that will
    not work, anyway.

All feedback extremely appreciated. RT fits our needs better and better,
I just need to iron out the last few things, including this one :slight_smile:

Richard

PS: If someone can tell me how to merge tickets from within the scrip I
am writing, that would be awesome. Else, I will just figure it out,
myself :slight_smile:

PPS: The goal is to merge all tickets our Zabbix instances create to
inform us of trigger changing to OFF into the tickets which set the
initial ON for the tuple of zabbix instance & event id. If anyone needs
such a thing for themselves, I will share, gladly.


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

   I'm not sure I understand WHY you are creating new conditions.

Because I need to test on the status of CF.{zabbix_event_status}

If you
are trying to create your own scrips for non-default situations, I would
recommend setting the Condition to “User-defined” and coding the correct
perl for that condition. I do not understand why you would want top mess
around with the code in the directories. Is there some condition you need to
look for that is not codable in perl?

No, but jibsheet in #rt suggested this approach as you can then check in
your changes into svn. Also, I could not find any useful snippets for the
scrip conditions (i.e. what is needed, what to leave out when compared to
the file-based approach) whereas it’s trivial to template from the files.

Thanks,
Richard

Richard,

I use something like this to test a CF Value:

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’)
{my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,
Name => “QA Approved”);
return 0 unless $cf->id;
if ($trans->Field == $cf->id &&
$trans->NewValue eq “Yes”)
{
return 1;
}
}

return 0;

I even have some compound conditions in code. I find this MUCh easier 

to maintain than fooling around in the directories. Just a thought.

Kenn
LBNLOn 10/20/2008 1:44 PM, Richard Hartmann wrote:

On Mon, Oct 20, 2008 at 21:50, Kenneth Crocker KFCrocker@lbl.gov wrote:

   I'm not sure I understand WHY you are creating new conditions.

Because I need to test on the status of CF.{zabbix_event_status}

If you
are trying to create your own scrips for non-default situations, I would
recommend setting the Condition to “User-defined” and coding the correct
perl for that condition. I do not understand why you would want top mess
around with the code in the directories. Is there some condition you need to
look for that is not codable in perl?

No, but jibsheet in #rt suggested this approach as you can then check in
your changes into svn. Also, I could not find any useful snippets for the
scrip conditions (i.e. what is needed, what to leave out when compared to
the file-based approach) whereas it’s trivial to template from the files.

Thanks,
Richard

   I even have some compound conditions in code. I find this MUCh easier

to maintain than fooling around in the directories. Just a thought.

I will play with that tomorrow. Thanks :slight_smile:

Richard