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]

 


This message and any attachments are intended only for the use of the addressee 
and
may contain information that is privileged and confidential. If the reader of 
the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.

Reply via email to