Re: Tailing logs

2008-08-27 Thread Paul Chvostek

On Fri, Aug 22, 2008 at 10:28:33AM -0400, DAve wrote:

 I would love to have a way to tail a log, like piping to grep, except I
 see every line and the lines I would normally grep for are highlighted.
 That would be cool. Anyone know of a bash command or tool that will do this?

I use tcsh as my shell.  The following alias works nicely for me in
xterm, but would have to be adjusted for anything else:

  alias highlight 'sed -E '\''s/\!:*/^[[1m^[[0m/g'\'''

Replace ^[ with an escape character, twice.  Put it in your .tcshrc if
you like.  YMMV.

 Side note, I am tailing sendmail after changes to my outbound queue
 runners. I want to highlight my sm-mta-out lines but still see all lines.

Right, I do very similar stuff.  You'd use this like:

  tail -F /var/log/maillog | highlight .*sm-mta-out.*

Quotes seem to confound this alias.  I haven't bothered to fix that; as
long as what you're searching for doesn't glob a file, you should be
fine without quotes.

You can also do more complex things in either sed or awk, colour-coding
individual pattern matches.  Here's one in awk that I use to highlight
the activity of milter-greylist:

  #!/usr/bin/awk -f
  BEGIN {
red=^[[31m; green=^[[32m;
yellow=^[[33m;  blue=^[[34m;
norm=^[[0m;
fmt=%s%s%s\n;
  }
  /autowhitelisted/ { printf(fmt, green, $0, norm); next; }
  /delayed for/ { printf(fmt, yellow, $0, norm); next; }
  # /skipping greylist/ { printf(fmt, blue, $0, norm); next; }
  { print; }

Same deal with the ^[.

Enjoy.

p

-- 
  Paul Chvostek [EMAIL PROTECTED]
  it.canadahttp://www.it.ca/

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-23 Thread Chuck Robey

DAve wrote:

DAve wrote:
I would love to have a way to tail a log, like piping to grep, except 
I see every line and the lines I would normally grep for are 
highlighted. That would be cool. Anyone know of a bash command or 
tool that will do this?


Side note, I am tailing sendmail after changes to my outbound queue 
runners. I want to highlight my sm-mta-out lines but still see all 
lines.


DAve


Thank you all, I got what I needed!

DAve

I do this commonly to catch the lines with the  word Building in them, 
from a file build.out:


tail -F build.out | grep --color=always Building


When I get a free moment, I need to see about making that --color-always 
the default.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-23 Thread George Davidovich
On Sat, Aug 23, 2008 at 11:07:59AM -0400, Chuck Robey wrote:
 DAve wrote:
  DAve wrote:
  
 I do this commonly to catch the lines with the  word Building in them,
 from a file build.out:
 
 tail -F build.out | grep --color=always Building
 
 When I get a free moment, I need to see about making that --color-always
 the default.

Grep provides for a number of environmental variables, the above being
one of them.  For example:

export GREP_COLOR='0;32'
export GREP_OPTIONS='--color=auto'

Perfectly acceptable for regular use, but especially useful to test
pattern matching before finalising that script you're working on.

-- 
George
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-23 Thread Noel Jones
On Sat, Aug 23, 2008 at 10:07 AM, Chuck Robey [EMAIL PROTECTED] wrote:

 DAve wrote:

 DAve wrote:

 I would love to have a way to tail a log, like piping to grep, except I
 see every line and the lines I would normally grep for are highlighted. That
 would be cool. Anyone know of a bash command or tool that will do this?

 Side note, I am tailing sendmail after changes to my outbound queue
 runners. I want to highlight my sm-mta-out lines but still see all lines.

 DAve


 Thank you all, I got what I needed!

 DAve

  I do this commonly to catch the lines with the  word Building in them,
 from a file build.out:

 tail -F build.out | grep --color=always Building


 When I get a free moment, I need to see about making that --color-always
 the default.
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 [EMAIL PROTECTED]



Look at ports/sysutils/multitail

-- 
Noel Jones
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Tailing logs

2008-08-22 Thread DAve
I would love to have a way to tail a log, like piping to grep, except I 
see every line and the lines I would normally grep for are highlighted. 
That would be cool. Anyone know of a bash command or tool that will do this?


Side note, I am tailing sendmail after changes to my outbound queue 
runners. I want to highlight my sm-mta-out lines but still see all lines.


DAve
--
Don't tell me I'm driving the cart!
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-22 Thread Jon Radel
DAve wrote:
 
 I would love to have a way to tail a log, like piping to grep, except I
 see every line and the lines I would normally grep for are highlighted.
 That would be cool. Anyone know of a bash command or tool that will do
 this?
 
 Side note, I am tailing sendmail after changes to my outbound queue
 runners. I want to highlight my sm-mta-out lines but still see all lines.


less logfile
/string you care about, regex works
F


If you do a search a file in less and then start tailing the file inside
less, it continues to highlight all matches for your last search.  While
I'm sure there are other ways of achieving this, this is the one I use
on a regular basis.

--Jon Radel


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Tailing logs

2008-08-22 Thread Vincent Hoffman
DAve wrote:
 I would love to have a way to tail a log, like piping to grep, except
 I see every line and the lines I would normally grep for are
 highlighted. That would be cool. Anyone know of a bash command or tool
 that will do this?

 Side note, I am tailing sendmail after changes to my outbound queue
 runners. I want to highlight my sm-mta-out lines but still see all lines.

 DAve
If you dont mind installing a few perl modules, try textproc/p5-ack
then just tail -f /var/log/LOGNAME | ack --color --passthru STRING



Vince


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-22 Thread Steve Bertrand

DAve wrote:
I would love to have a way to tail a log, like piping to grep, except I 
see every line and the lines I would normally grep for are highlighted. 
That would be cool. Anyone know of a bash command or tool that will do 
this?


Side note, I am tailing sendmail after changes to my outbound queue 
runners. I want to highlight my sm-mta-out lines but still see all lines.


A little late to the party now, but the following Perl script will 
'highlight' the lines containing $pattern with a blank line above and 
below, surrounded by . The lines not matching will be printed 
normally. Note, File::Tail must be installed:


#!/usr/bin/perl
# grep.pl

use warnings;
use strict;
use File::Tail;

my $pattern = submission;
my $log = /var/log/maillog;
my $ref=tie *FH,File::Tail,(name=$log, maxinterval=3);

while (FH) {

if ($_ =~ /$pattern/) {
chop ($_);
print \n $_ \n\n;
} else {
print $_;
}
}


pearl# ./grep.pl

 Aug 22 11:30:45 pearl vpopmail[65893]: vchkpw-submission: 
(CRAM-MD5) login 
 success [EMAIL PROTECTED]:2607_f118__5 


Aug 22 11:31:19 pearl spamd[32860]: spamd: connection from localhost 
[127.0.0.1] 
at port 57092
Aug 22 11:31:19 pearl spamd[32860]: spamd: processing message 
6e3e383b080822071 
  [EMAIL PROTECTED] for 
[EMAIL PROTECTED]:58



 Aug 22 11:31:46 pearl vpopmail[66048]: vchkpw-submission: 
(CRAM-MD5) login success [EMAIL PROTECTED]:2607_f118__5 


Aug 22 11:31:56 pearl spamd[95770]: prefork: child states: II

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-22 Thread Oliver Fromme
DAve  wrote:
  I would love to have a way to tail a log, like piping to grep, except I 
  see every line and the lines I would normally grep for are highlighted. 
  That would be cool. Anyone know of a bash command or tool that will do this?
  
  Side note, I am tailing sendmail after changes to my outbound queue 
  runners. I want to highlight my sm-mta-out lines but still see all lines.

You could use this script:

http://www.secnetix.de/olli/scripts/bold

It's a filter that works like similar to grep, but it
highlights the parts that match your regular expression.
The script contains usage information.

So you can do things like this:

$ tail -f /var/log/maillog | bold -l myhost.mydomain

(The -l option specifies to highlight the whole line,
not just the part that matches.)

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

C++ is over-complicated nonsense. And Bjorn Shoestrap's book
a danger to public health. I tried reading it once, I was in
recovery for months.
-- Cliff Sarginson
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tailing logs

2008-08-22 Thread DAve

DAve wrote:
I would love to have a way to tail a log, like piping to grep, except I 
see every line and the lines I would normally grep for are highlighted. 
That would be cool. Anyone know of a bash command or tool that will do 
this?


Side note, I am tailing sendmail after changes to my outbound queue 
runners. I want to highlight my sm-mta-out lines but still see all lines.


DAve


Thank you all, I got what I needed!

DAve

--
Don't tell me I'm driving the cart!
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]