new report on log reviews emailed to user/admin

This commit is contained in:
Fish 2004-11-16 08:19:34 +00:00
parent 199433f0b8
commit 3fd00649de
2 changed files with 78 additions and 0 deletions

1
.gitattributes vendored
View file

@ -111,6 +111,7 @@ html/scripts/php/processlogs.php -text
html/scripts/php/vacuumdb.php -text
html/scripts/php/vacuumtsyslog.php -text
html/scripts/php/weeklyindexrebuild.php -text
html/scripts/php/weeklyreport.php -text
html/smtversion -text
html/template.php -text
html/view.php -text

View file

@ -0,0 +1,77 @@
#!/usr/bin/php -q
<?
define("REPORTADDRESS", "justin@dynam.ac");
/*=============================================================================
* $Id$
*
* Copyright 2004 Justin Hammond jhammond4@csc.com
*
* This is free software; you can redistribute it and/or modify
* it under the terms of version 2 only of the GNU General Public License as
* published by the Free Software Foundation.
*
* It is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
=============================================================================*/
require_once('../../config.php');
$sec_dbsocket=sec_dbconnect();
$REMOTE_ID=sec_usernametoid($sec_dbsocket,'msyslog');
$GROUP_ID=sec_groupnametoid($sec_dbsocket,'Syslog msyslog');
if ( ! sec_groupmember($sec_dbsocket,$REMOTE_ID,$GROUP_ID) ) {
dbdisconnect($sec_dbsocket);
exit;
}
$dbsocket= dbconnect(SMACDB,"msyslog",SMACPASS);
$month=date("M",time());
$day=date("d",time())+1;
$year=date("Y",time());
$endday = date("d", (time()-(86400*7)));
$endtoday="$month-$day-$year";
$startdate="$month-$endday-$year";
$SQLQuery="select tr.reviewer, tr.date as reviewdate, tr.comments, tr.tsummary_id, ts.host, ts.date as reportdate from syslog_treview as tr, syslog_tsummary as ts where tr.tsummary_id=ts.tsummary_id and tr.date >= '$startdate' and tr.date <= '$endtoday' order by ts.host, ts.date";
$SQLQueryResults = pg_exec($dbsocket,$SQLQuery) or
die(pg_errormessage());
$SQLNumRows = pg_numrows($SQLQueryResults);
if ( $SQLNumRows ) {
$hosttext="LogReview Report for Period of $startdate to $endtoday\n";
$id = 0;
for ( $loop = 0 ; $loop != $SQLNumRows ; $loop++ ) {
$SQLQueryResultsObject = pg_fetch_object($SQLQueryResults,$loop) or
die(pg_errormessage()."<BR>\n");
if ($id != $SQLQueryResultsObject->tsummary_id) {
$hosttext .= "\n\n=============================================================\n";
$hosttext .= "System: " .stripslashes(pgdatatrim($SQLQueryResultsObject->host)) . "\n" ;
$hosttext .= "Report Date: ". pgdatatrim($SQLQueryResultsObject->reportdate) ."\n";
$id = $SQLQueryResultsObject->tsummary_id;
$hosttext .= "=============================================================\n";
} else {
$hosttext .= "-------------------------------------------------------------\n";
}
$hosttext .= "Reviewer: ". sec_username($sec_dbsocket, $SQLQueryResultsObject->reviewer);
$hosttext .= " Date: ". $SQLQueryResultsObject->reviewdate. "\n\n";
$hosttext .= stripslashes(pgdatatrim($SQLQueryResultsObject->comments)) ."\n";
}
echo $hosttext;
mail(REPORTADDRESS,"CLF Log Review Report",$hosttext);
} else {
echo "No results\n";
}
pg_freeresult($SQLQueryResults) or
die(pg_errormessage());
dbdisconnect($sec_dbsocket);
dbdisconnect($dbsocket);
?>