This is just a scenario i got it in mind, Reporting Warning/Error to Developer(s), using a PERL script, this you can also be done using SHELL Script.
use Net::SMTP;
my $date=`date +%a" "%b" "%d`;
my $warn="Warning:";
my $line1=`cat /var/log/apachelogs/error_log | grep -i 'php warning' | grep '$date' | awk -F'$warn' '{print \$2}' | sort | uniq -c | sed G > /tmp/get-PHP-errors.txt`;
my $line=`cat /tmp/get-PHP-errors.txt`;
my $ServerName = "mail2.mailer.com";
my $RealNameFrom = "PHP Warnings";
my $MailFrom = "noreply\@tech-suppport.com";
my $RealNameTo = "Web Coders";
my $MailTo = "delhi.manish\@gmail.com";
my $MailSubject = "Apache Error Log On Stagging Server";
$smtp = Net::SMTP->new($ServerName);
die "Couldn't connect to server" unless $smtp;
$smtp->mail( $MailFrom );
$smtp->to( $MailTo );
$smtp->data();
$smtp->datasend("To: $RealNameTo <$MailTo>\n");
$smtp->datasend("From: $RealNameFrom <$MailFrom>\n");
$smtp->datasend("Subject: $MailSubject\n\n");
$smtp->datasend("$line");
$smtp->dataend();
$smtp->quit();
No comments:
Post a Comment