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

Reply via email to