perl operations on a hash are surprisingly efficient. If you store your context
in a hash, it can be very efficient to add/remove/check specific items. What is
not efficient is aging things out based on time.
David Lang
On Thu, 2 Apr 2020, Richard Ostrochovský wrote:
Date: Thu, 2 Apr 2020 00:17:40 +0200
From: Richard Ostrochovský <richard.ostrochov...@gmail.com>
To: simple-evcorr-users@lists.sourceforge.net
Subject: Re: [Simple-evcorr-users] action-list checking if log file is already
open by SEC
Hi Risto,
thank you for the solution. There is also concern about potential
performance impact in case of e.g. thousands of files being added by
addinput with creating extra context for each of them.
Another way could be e.g. maintaining (associative) array in action list,
with keys of paths to addinput files, reduced by dropinput, similarly as
you suggest with context creation.
And maybe the most efficient, having built-in way, how to access this list
of open files, without custom implementation of it.
How do you see these potential options in comparison by performance?
Richard
št 20. 2. 2020 o 21:23 Risto Vaarandi <risto.vaara...@gmail.com> napísal(a):
hi Richard,
I think this scenario is best addressed by creating a relevant SEC context
when 'addinput' action is called. In fact, handling such scenarios is one
of the purposes of contexts, and here is an example rule which illustrates
this idea:
type=single
ptype=regexp
pattern=start monitoring (\S+)
context=!FILE_$1_MONITORED
desc=add $1 to list of inputs
action=addinput $1; create FILE_$1_MONITORED
Whenever "start monitoring <filename>" event appears, the rule will match
only if context FILE_<filename>_MONITORED does not exist. If rule matches,
it executes 'addinput' action for the given file and creates the context,
in order to manifest the fact that 'addinput' has already been executed for
the given file. Also, as you can see from the above rule, the presence of
the context for a file will prevent the execution of 'addinput' again for
this file. In order to keep contexts in sync with files that are monitored,
the context for a file should be deleted when 'dropinput' action is
executed for it.
Note that when HUP signal is received, SEC will stop monitoring input
files set up with 'addinput' action. However, on receiving HUP signal SEC
will also drop all its contexts, so there is no need to take any extra
steps in that case.
Hope this helps,
risto
Kontakt Richard Ostrochovský (<richard.ostrochov...@gmail.com>) kirjutas
kuupäeval N, 20. veebruar 2020 kell 21:43:
Hello Risto and friends,
having mechanism for dynamic opening (addinput) and closing (dropinput)
files, I would like to be able to check, if the file is already opened,
before trying to open it again, to avoid it. That way I would like to
eliminate this error message from SEC log (present also in debug level 3):
Dynamic input file '/path/to/file.log' already exists in the list of
inputs, can't add
This information is present in sec.dump, but maybe there exists more
instant and straightforward way how to achieve it (without parsing
intermediary files).
Thank you.
Richard
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users