|
From: | Julian Simpson |
Subject: | RE: The cfengine way of rotating files? |
Date: | Wed, 5 Feb 2003 21:43:47 -0000 |
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.confcontrol:
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=web002prodI 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
doneIs 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
[Prev in Thread] | Current Thread | [Next in Thread] |