Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
auth.debug /syslog/auth.log rotate size 20000k files 10
#!/usr/opt/perl5/bin/perl -w
######################################################################
# SCRIPT NAME : /usr/local/bin/syslog.pl #
######################################################################
use Time::localtime;
use FileHandle;
use File::stat;
$syslog="/syslog/auth.log";
$log="/tmp/auth.out";
$|=1;
$subject="-subject AUTH syslog Event";
open(GWFILE, "< $syslog") or die "can't open $syslog: $!";
open(LOG, ">> $log") or die "can't open $log: $!";
LOG->autoflush(1);
### Seek to end of file ###
seek(GWFILE, 0, 2);
$prev_size=0;
### Do Forever ###
for (;;) {
### EXIT IF MORE THAN ONE COPY IS RUNNING ###
$running=GetPsefData('/usr/local/bin/$0');
exit if ($running > 1);
$sb = stat($syslog);
$size=$sb->size;
if ( $size < $prev_size) {
close(GWFILE);
open(GWFILE, "< $syslog") or die "can't open $syslog: $!";
} else {
$prev_size=$size;
}
### For each new record ###
for ($curpos = tell(GWFILE); <GWFILE>; $curpos = tell(GWFILE)) {
$MSG=$_;
chomp($MSG) if (defined $MSG) ;
if ($MSG=~/Login restricted/i ||
# $MSG=~/Invalid user/i ||
# $MSG=~/Software caused connection abort/i ||
# $MSG=~/chan_read_failed/i ||
# $MSG=~/failed login attempt/i ||
# $MSG=~/Did not receive/i ||
$MSG=~/UNKNOWN_USER/i ||
$MSG=~/BREAK-IN/i ||
$MSG=~/BAD SU/i ||
$MSG=~/Authentication refused/i ||
$MSG=~/No space left on device/i ||
$MSG=~/encrypted password is invalid/i ||
$MSG=~/rexec/i ||
$MSG=~/not enough memory/i ||
$MSG=~/Bad protocol/i ||
$MSG=~/illegal port/i ||
$MSG=~/illegal user/i ||
$MSG=~/Failed dlopen/i ||
$MSG=~/rlogind/i ) {
&SendEmail;
&SendPage if ($MSG=~/Login restricted/i );
} else {
next;
}
}
seek(GWFILE, $curpos, 0); # seek to where we had been
sleep 2;
}
################################################################################
### END ########################################################################
################################################################################
### CHECK IF RUNNING ######################################
sub GetPsefData { #########################################
###########################################################
open(PSEF_PIPE,"ps -ef|");
my($process)=@_;
my($i)=0;
while (<PSEF_PIPE>) {
next unless($_=~/$process/);
chomp;
$i++;
}
close(PSEF_PIPE);
return $i;
}
### SEND EMAIL ############################################
sub SendEmail { ###########################################
###########################################################
print LOG "EMAIL: $MSG\n";
`<your email command here> -m "$MSG" $subject`;
return;
}
### SEND PAGE #############################################
sub SendPage { ############################################
###########################################################
print LOG "PAGE: $MSG\n";
`<your paging command here> -m "$MSG"`;
return;
}