Re: [Simple-evcorr-users] Test IF correlation operation exist then take action

2017-01-15 Thread Dusan Sovic
Hi Risto,


This is exactly what I have looking for!

Thank you,
Dusan


Od: Risto Vaarandi <risto.vaara...@gmail.com>
Odoslané: 15. januára 2017 20:54
Komu: Dusan Sovic
Kópia: simple-evcorr-users@lists.sourceforge.net
Predmet: Re: [Simple-evcorr-users] Test IF correlation operation exist then 
take action

hi Dusan,

the use of 'getwpos' is probably the best way to accomplish this task.
As an alternative, one could check sec internal data structures, but
it is more complex and makes the rules less readable. Since 'getwpos'
assigns the beginning of the event correlation window (as seconds
since epoch) to a variable, and does not alter the variable if the
operation does not exist, the presence of operations could be checked
in the following way:

type=SingleWithSuppress
ptype=RegExp
pattern=event: (\d+)
desc=suppress event $1
action=write - %s
window=30

type=Single
ptype=RegExp
pattern=check: (\d+)
desc=check if operation for event $1 exists
action=assign %exists 0; getwpos %exists -1 suppress event $1; \
   if %exists ( write - Operation for event $1 exists ) \
 else ( write - Operation for event $1 does not exist )

In this very simple example, the second rule verifies if a
SingleWithSuppress operation is currently running for a given event
number. If the operation does not exist, %exists variable will keep
its initial value 0, and thus the 'if-else' action will print the
right status string to standard output.

Hope this helps,
risto

2017-01-15 18:32 GMT+02:00 Dusan Sovic <dusan.so...@hotmail.sk>:
> Dear mailing list users,
>
> In one of my rule I need to conditionally take action if given correlation 
> operation exist. From SEC man page, I can see that under rule *action* I can 
> use actions 'reset', 'getwpos' and 'setwpos' to work with correlation 
> operation(s).
> I learn how to use 'reset' action and it's working well for me.
> In one of my rule I need to call two actions if given operation exist and do 
> nothing if operation doesn't exist.
>
> The "pseudo code" may looks like:
>
> action= if( exist([] []) ) { write - some_output_$0; reset 
> [] []; }
>
> One theoretical solution what I see is to use 'getwpos' action and use return 
> value % for test in next *if* statement, but maybe there is a "smarter" 
> way how to test for the presence / existence of correlation operation.
>
> Thank you,
> Dusan
>
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> ___
> Simple-evcorr-users mailing list
> Simple-evcorr-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users


Re: [Simple-evcorr-users] Test IF correlation operation exist then take action

2017-01-15 Thread Risto Vaarandi
hi Dusan,

the use of 'getwpos' is probably the best way to accomplish this task.
As an alternative, one could check sec internal data structures, but
it is more complex and makes the rules less readable. Since 'getwpos'
assigns the beginning of the event correlation window (as seconds
since epoch) to a variable, and does not alter the variable if the
operation does not exist, the presence of operations could be checked
in the following way:

type=SingleWithSuppress
ptype=RegExp
pattern=event: (\d+)
desc=suppress event $1
action=write - %s
window=30

type=Single
ptype=RegExp
pattern=check: (\d+)
desc=check if operation for event $1 exists
action=assign %exists 0; getwpos %exists -1 suppress event $1; \
   if %exists ( write - Operation for event $1 exists ) \
 else ( write - Operation for event $1 does not exist )

In this very simple example, the second rule verifies if a
SingleWithSuppress operation is currently running for a given event
number. If the operation does not exist, %exists variable will keep
its initial value 0, and thus the 'if-else' action will print the
right status string to standard output.

Hope this helps,
risto

2017-01-15 18:32 GMT+02:00 Dusan Sovic :
> Dear mailing list users,
>
> In one of my rule I need to conditionally take action if given correlation 
> operation exist. From SEC man page, I can see that under rule *action* I can 
> use actions ‘reset’, ‘getwpos’ and ‘setwpos’ to work with correlation 
> operation(s).
> I learn how to use ‘reset’ action and it’s working well for me.
> In one of my rule I need to call two actions if given operation exist and do 
> nothing if operation doesn’t exist.
>
> The "pseudo code" may looks like:
>
> action= if( exist([] []) ) { write - some_output_$0; reset 
> [] []; }
>
> One theoretical solution what I see is to use 'getwpos' action and use return 
> value % for test in next *if* statement, but maybe there is a "smarter" 
> way how to test for the presence / existence of correlation operation.
>
> Thank you,
> Dusan
>
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> ___
> Simple-evcorr-users mailing list
> Simple-evcorr-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users


[Simple-evcorr-users] Test IF correlation operation exist then take action

2017-01-15 Thread Dusan Sovic
Dear mailing list users,

In one of my rule I need to conditionally take action if given correlation 
operation exist. From SEC man page, I can see that under rule *action* I can 
use actions ‘reset’, ‘getwpos’ and ‘setwpos’ to work with correlation 
operation(s). 
I learn how to use ‘reset’ action and it’s working well for me.
In one of my rule I need to call two actions if given operation exist and do 
nothing if operation doesn’t exist.

The "pseudo code" may looks like:

action= if( exist([] []) ) { write - some_output_$0; reset 
[] []; }

One theoretical solution what I see is to use 'getwpos' action and use return 
value % for test in next *if* statement, but maybe there is a "smarter" 
way how to test for the presence / existence of correlation operation.

Thank you,
Dusan

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users