Wow, nice tip. I didn't realize Asterisk could use syslog instead of
/var/log/asterisk/
On my box (Gentoo), the app "logrotate" is what does the log rotations for
me, so I simply stuck an extra config file inside /etc/logrotate.d/ for my
various asterisk files. Below is my config, should someone in the group
find this interesting..
-Marc
$ cat /var/logrotate.d/asterisk
#rotate the logs
/var/log/asterisk/event_log /var/log/asterisk/messages
/var/log/asterisk/queue_log {
missingok
rotate 208
create 0640 asterisk asterisk
postrotate
asterisk -rx "logger reload" > /dev/null 2>&1 || true
endscript
}
#rotate the csv cdr(s)
/var/log/asterisk/cdr-csv/*.csv {
missingok
rotate 208
create 0640 asterisk asterisk
}
#rotate the tsv cdr (+ rename!!)
/var/log/asterisk/cdr-custom/Master.txt {
missingok
rotate 208
create 0640 asterisk asterisk
postrotate
mv /var/log/asterisk/cdr-custom/Master.txt.1
/var/log/asterisk/cdr-custom/Master.txt.$(date +%F)
#gzip /var/log/asterisk/cdr-custom/Master.txt.$(date +%F)
endscript
}
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Simon P. Ditner
> Sent: Thursday, January 15, 2009 6:34 AM
> To: asterisk Mailing
> Subject: Re: [on-asterisk] Keeping the messages file clean
>
> If you send your logging to syslog instead, I believe it will
> automatically collapse these sorts of things for you.
>
> Then you configure syslog to write out the asterisk messages to a
> dedicated file, and configure it to also do the log rotation and
> compression.
>
> On Tue, Jan 13, 2009 at 4:56 PM, Jim Van Meggelen
> <[email protected]> wrote:
> > That, Sir, is a thing of beauty!
> >
> > Thanks hugely!
> >
> > Jim
> >
> >
> > McQuiggan, Mark - Broadridge (Toronto) wrote:
> >>
> >> Jim:
> >>
> >>
> >> My two cents...
> >>
> >>
> >> The quick and dirty method on one line, using sed is:
> >>
> >>
> >> sed -e "/file.c: Unexpected control subclass '-1'/d" logfile >
> >> logfile.tmp; mv logfile.tmp logfile
> >>
> >>
> >> This will delete all lines containing the text.
> >>
> >>
> >> Since I don't know how this logfile works, you should stop
> the logging
> >> process before executing this line, and start it after.
> >>
> >>
> >> I would use awk for your ideal method. This is a sample (called
> >> strip.awk):
> >>
> >>
> >> BEGIN { n=0 }
> >>
> >> / file.c: Unexpected control subclass '-1'/ { ++n }
> >>
> >> !/ file.c: Unexpected control subclass '-1'/ { if (n>0) {
> print "file.c:
> >> Unexpected control subclass '-1' appears ",n,"times.";n=0 }
> >>
> >> print $0 }
> >>
> >> END {if (n>0) print "file.c: Unexpected control subclass
> '-1' appears
> >> ",n,"times." }
> >>
> >>
> >> Invoke it as:
> >>
> >> awk -f strip.awk logfile > logfile.tmp; mv logfile.tmp logfile
> >>
> >>
> >> again, stopping the logging first.
> >>
> >>
> >> There are probably lots of ways to do this, and you may
> get differing
> >> opinions, but these seem to work.
> >>
> >>
> >> M.
> >>
> >>
> >> -----Original Message-----
> >>
> >> From: Jim Van Meggelen [mailto:[email protected]]
> >> Sent: Friday, January 09, 2009 5:20 PM
> >>
> >> To: Asterisk Users Group
> >>
> >> Subject: [on-asterisk] Keeping the messages file clean
> >>
> >>
> >> This is perhaps more a linux question than an asterisk
> question, but in
> >> my defense I don't know too many linux programs that will
> happily flood
> >> the messages file the way asterisk does.
> >>
> >>
> >> I have a minor error on a system that doesn't cause any
> problems, but
> >> when it happens it will write about a dozen messages per
> second to the
> >> log file. The error looks like this:
> >>
> >>
> >> Jan 9 12:04:37 WARNING[19760] file.c: Unexpected control
> subclass '-1'
> >>
> >>
> >> What I want to be able to do is run a cron job that'll look for the
> >> error message, and erase it from the log file (ideally I
> guess instead
> >> of erasing it, it would re-write it as one line, with the message
> >> "(occurred x times)" following, but that's quite a bit more fussy).
> >> Everything up to the 'file.c' part is variable, so I guess
> I'd want to
> >> search for lines containing "file.c: Unexpected control
> subclass '-1'",
> >> and put them somewhere else (or just get rid of them).
> >>
> >>
> >> I figure this is very likely a one-liner for somebody who
> knows sed and
> >> regex well-enough, and before I started searching I
> figured I'd ask if
> >> anyone had a util that might be suitable. Seems to be
> something that's
> >> common enough that somebody might have a quick solutino.
> >>
> >>
> >> Thanks in advance for any advice on this one.
> >>
> >>
> >> Jim
> >>
> >>
> >>
> >
> >
> > --
> >
> > --
> > Jim Van Meggelen
> > [email protected]
> > http://www.oreillynet.com/pub/au/2177
> >
> > "A child is the ultimate startup, and I have three. This
> makes me rich."
> > Guy Kawasaki
> > --
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
>
>
> --
> | Network: http://www.linkedin.com/in/spditner
> | http://facebook.com/people/Simon-P-Ditner/776370031
> |
> | It ain't what you don't know that gets you into trouble. It's what
> | you know for sure that just ain't so. -- Mark Twain
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]