Bill Campbell<[EMAIL PROTECTED]> wrote on 2006-02-09 05:15:50:
> On Wed, Feb 08, 2006, Doug Summers wrote:
>>Could someone post a quick example of how to rotate logs based on size 
>>and/or age with FSL? I'm most interested in rotating after 60 days and 
>>keeping all compressed archives.
> 
> You can find many examples in the %{l_prefix}/etc/rc.d/rc.* run
> control files in the %daily sections. [...]
> 
As Bill suggested, looking into existing packages is the easiest way getting
examples. I recommend you check out the sources thus getting every existing
use. You must look at both, rc.* and fsl.* files.

Note that fsl by itself does not rotate logs at all! It requires an external
mechanism to rotate, archive and often restart service. In the OpenPKG world we
usually use "shtool rotate" and fsl in concert. This tool has powerful
capabilities to decide when to rotate, how to archive and compress and it
allows execution of external programs prior and past rotation. And that tool is
under control of the same developers, so we can always make shtool and fsl a
working team :-)

Regarding fsl it should be noted in OpenPKG by default we always log to a plain
file, although fsl offers more options. The challenge with rotation is that the
application does not know when an external "shtool rotate" moved the log away.
The application still logs into the previously opened file. Few applications
can be tweaked to close and open their logging channels so the majority of
packages restart the whole service after rotation. Not ideal, but it works -
sadly some service behaves better with occational restarts anyway, think of
memory leaks and other uncleand resources.

In case you do neither want service restarts nor does the service offer a
mechanism to control log restarting (e.g. by sending a signal or pipe a command
through a network socket) then fsl offers help. To be more precise, fsl dumps
its logs through OSSP l2 (logging library) and inherits its capabilities from
there. Again, same developers :-)

Option 1: "jitter=<count>"
see -> cvs, lighttpd, nagios, nessus-tool, nsd, openvpn, pound, powerdns,
spamassassin, squid

Counts the messages being written to the log and closes and opens the logfile
after every <count> writes just before the actual write is performed. Use
jitter=1" to close and open for every new message. This is very easy to
understand and use but the price is a performance penalty.

Option 2: "monitor=<seconds>"
see -> dhcp-agent, gated, lighttpd, nagios, nessus-tool, nsd, openvpn, postfix, 
pound, powerdns, powerdns, spamassassin, ucarp

Remembers the time when the last message was written to the log. Before every
new write the current time is checked and in case <seconds> or more time has
passed since the last write the state of the log file is monitored and in case
the original file disappeared a close and open is done before the write. Sounds
a little bit complicated but fsl cannot trigger actions by time because it is
under control of the applications it was implanted and that application does
not know about fsl (otherwise it could use OSSP l2 natively without fsl
wrapping syslog). So fsl can only act when it is called. The behavior is that
fsl keeps the log file open until the next message is to be written. This could
probably be a very long time and the opened log file might be moved, compressed
and deleted in the mean time. No problem, the check is performed before the
next write and we thoroughly evaluated that closing such a strange file does
not do harm to the application, fsl or the log file contents. Again the price
for using that feature is a performance penalty.

Find more details -> openpkg man fsl
 


-- 
Thomas
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
User Communication List                      openpkg-users@openpkg.org

Reply via email to