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]