Hi,

Thanks again for sharing your work, i was testing and studying a little bit
and firstly i could not use as it comes because in SEC 2.6.2 and Strawberry
Perl 5.14.3.1 are not supported. Then i rewrite the code a little bit for
using it . Commands such  "given" and "when" are not included in this
compilation, also i had to modify log level in "fake_signal_handler" method
and change " LOG_WITHOUT_LEVEL" and set up " LOG_WARN". I did the following
modifications to work:

I created a Signals.pm, that´s included in path "/perl/lib/Signals".

Signals.pm
_________________________________________________________________
package SecSignals;

our $SELF = 'SecSignals';


# Subroutine to provide access to native signal processing on platforms
# where signals not supported, eg Windows with native perl (ActiveState,
# Strawberry etc)
sub fake_signal_handler {
    my ($fakesignal) = @_;
    if ($fakesignal =~ /^HUP$/i) { main::hup_handler; }
if ($fakesignal =~ /^ABRT$/i) { main::abrt_handler; }
if ($fakesignal =~ /^USR1$/i) { main::usr1_handler; }
    if ($fakesignal =~ /^USR2$/i) { main::usr2_handler; }
    if ($fakesignal =~ /^INT$/i) { main::int_handler; }
    if ($fakesignal =~ /^TERM$/i) { main::term_handler; }
    if ($fakesignal !~ /^HUP$|^ABRT$|^USR1$|^USR2$|^INT$|^TERM$/i){
my($namefake)= $_[0];
main::log_msg(main::LOG_WARN,"$fakesignal - Unknown fake signal in $SELF");
                     return "$fakesignal Unknown fake signal in $SELF";
}

    return 0;
}
1;
_________________________________________________________________

In the rulesets folder, i created 2 files:


SecSignalsRules.conf
_________________________________________________________________

type = single
continue=dontcont
desc = do a full restart of SEC
context = SIGNALSCONTEXT
ptype = regexp
pattern = ^resetSec
action = lcall %r HUP -> ( sub { SecSignals::fake_signal_handler(@_) } );
delete SIGNALSCONTEXT;

###############################################################################
type = single
continue=dontcont
desc = do a soft restart of SEC
context = SIGNALSCONTEXT
ptype = regexp
pattern = ^reloadSec
action = lcall %r ABRT -> ( sub { SecSignals::fake_signal_handler(@_) } );
delete SIGNALSCONTEXT;

###############################################################################
type = single
continue=dontcont
desc = dynamically cycle through logging verbosity levels
context = SIGNALSCONTEXT
ptype = regexp
pattern = ^verboseSec
action = lcall %r INT -> ( sub { SecSignals::fake_signal_handler(@_) } );
delete SIGNALSCONTEXT;

###############################################################################
type = single
continue=dontcont
desc = write info about SEC state to the dump file
context = SIGNALSCONTEXT
ptype = regexp
pattern = ^dumpstatsSec
action = lcall %r USR1 -> ( sub { SecSignals::fake_signal_handler(@_) } );
delete SIGNALSCONTEXT;

###############################################################################
type = single
continue=dontcont
desc = close and reopen output logs
context = SIGNALSCONTEXT
ptype = regexp
pattern = ^logrotateSec
action = lcall %r USR2 -> ( sub { SecSignals::fake_signal_handler(@_) } );
delete SIGNALSCONTEXT;

###############################################################################
type = single
continue=dontcont
desc = implement fake signal handling
ptype = regexp
context = SIGNALSCONTEXT && !SEC_INTERNAL_EVENT
pattern = (.*)
action = lcall %r $1 -> ( sub { SecSignals::fake_signal_handler(@_) } );
delete SIGNALSCONTEXT;

_________________________________________________________________


and iniSignals.pm

iniSignals.pm
_________________________________________________________________

type=Single
ptype=SubStr
pattern=SEC_STARTUP
context=SEC_INTERNAL_EVENT
continue=TakeNext
desc=Load the Signals module and terminate if it is not found
action=eval %ret (require Signals::SecSignals;);\
eval %ret (exit(1) unless %ret);

_________________________________________________________________


Afterwards i launch this rules from my ruleset like this:


Rule.conf(just an example)
_________________________________________________________________

type=Calendar
time= */5 * * * *
desc= $0
action= create SIGNALSCONTEXT; event reloadSec;

type=Calendar
time= 30 15 * * *
desc= $0
action= create SIGNALSCONTEXT; event reloadSec;
_________________________________________________________________

I created an specific context to manage all signals and activate when it is
necessary "SIGNALSCONTEXT".

I have some doubts about it. I never could use signals(It´s new for me).

Doubt 1:
I load the files with a path regexp like this:

C:\logs\*roduction\*\*.log

And it generates paths like this:

C:\logs\Production\Device1\log.log
C:\logs\production\Device3\log.log
C:\logs\Production\Device5\log.log
C:\logs\production\Device8\log.log

and sec process it directly before.

If i use this kind of rule:

type=Calendar
time= 30 15 * * *
desc= $0
action= create SIGNALSCONTEXT; event reloadSec;

The system waits till sec reload(15:30 hour) and generate input files for
sec and start to work. Why happend this?

Doubt 2:

Sorry for being repetitive.

I load the files with a path regexp like this:

C:\logs\*roduction\*\*.log

And it generates paths like this:

C:\logs\Production\Device1\log.log
C:\logs\production\Device3\log.log
C:\logs\Production\Device5\log.log
C:\logs\production\Device8\log.log

and sec process.

During the processing if i had new files in the input scope don´t read it.
Just read the first paths loaded.

For example a file is added in the following path:

C:\logs\production\Device9\log.log

During the next reload system has to generate the following paths:

C:\logs\Production\Device1\log.log
C:\logs\production\Device3\log.log
C:\logs\Production\Device5\log.log
C:\logs\production\Device8\log.log
C:\logs\production\Device9\log.log

Sec and perl could not reach it and process the new file.

C:\logs\production\Device9\log.log

Which kind of signal i have to send? It´s a little bit confusing for me.

I launch the process with the following options: --blocksize=1024
--bufsize=10 --cleantime=1 --debug=4 --nodetach --nofromstart
--nointcontexts --intevents --nokeepopen --log=E:\output.log --noquoting
--reopen_timeout=10 --tail

Thanks for your support!. Regards.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to