help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: The cfengine way of rotating files?


From: Julian Simpson
Subject: RE: The cfengine way of rotating files?
Date: Wed, 5 Feb 2003 21:43:47 -0000

Hi John,
 
Thanks for your reply.  I have looked at cronolog and it sounds great.  Not sure if it will work in this instance because I have a mix of servers - including several Java servers that use log4j and other methods to write logfiles - so I'm not sure I can easily get it to work there.
 
I think I can work out an alternative from your example below anyhow - so thanks for that. I think it proves that I hadn't understood the cfengine approach to things :)
 
Best,
 
Julian.
 
-----Original Message-----
From: help-cfengine-bounces+julian_simpson=gmx.co.uk@gnu.org [mailto:help-cfengine-bounces+julian_simpson=gmx.co.uk@gnu.org] On Behalf Of Wheeler, John
Sent: 05 February 2003 15:19
To: help-cfengine@gnu.org
Subject: RE: The cfengine way of rotating files?

I had to do something like this recently. I ran across this
http://www.cronolog.org/

It make file creation a much easier with apache.

It created the files I need in a format similar to what you described. The second part was moving and copying. I've included the conf files below.

:> more yesterday.conf
control:
        addclasses      = ( yesterday )

        _day    = ( ExecResult(/bin/sh -c "TZ=${TZ}+24;export TZ;/bin/date +%d") )
        _monnum = ( ExecResult(/bin/sh -c "TZ=${TZ}+24;export TZ;/bin/date +%m") )
        _month  = ( ExecResult(/bin/sh -c "TZ=${TZ}+24;export TZ;/bin/date +%b") )
        _year   = ( ExecResult(/bin/sh -c "TZ=${TZ}+24;export TZ;/bin/date +%Y") )


[:> more registerrotate.conf
classes:
        desthost        = ( app002prod )
        register        = ( web001prod web002prod )
import:
        !yesterday::
                yesterday.conf

control:

        Rfilename       = ( access.$(_day)$(_month)-12AM )

        Rsourcepfx      = ( /var/adm/apache/register-80/logs/access )
        Rsourcepath     = ( "$(Rsourcepfx)/$(_year)/$(_monnum)/$(Rfilename)" )


        Rdestpfx1       = ( /logs/register/web001prod/access )
        Rdestpfx2       = ( /logs/register/web002prod/access )
        Rdestpath1      = ( "$(Rdestpfx1)/$(_year)/$(_monnum)/$(Rfilename)" )
        Rdestpath2      = ( "$(Rdestpfx2)/$(_year)/$(_monnum)/$(Rfilename)" )


        desthost::
                actionsequence  = (
                        copy.registerrotate
                )
        register::
                actionsequence  = (
                        shellcommands.registerrotate
                )

shellcommands:

        registerrotate.Hr02_Q1::
                '/usr/bin/gzip $(Rsourcepath)'

copy:

        registerrotate.Hr03_Q1::
                $(Rsourcepath).gz
                        dest=$(Rdestpath1).gz
                        type=checksum
                        inform=true
                        server=web001prod

                $(Rsourcepath).gz
                        dest=$(Rdestpath2).gz
                        type=checksum
                        inform=true
                        server=web002prod

I run this on the two web servers I harvest logs from, and the collection server I pull them to. I protect the yesterday import because I harvest ~ 10 different sites from a server at one time. All the other conf files look very similar with the macro names changed.

My macro names suck because of name space collision. I haven't figured out a clever way to have the same macro in a template file and not have it collide with other names, although it sounds like name spaces are part of the next cfengine release.

wheeler

-----Original Message-----
From: Julian Simpson [mailto:julian_simpson@yahoo.co.uk]
Sent: Tuesday, February 04, 2003 3:51 PM
To: help-cfengine@gnu.org
Subject: The cfengine way of rotating files?


Hi,

I want to rotate and compress web/app server logfiles on my systems.  I presently use cfengine for tidying directories, disting things like Big Brother, etc.  I am rotating some logs with disable and the rotate=x option, but I don't want numbered logfiles, I want a date.

I think I want to:

- copy the file to file.YYYY-MM-DD.
(okay, I can do that with the copy command if I can work out a way to massage the date to that format)

- cat /dev/null into the original file
(disable: and then rotate=empty)

- compress the copy.
(shell command)

The thing is, I only want the actions to happen if the previous actions completed.  And if I come up with an actionsequence of ( copy disable shellcommands ) and declare all the logfiles in each stanza, how do I do that?

What I want to be able to do is a shell-like:

for file in "/path/to/file1 /path/to/file2"
do
        filenew="$file.`date +%F`"
        cp $file $filenew && \
        >$file && \
        gzip $filenew
done

Is there a way to do this in cfengine, or do I just not grok the cfengine approach?

Best,

Julian.

Julian Simpson
julian@juliansimpson.org
http://juliansimpson.is-a-geek.org

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts http://uk.my.yahoo.com


_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org http://mail.gnu.org/mailman/listinfo/help-cfengine


reply via email to

[Prev in Thread] Current Thread [Next in Thread]