[Nodebrain-users] RE: Is this a bug, or am I not getting it....
Rule Engine for State and Event Monitoring
Brought to you by:
trettevik
|
From: Trettevik, Ed A <ed....@bo...> - 2003-08-06 20:33:11
|
Looks like it is working as I would expect. You have created a nice =
illustration of the difference between ON and IF rules with respect to =
the ALERT command, and it looks like you fully understand that =
difference. In your second alert, all 3 ON rules fired, but only 1 IF =
rule fired. Two IF rules didn't respond as you expected. The IF rule =
that fired is the one defined in the context you alerted. The 2 defined =
in the parent context did not fire because that context was not alerted. =
In your third alert, no ON rule fired, as you expected, because the =
conditions did not transition to a true state---they were already there. =
Again, because only 1 IF rule was alerted, only 1 fired. You would =
have to alert the parent context to trigger the other two rules. =20
I'm not sure what will work best in your case, but here are some ideas =
to consider when organizing rules for multiple nodes.
1) When alerting a context devoted to a single node, that context can =
alert other contexts. In the following example, the M_21 context alerts =
the root context ("@") every time M_21 is alerted. It could be =
conditional---just replace (1) with a condition.=20
M_21 define P_root if(1):@ alert node=3D"21";
2) When alerting a high level context, that context can alert node =
specific contexts. I'm not sure if numnodes was intended as a node =
specific variable, but I'm making the assumption that both Warning and =
numnodes may be used as both root variables and node specific variables.
define P_node if(1):$ m_$${node} alert =
Warning=3D$${Warning},numnodes=3D$${numnodes};
alert node=3D"21",Warning=3D1,numnodes=3D1;
3) A cache (table) can often be used to avoid node specific rules. The =
following example monitors for 5, 10 and 30 nodes having the same =
problem within a 2 hour period. You can add and subtract problem and =
node names to your environment without changing these rules.
define cProblemNode context cache(~(2h),problem[5,10,30],node);
cProblemNode define P1 if(problem._kidState):$ - echo "$${problem} on =
$${problem._kids} nodes" >> /tmp/policy.txt
cProblemNode assert ("Degraded","web1");
cProblemNode assert ("Degraded","web2");
cProblemNode assert ("Degraded","db1");
If you want different caching intervals or thresholds for different sets =
of problems, just create multiple caches and assert specific types of =
problems to the right cache.
define cProblemNodeA context cache(~(4h),problem[100,200,1000],node);
cProblemNode assert ("Degraded","web1");
cProblemNodeA assert ("TrivialSomething","web1");
4) Node specific conditions can be represented by cache tables.
define NodeRequired context cache(node);
define r1 if(NodeRequired(node)):$ - echo "$${problem} on $${node}" >> =
/tmp/policy.txt
=09
NodeRequired assert ("21");
alert node=3D"21",problem=3D"DroppedTransaction";
5) If you have a set of rules that you want to repeat and maintain for =
multiple entities, SOURCE a rule file using symbolic substitution.
source nodeRules.nb node=3D"abc";
source nodeRules.nb node=3D"xyz";
The sourced file uses %{} for symbolic substitution of =
parameters---different than symbolic substitution using context =
variables where the notation is ${}.
define %{node} context;
%{node} define r1 on(%{node}.a=3D1 and %{node}.b=3D2);
%{node} define r2 on(%{node}.c=3D1 and %{node}.d<5);
If your node names include special characters (other than "'") you may =
use quoted names for your contexts.
define '%{node}' context;
'%{node}' define r1 on('%{node}'.a=3D1 and '%{node}'.b=3D2);
'%{node}' define r2 on('%{node}'.c=3D1 and '%{node}'.d<5);=09
source nodeRules.nb node=3D"humpty-dumpty.mothergoose.com";
'humpty-dumpty.mothergoose.com' assert a=3D1,b=3D2,c=3D1,d=3D0;
Don't know if this last example addresses your syntax concern. If not, =
please describe the problem in more detail and I'll give it another =
shot.
-Ed
-----Original Message-----
From: gh...@rl... [mailto:gh...@rl...]
Sent: Tuesday, August 05, 2003 12:25 PM
To: nod...@li...
Subject: Is this a bug, or am I not getting it....
Below is a block of code, and the out come. Tell me if you see =
something
wrong.I made up 6 case where all the rules should fire, but not all of =
them
do.
On the second alert only 4 out of 6 fire.
On the third alert only 1 out of 3 fire.
I am looking at this becuase I want to make a context per node, and have
rules that include multiple nodes, so multiple contexts. The easiest =
syntax
would be P_1a/b. P_2a/b work, but is to limited.
-Gilbert.
------------------- CODE ----------------------------
define M_21 context;
#P_1
define P_1a on(M_21.Warning>=3DM_21.numnodes):- echo "Policy fired 1a" =
>>
/tmp/policy.txt
define P_1b if(M_21.Warning>=3DM_21.numnodes):- echo "Policy fired 1b" =
>>
/tmp/policy.txt
#P_2
M_21 define P_2a on(Warning>=3Dnumnodes):- echo "Policy fired 2a" >>
/tmp/policy.txt
M_21 define P_2b if(Warning>=3Dnumnodes):- echo "Policy fired 2b" >>
/tmp/policy.txt
#P_3
alert T_3=3D=3D(M_21.Warning>=3DM_21.numnodes);
define P_3a on(T_3):- echo "Policy fired 3a" >> /tmp/policy.txt
define P_3b if(T_3):- echo "Policy fired 3b" >> /tmp/policy.txt
M_21 alert Warning=3D0,numnodes=3D1;
M_21 alert Warning=3D1,numnodes=3D1;
M_21 alert Warning=3D1,numnodes=3D1;
show -cells;
show P_1a;
show P_1b;
show M_21.P_2a;
show M_21.P_2b;
show P_3a;
show P_3b;
-------------- Output ------------------------
--- 4 out of 6
2003/08/05 01:45:43 NB000I Rule "@.P_3a" fired
> - echo "Policy fired 3a" >> /tmp/policy.txt
2003/08/05 01:45:43 NB000I Rule "P_2a" fired
> - echo "Policy fired 2a" >> /tmp/policy.txt
2003/08/05 01:45:43 NB000I Rule "@.P_1a" fired
> - echo "Policy fired 1a" >> /tmp/policy.txt
2003/08/05 01:45:43 NB000I Rule "P_2b" fired
> - echo "Policy fired 2b" >> /tmp/policy.txt
--- 1 out of 3
2003/08/05 01:59:34 NB000I Rule "P_2b" fired
> - echo "Policy fired 2b" >> /tmp/policy.txt
T_3 =3D 1 =3D=3D (M_21.Warning>=3DM_21.numnodes)
M_21.numnodes =3D 1
M_21.Warning =3D 1
M_21.OK =3D 0
@> P_1a on(M_21.Warning>=3DM_21.numnodes):- echo "Policy fired 1a" >>
/tmp/policy.txt
@> P_1b if(M_21.Warning>=3DM_21.numnodes):- echo "Policy fired 1b" >>
/tmp/policy.txt
@> M_21.P_2a on(M_21.Warning>=3DM_21.numnodes):- echo "Policy fired 2a" =
>>
/tmp/policy.txt
@> M_21.P_2b if(M_21.Warning>=3DM_21.numnodes):- echo "Policy fired 2b" =
>>
/tmp/policy.txt
@> P_3a on(T_3):- echo "Policy fired 3a" >> /tmp/policy.txt
@> P_3b if(T_3):- echo "Policy fired 3b" >> /tmp/policy.txt
|