if you like to sit there and tail your mainlog for fun, try adding a bit o
colour :)
thought i'd contribute this, as i find it quite useful
<<eximtail.txt>>
original is from:
http://www.blemished.net/tailc.html
#!/usr/bin/perl
#
# Prints lines from $logfile in colour according to
# matches you define in %cfg
#
# Usage: tailc <# lines back in log to display (default=5)>
#
#
http://www.blemished.net/tailc.html
# supermike@???
#
$logfile='/var/log/exim/mainlog';
%cfg = (
'005|SMTP connection from \[10\.10\.1\.1\]' => 'ignore',
'006|SMTP connection from .* lost$' => 'PURPLE-INV',
'007|SMTP connection from ' => 'PURPLE',
'010|P=smtp' => 'GREEN',
'020|P=esmtp' => 'GREEN-BOLD',
'025| mailbox is full' => 'RED-bCYAN-BOLD',
'030|T=local_delivery' => 'YELLOW',
'040|R=hubbed_hosts' => 'CYAN',
'050|T=remote_smtp H' => 'CYAN-BOLD',
'060| Completed$' => 'GREEN',
'070| Spool file is locked' => 'RED',
'080| retry time not reached' => 'PURPLE-BOLD',
'090| [Ff]rozen' => 'RED',
'100| Connection timed out' => 'RED-INV',
'101| SMTP command timeout on connection from' => 'RED-INV',
'102| SMTP data timeout' => 'RED-INV',
'105| unknown local-part' => 'RED',
'110| Error message sent to' => 'RED-BOLD',
'120| unrouteable mail domain' => 'RED-UL',
'130|P=local' => 'GREEN-INV',
'140|removed by root' => 'PURPLE-INV',
'150|host lookup did not complete' => 'RED',
'160|retry timeout exceeded' => 'RED-INV',
'170|Connection refused' => 'YELLOW-bRED',
'175|closed connection after initial connection' => 'YELLOW-bRED',
'180|Connection reset by peer' => 'YELLOW-bRED',
'190|SMTP error from remote mailer' => 'BLUE-bYELLOW-BOLD',
'200|in RBL list at' => 'BLUE-bRED-BOLD',
'205|recipients refused from' => 'CYAN-bRED-BOLD',
'210|unexpected disconnection while reading' => 'RED-BOLD',
'220|no immediate delivery:' => 'YELLOW-bBLUE',
'230| refused relay ' => 'BLUE-bYELLOW',
'240| verify failed for SMTP recipient' => 'RED-bYELLOW-BOLD',
'250| unqualified sender rejected:' => 'RED-INV-BOLD',
);
%col = (
BEEP => '?',
BOLD => "\033[01m",
UL => "\033[02m",
INV => "\033[03m",
RED => "\033[31m",
GREEN => "\033[32m",
YELLOW => "\033[33m",
BLUE => "\033[34m",
PURPLE => "\033[35m",
CYAN => "\033[36m",
WHITE => "\033[37m",
bRED => "\033[41m",
bGREEN => "\033[42m",
bYELLOW => "\033[43m",
bBLUE => "\033[44m",
bPURPLE => "\033[45m",
bCYAN => "\033[46m",
bWHITE => "\033[47m",
ignore => 0,
);
$back = $ARGV[0] ? $ARGV[0] : 5;
$os = `/bin/uname`;
if ($os == 'SunOS') {
open(LOG, "tail -${back}f $logfile|") || die "Error opening $logfile: $!\n";
} else {
open(LOG, "tail -n $back -f $logfile|") || die "Error opening $logfile: $!\n";
}
$def = "\033[0m"; # default colour
while (defined($line=<LOG>)) {
chomp $line;
$esc = $def;
foreach $string (sort keys %cfg) {
$str = $string; $str =~ s/^\d+\|//;
if ($line =~ /$str/) {
@clr = split(/-/, $cfg{$string});
undef $esc;
foreach $c (@clr) { $esc .= $col{$c}; };
last;
}
}
print "$esc$line$def\n" if $esc;
}