On 11/01/2010 11:16 PM, Risto Vaarandi wrote: > hi Tim, > here is the workaround I promised -- it works for the Linux/DGRAM-socket > systems: > > type=Single > ptype=SubStr > pattern=SEC_STARTUP > context=SEC_INTERNAL_EVENT > continue=TakeNext > desc=Load the Socket module and store facility/level values to hashes > action=assign %a 0; eval %a (require Socket); eval %a (exit(1) unless %a); \ > eval %a ( %facility = ( 'kern' => 0, 'user' => 1, 'mail' => 2, \ > 'daemon' => 3, 'auth' => 4, 'syslog' => 5, 'lpr' => 6, \ > 'news' => 7, 'uucp' => 8, 'cron' => 9, 'authpriv' => > 10, \ > 'ftp' => 11, 'ntp' => 12, 'local0' => 16, 'local1' => > 17, \ > 'local2' => 18, 'local3' => 19, 'local4' => 20, \ > 'local5' => 21, 'local6' => 22, 'local7' => 23 ) ); \ > eval %a ( %level = ('emerg' => 0, 'alert' => 1, 'crit' => 2, \ > 'error' => 3, 'warning' => 4, 'notice' => 5, \ > 'info' => 6, 'debug' => 7) ) > > > type=Single > ptype=RegExp > pattern=(SEC_STARTUP|SEC_RESTART) > context=SEC_INTERNAL_EVENT > desc=Open connection to syslogd and compile the logging routine > action=eval %a ( socket(SOCKET, Socket::PF_UNIX, Socket::SOCK_DGRAM, 0); \ > connect(SOCKET, Socket::sockaddr_un('/dev/log')) ); \ > eval %syslog ( sub { my($pri) = $facility{$_[0]}*8 + $level{$_[1]}; \ > my($tag) = $_[2]; my($msg) = $_[3]; \ > my($time) = scalar(localtime(time())); \ > substr($time, 0, 4) = ""; \ > substr($time, -5) = ""; \ > send(SOCKET, "<$pri>$time $tag: $msg", 0); } ) > > > type=Single > ptype=RegExp > pattern=facility=(\S+) level=(\S+) tag=(\S+) msg=(.*) > desc=log message $4 for program $3 with priority $1.$2 > action=call %o %syslog $1 $2 $3 $4 >
in order to add another example to previous rule -- if you write call %o %syslog local0 notice myprogram %s this action will log the content of the %s variable with the 'local0.notice' priority and tag 'myprogram'. hth, risto > > The first two rules only act when SEC is (re)started, and they set up the > environment for later communication with local syslogd. The actual > communication is done by the third rule and it is really simple -- it is only > a matter of calling a function through the pointer in the %syslog variable, > with facility, level, program name and message text as parameters. Although > in the case of this example messages are written to /dev/log without the > hostname field, there could be also unix flavors around which require its > presence (and hostname must be present if you are opening the socket to a > remote syslog server). > hope this helps, > risto > > > --- On Wed, 10/27/10, Tim Peiffer<peif...@umn.edu> wrote: > >> From: Tim Peiffer<peif...@umn.edu> >> Subject: Re: [Simple-evcorr-users] New feature requests >> To: "Risto Vaarandi"<rvaara...@yahoo.com> >> Cc: simple-evcorr-users@lists.sourceforge.net >> Date: Wednesday, October 27, 2010, 2:45 AM >> On 10/26/10 4:14 PM, Risto Vaarandi >> wrote: >>> Are you requesting this feature because you would like >> to change the list of configuration files without restarting >> SEC? If so, then you could also take advantage of SEC >> resource file which can be provided with an environment >> variable. >>> As for changing syslog tag field dynamically for every >> message -- unfortunately, the openlog(3) C-library function >> sets the program name for all subsequent logging, so this >> means that connection to syslog would have to be reopened >> and closed for each call to syslog(3) function. I think >> there is no clean way to replace the program name string >> temporarily with something else, so I will have to >> investigate what would be the possible performance penalty >> of opening and closing connection to syslogd for each >> logging attempt. >>> kind regards, >>> risto >> With regards to the list of configuration files.. sometimes >> it is >> difficult to load all of the -conf=<filename> on the >> command line. I am >> interested in providing a clean looking process >> table. And, it might be >> nice to change the list of configuration files without a >> restart of >> SEC. So if I wished to use a SECRC, an example (this >> is not clear in >> the documentation) might be >> >> $SEC/.secrc: >> -input=<input 1> >> -input=<input 2> >> -config=<config 1> >> -config=<config 2> >> -log=<logfile> >> -pid=<pidfile> >> -dump=<dumpfile> >> >> With regards to syslog tags, since it seems too difficult >> to do, I will >> assign text to %TAG, and use that as part of the >> logonly line, >> logonly %TAG<my message> >> so that the line in syslog comes out looking like ... >> sec.pl[<pid>]<my tag> <my >> message> >> >> Relating the two requests: >> If I provide multiple configuration files as above, I might >> want to have >> a different %TAG for each file, so I would want a way of >> localizing the >> configuration scope... >> >> Please advise, >> Tim Peiffer >> >> -- >> Tim Peiffer >> Network Support Engineer >> Office of Information Technology >> University of Minnesota/NorthernLights GigaPOP >> >> +1 612 626-7884 (desk) >> >> >> ------------------------------------------------------------------------------ >> Nokia and AT&T present the 2010 Calling All >> Innovators-North America contest >> Create new apps& games for the Nokia N8 for consumers >> in U.S. and Canada >> $10 million total in prizes - $4M cash, 500 devices, nearly >> $6M in marketing >> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish >> to Ovi Store >> http://p.sf.net/sfu/nokia-dev2dev >> _______________________________________________ >> Simple-evcorr-users mailing list >> Simple-evcorr-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users >> > > > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > Create new apps& games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > Simple-evcorr-users mailing list > Simple-evcorr-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users > > ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users