Tideway Community Forum

forgot password?
   
 
Trigger by matching regex with process related to SI
Posted: 31 October 2008 10:23 AM   [ Ignore ]  
Newbie
Avatar
Rank
Total Posts:  30
Joined  2008-03-19

I’m writing a tpl that, amongst others, triggers on a ‘SAP R/3 Application Server’ SI.
It should only trigger on certain SAP servers that have a certain string in the cmd of the primary process from the SI.
I have made the trigger below, but of course it doesn’t work.
I’ve tried to look the answer up in the documentation but I can’t find it.
How can I match the underlying process correctly?

triggers
       on si 
:= SoftwareInstance createdconfirmedmodified
       where 
(type "Oracle Database Server"
              
and instance matches regex "PF[0-9]+")
          or (
type matches regex 'SAP R/3 Application Server'
              
and InferredElement:Inference:Primary:DiscoveredProcess.cmd matches regex "PF[0-9]+")
          or (
type matches regex 'SAP PF Tomato');
end triggers

 Signature 

“with a hip hop the hippie to the hippie
the hip hip a hop a you dont stop the rockin
to the bang bang boogie say up jump the boogie
to the rhythm of the boogie the beat”

Profile
 
 
Posted: 31 October 2008 10:40 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  132
Joined  2008-01-25

Hi Edwin, good to hear from you again.

The triggers section of the ECA is very highly optimized so we can make a decision on whether we need to invoke patterns very quickly. As you can imagine there are a lot of events going on during a scan.

This means you are restricted to what you can use in the triggers section to basic logic tests. Two things you can’t use are key expressions or a not condition.

It’s good practise to make the trigger conditions as tight as possible as you have done. But for the wider tests you will need to do these as the first part of the body section of the pattern and issue a stop command if you find you shouldn’t go on.

Essentially you need to think of a trigger as “good enough evidence to run the pattern” rather than absolute evidence.

Does that help?

(Edited to correct an error Edwin spotted – Thanks!)

Profile
 
 
Posted: 31 October 2008 11:18 AM   [ Ignore ]   [ # 2 ]  
Newbie
Avatar
Rank
Total Posts:  30
Joined  2008-03-19

Thanks for your reply Charles, but you’ve got me all confused now…
I have used various OR-conditions in my triggers without any problems.
My question focuses on this bit:

and InferredElement:Inference:Primary:DiscoveredProcess.cmd matches regex "PF[0-9]+" 

How do I put a correct relation here?

 Signature 

“with a hip hop the hippie to the hippie
the hip hip a hop a you dont stop the rockin
to the bang bang boogie say up jump the boogie
to the rhythm of the boogie the beat”

Profile
 
 
Posted: 31 October 2008 11:56 AM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  132
Joined  2008-01-25

I confused myself due to lack of coffee – of course it’s not you can’t use or is fine. I’ll correct the reply for clarity.

To test a related node you will need to do this in the body of the pattern. So a simplistic example would be along the lines of

triggers
  on si 
:= SoftwareInstance createdconfirmed where type 'SAP R/3 Application Server';
end triggers;

body
  
if not si.#InferredElement:Inference:Primary:DiscoveredProcess.cmd matches regex "PF[0-9]+" then
  
stop;
end body

Notes on body termination are here and trigger notes are here.

Profile
 
 
Posted: 31 October 2008 12:11 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  132
Joined  2008-01-25

As an aside you probably don’t need the modified in this pattern.

A trigger with created, confirmed will be fired every time model.SoftwareInstance() is used to confirm the existence of the SI you are trigger on.

The only time you would really need a modified trigger kind is if you expect an attribute to be updated directly, usually through some custom pattern.

Profile
 
 
Posted: 31 October 2008 12:14 PM   [ Ignore ]   [ # 5 ]  
Newbie
Avatar
Rank
Total Posts:  30
Joined  2008-03-19

This is exactly what I wanted to know.
You made it clear that I try to do too much in the trigger itself, while the body is much better suited for that.
Sometimes when I’m on a track it’s hard to jump on another (the right) one..
Good suggestion about the ‘modified’ bit too.
Many thanks!

 Signature 

“with a hip hop the hippie to the hippie
the hip hip a hop a you dont stop the rockin
to the bang bang boogie say up jump the boogie
to the rhythm of the boogie the beat”

Profile