#!/usr/bin/perl $logfile = "/var/log/syslog"; $hostname = "muse.yi.org"; $ssh = "sshd"; $ftp = "proftpd"; $telnet = "telnetd"; $pam = "PAM_pwdb"; $anacron = "anacron"; open(output, "$logfile"); $fsize = check_size(); $goon = true; main_loop(); sub main_loop { while($goon eq true) { $nsize = check_size(); if($nsize > $fsize) { seek output, $fsize, 0; $buf_length = $nsize-$fsize; read output, $data, $buf_length; $data =~ s/$hostname//; @arglines = split("\n",$data); foreach $data (@arglines) { @args = split(" ", $data); $argc = @args; $date = "@args[0..1]"; $time = "$args[2]"; $action = "@args[4..$argc]"; $i = 0; foreach $arg (@args) { if($arg =~ $ssh) { $action = "SSH"; $info = "@args[$i+1..$argc]";} if($arg =~ $ftp) { $action = "FTP"; $info = "@args[$i+1..$argc]";} if($arg =~ $telnet) { $action = "TELNET"; $info = "@args[$i+1..$argc]";} if($arg =~ $pam) { $action = "PAM_pwdb"; $info = "@args[$i+1..$argc]";} if($arg =~ $anacron) { $action = "ANACRON"; $info = "@args[$i+1..$argc]";} if($arg =~ "warning:") { $warning = "@args[$i+1..$argc]"; } $i++; } $line = "\033[32;1m[$date]\033[33;1m [$time]\033[35;1m [$action] \033[36;1m $info \033[0m\n"; if($warning) { $line = "\033[32;1m[$date]\033[33;1m [$time]\033[35;1m [$action] \033[31;1m $info \033[0m\n"; } print "$line"; undef $warning; } $fsize = $nsize; } else { $fsize = $nsize; } sleep 1; } } sub check_size { $size = -s output; return $size; } sub exit { close(output); exit 0; }