Skip to content

Instantly share code, notes, and snippets.

@joet3ch
Created September 17, 2010 03:48
Show Gist options
  • Save joet3ch/583646 to your computer and use it in GitHub Desktop.
Save joet3ch/583646 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use File::Tail;
my @errors = ('Bad protocol version identification','Failed password','Did not receive identification string');
my $line;
my $file = File::Tail->new("/var/log/everything.log");
while (defined($line=$file->read)) {
if ($line =~ /$errors[0]|$errors[1]|$errors[2]/) {
open(SSHALERT, ">/tmp/sshalert.txt");
print SSHALERT "$line";
#system ('mplayer /etc/scripts/burglar.mp3');
system ('mutt -s ALERT-SSH -c me@yourmomma.com < /tmp/sshalert.txt');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment