All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

mailphperrors 1.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use English;
use Getopt::Std;
use POSIX qw(strftime);

#
# Mail the daily contents of the php errors log to tbops to annoy us,
# and maybe even fix them. This should be run from cron just after
# midnight.  Note that I am not rolling the log, except by hand. Once
# things get settled, the php errors log should not get very big.
#
# Oh, only at emulab,net; no reason for external sites to run this, and
# so I did not bother to configure or install it (do it by hand).
#

#
# Configure variables
#
my $TB		= "/usr/testbed";
my $TBOPS       = "testbed-ops\@flux.utah.edu";
my $PHPLOG      = "/usr/testbed/log/php-errors.log";
my $EGREP       = "/usr/bin/egrep";
my $FGREP       = "/usr/bin/fgrep";
my $TMPFILE     = "/tmp/phperrors.$$";
my $ERRFILE     = "/tmp/greperror.$$";

use lib '/usr/testbed/lib';
use libtestbed;

#
# This script will run a little after midnight, so back up a bit to
# get the previous day logs. 
#
my ($sec,$min,$hours) = localtime();

my $stamp = POSIX::strftime("%d-%b-%G",
			    localtime(time() - (100 + $sec + (60 * $min) +
						(3600 * $hours))));

#
# egrep the file for the above stamp.
#
system("$EGREP '^\\[$stamp' $PHPLOG 2>${ERRFILE} | ".
50
       "$FGREP -v -i openssl | ".
51 52
       "$FGREP -v 'in /usr/testbed/devel/' | " .
       "$FGREP -v 'in /usr/testbed/www/dev/' > $TMPFILE 2>&1");
53 54 55 56 57 58 59 60 61 62 63 64 65 66

if (-s $ERRFILE) {
    SENDMAIL($TBOPS, "Failed to parse PHP error log",
	     "Failed to parse $PHPLOG for errors: $?",
	     $TBOPS, undef, $ERRFILE);
}
if (-s $TMPFILE) {
    SENDMAIL($TBOPS, "PHP Errors for $stamp",
	     "Yesterday's PHP errors:",
	     $TBOPS, undef, $TMPFILE);
}
unlink($TMPFILE);
unlink($ERRFILE);
exit(0);