Re: Policy with perl script only first rule triggres (204 Views)
Reply
Honored Contributor
KAKA_2
Posts: 1,278
Registered: ‎05-26-2007
Message 1 of 7 (305 Views)
Accepted Solution

Policy with perl script only first rule triggres

Hello Support,

 

I have created a policy with embeded perl script. I also used Ovtrace.pm module in it. Script outside policy, just works fine and if i use the same script as an only one rule in the policy then also it works fine but when i split it into multiple rules it never enters into 2nd rule.

 

I am also aware that if first rule matches then policy never go into second rule but i have made sure that first rule does not match in this case.

 

can someone help me at what step i am doing wrong? if not with the same policy then can just pass an example policy which works with two rules?

 

Attaching word document for quick review. let me know if you need policy.

 

Any help will be appricated.

 

Thank You.

-KAKA-

Please use plain text.
Valued Contributor
Kallol
Posts: 54
Registered: ‎01-20-2011
Message 2 of 7 (275 Views)

Re: Policy with perl script only first rule triggres

Hello there,

 

In between the rules, I do see the variable $offset being accessed. If you are assinging it in rule 1, try saving it in a session variable and use the same in the second rule. 

 

$Session->Value('offset', $offset); --> Store the value of offset in session variable in the first Rule

$offset = $Session->Value('offset') --> Retrieve the session variable in the second Rule for further use

 

Also in order to get the trace statements one need to recreate the OvTrace object

use OvTrace;
my $tracer = OvTrace->new($Policy,$ConsoleMessage, $Rule, $Session);

 

Hope this helps. Do let me know also in case if possible do share the policy.

Thanks and Regards,
_______________________________________________________
Kallol Roy

"Be kinder than necessary, for everyone you meet is fighting some kind of battle."
Please use plain text.
Honored Contributor
KAKA_2
Posts: 1,278
Registered: ‎05-26-2007
Message 3 of 7 (264 Views)

Re: Policy with perl script only first rule triggres

Hello Kallol,

 

 

Thank You for your response. I tried as you suggested but still it does not hit second rule. attaching the modified policy.

 

-KAKA-

Please use plain text.
Honored Contributor
KAKA_2
Posts: 1,278
Registered: ‎05-26-2007
Message 4 of 7 (254 Views)

Re: Policy with perl script only first rule triggres

[ Edited ]

Hello Kallol,

I was able to fix this policy by modifying the second rule and observed following things.

 

1. Trace in second rule will not work, however 2nd rule is triggering and firing alarm.

2. 2nd rule does not work for if-else condition. Only for if condition is working.

 

To confirm if 2nd rule is being evaluated or not i created a syntax error intentionally and i got error from opcmona, which confirmed me that 2nd rule is being evaluated.

 

Then I modified the codes to look as below in second rule.

 

use OvTrace;

my $traceObj = OvTrace->new($Policy, $ConsoleMessage, $Rule, $Session);

my $offset = $Session->Value('offset');

if ($offset < 1 && $offset > -1) {
if ($Debug) {
        $traceObj->WriteTraceLog($Debug, \"Value of offset is between +1 and -1:\" .$offset);
$Rule->Status(1);
}

I got the alert from this rule but there was no trace message. I checked all the SI policies, and see even they have trace configured only on first rule but not on following rules. Is there a limitation?

 

And about only one if condition I could not compare with any existing policy.  

 

Thank You.

-KAKA-

 

Please use plain text.
Valued Contributor
Kallol
Posts: 54
Registered: ‎01-20-2011
Message 5 of 7 (240 Views)

Re: Policy with perl script only first rule triggres

[ Edited ]

Hello KAKA,

 

I did install the policy on my OMW, and as you said I was about to ask if you had got any trace message from the second rule. But then I noticed that I didnt point you for the variable Debug. Remember the value of $Debug is set in the first rule and its local to that rule alone. In order to use the same variable you can use 

my $Debug = $Session->Value('Debug');

 

Also I wanted to keep a trace outside to see if the rule is getting executed or not as shown below:

 

use OvTrace;
my $traceObj = OvTrace->new($Policy, $ConsoleMessage, $Rule, $Session);
my $offset = $Session->Value('offset');

$traceObj->WriteTraceLog($Debug,\"Trace: I am in the second rule \\n\");

Thanks and Regards,
_______________________________________________________
Kallol Roy

"Be kinder than necessary, for everyone you meet is fighting some kind of battle."
Please use plain text.
Honored Contributor
KAKA_2
Posts: 1,278
Registered: ‎05-26-2007
Message 6 of 7 (218 Views)

Re: Policy with perl script only first rule triggres

Hello Kallol,

I think I tried assigning session variable debug to $ debug and there was no trace message, but that was inside the if condition. I will try again tomorrow.

How about if- else condition in second rule? Did you get alert or trace message ?

-KAKA-
Please use plain text.
Honored Contributor
KAKA_2
Posts: 1,278
Registered: ‎05-26-2007
Message 7 of 7 (204 Views)

Re: Policy with perl script only first rule triggres

Hi Kallol,

I tested again this policy as you suggested and now see trace is working in second rule and if-else condition as well.

So i think main problem was if i dont assign any variable into session varibale they can not be used in next rule.

Thanks fo your help.

-KAKA-
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation