diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php index b27c878..147c144 100644 --- a/src/classes/logstream.class.php +++ b/src/classes/logstream.class.php @@ -246,6 +246,12 @@ abstract class LogStream { public abstract function CleanupLogdataByDate( $nDateTimeStamp ); + /* + * Helper function to set the message checksum, this will be used for database based logstream classes only + */ + public abstract function SaveMessageChecksum( $arrProperitesIn ); + + /* * Helper functino to trigger initialisation of MsgParsers */ diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index d54dcf4..a056ffa 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -286,7 +286,7 @@ class LogStreamDB extends LogStream { // Check how long we are running. If only two seconds of execution time are left, we abort further reading! $scriptruntime = intval(microtime_float() - $gl_starttime); - if ( $scriptruntime > ($content['MaxExecutionTime']-2) ) + if ( $content['MaxExecutionTime'] > 0 && $scriptruntime > ($content['MaxExecutionTime']-2) ) { // This may display a warning message, so the user knows we stopped reading records because of the script timeout. $content['logstream_warning'] = "false"; @@ -582,6 +582,40 @@ class LogStreamDB extends LogStream { return $rowcount; } + /* + * Implementation of the SaveMessageChecksum + * + * Creates an database UPDATE Statement and performs it! + */ + public function SaveMessageChecksum( $arrProperitesIn ) + { + global $querycount, $dbmapping; + $szTableType = $this->_logStreamConfigObj->DBTableType; + + if ( isset($arrProperitesIn[SYSLOG_UID]) && isset($arrProperitesIn[MISC_CHECKSUM]) && isset($dbmapping[$szTableType]['DBMAPPINGS'][MISC_CHECKSUM]) ) + { + // DELETE DATA NOW! + $szSql = "UPDATE " . $this->_logStreamConfigObj->DBTableName . + " SET " . $dbmapping[$szTableType]['DBMAPPINGS'][MISC_CHECKSUM] . " = " . $arrProperitesIn[MISC_CHECKSUM] . + " WHERE " . $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_UID] . " = " . $arrProperitesIn[SYSLOG_UID]; + $myQuery = mysql_query($szSql, $this->_dbhandle); + if ($myQuery) + { + // Return success + return SUCCESS; + } + else + { + // error occured, output DEBUG message + $this->PrintDebugError("SaveMessageChecksum failed with SQL Statement ' " . $szSql . " '"); + + // Failed + return ERROR; + } + } + } + + /** * Implementation of ConsolidateItemListByField * diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index 74f3a5f..131a396 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -255,7 +255,7 @@ class LogStreamDisk extends LogStream { // Check how long we are running. If only two seconds of execution time are left, we abort further reading! $scriptruntime = intval(microtime_float() - $gl_starttime); - if ( $scriptruntime > ($content['MaxExecutionTime']-2) ) + if ( $content['MaxExecutionTime'] > 0 && $scriptruntime > ($content['MaxExecutionTime']-2) ) { // This may display a warning message, so the user knows we stopped reading records because of the script timeout. $content['logstream_warning'] = "false"; @@ -639,7 +639,7 @@ class LogStreamDisk extends LogStream { /** * Implementation of the CleanupLogdataByDate * - * not implemented yet! + * not implemented! */ public function CleanupLogdataByDate( $nDateTimeStamp ) { @@ -647,6 +647,16 @@ class LogStreamDisk extends LogStream { return null; } + /* + * Implementation of the SaveMessageChecksum + * + * not implemented! + */ + public function SaveMessageChecksum( $arrProperitesIn ) + { + return SUCCESS; + } + /** * Implementation of ConsolidateItemListByField diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php index 9548524..337c8b1 100644 --- a/src/classes/logstreampdo.class.php +++ b/src/classes/logstreampdo.class.php @@ -333,7 +333,7 @@ class LogStreamPDO extends LogStream { // Check how long we are running. If only two seconds of execution time are left, we abort further reading! $scriptruntime = intval(microtime_float() - $gl_starttime); - if ( $scriptruntime > ($content['MaxExecutionTime']-2) ) + if ( $content['MaxExecutionTime'] > 0 && $scriptruntime > ($content['MaxExecutionTime']-2) ) { // This may display a warning message, so the user knows we stopped reading records because of the script timeout. $content['logstream_warning'] = "false"; diff --git a/src/classes/reports/report.class.php b/src/classes/reports/report.class.php index 8d62038..b7cc873 100644 --- a/src/classes/reports/report.class.php +++ b/src/classes/reports/report.class.php @@ -281,9 +281,6 @@ abstract class Report { // Call report function to init advanced settings! $this->InitAdvancedSettings(); - -// echo "TODO SetCustomFilters"; -// exit; } /* diff --git a/src/classes/reports/report.eventlog.eventsummary.class.php b/src/classes/reports/report.eventlog.eventsummary.class.php index 6fd158f..3fd071e 100644 --- a/src/classes/reports/report.eventlog.eventsummary.class.php +++ b/src/classes/reports/report.eventlog.eventsummary.class.php @@ -212,7 +212,7 @@ class Report_eventsummary extends Report { */ public function InitReport() { - // Nothing todo + // Nothing to do return SUCCESS; } @@ -223,7 +223,7 @@ class Report_eventsummary extends Report { */ public function RemoveReport() { - // Nothing todo + // Nothing to do return SUCCESS; } @@ -336,11 +336,14 @@ class Report_eventsummary extends Report { if ( !isset($logArray[MISC_CHECKSUM]) || $logArray[MISC_CHECKSUM] == 0 ) { // Calc crc32 from message, we use this as index - $logArray[MISC_CHECKSUM] = crc32( $logArray[SYSLOG_MESSAGE] ); + $logArray[MISC_CHECKSUM] = crc32( $logArray[SYSLOG_MESSAGE] ); // Maybe useful somewhere else: sprintf( "%u", crc32 ( $logArray[SYSLOG_MESSAGE] )); $strChecksum = $logArray[MISC_CHECKSUM]; - // TODO, save calculated Checksum into DB! + // Save calculated Checksum into DB! + $this->_streamObj->SaveMessageChecksum($logArray); } + else // Get checksum + $strChecksum = $logArray[MISC_CHECKSUM]; // Check if entry exists in result array if ( isset($content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]) ) diff --git a/src/classes/reports/report.syslog.syslogsummary.class.php b/src/classes/reports/report.syslog.syslogsummary.class.php index ff18884..e40e9e4 100644 --- a/src/classes/reports/report.syslog.syslogsummary.class.php +++ b/src/classes/reports/report.syslog.syslogsummary.class.php @@ -209,7 +209,7 @@ class Report_syslogsummary extends Report { */ public function InitReport() { - // Nothing todo + // Nothing to do return SUCCESS; } @@ -220,7 +220,7 @@ class Report_syslogsummary extends Report { */ public function RemoveReport() { - // Nothing todo + // Nothing to do return SUCCESS; } @@ -333,7 +333,7 @@ class Report_syslogsummary extends Report { if ( !isset($logArray[MISC_CHECKSUM]) || $logArray[MISC_CHECKSUM] == 0 ) { // Calc crc32 from message, we use this as index - $logArray[MISC_CHECKSUM] = crc32( $logArray[SYSLOG_MESSAGE] ); + $logArray[MISC_CHECKSUM] = crc32( $logArray[SYSLOG_MESSAGE] ); // Maybe useful somewhere else: sprintf( "%u", crc32 ( $logArray[SYSLOG_MESSAGE] )); $strChecksum = $logArray[MISC_CHECKSUM]; // TODO, save calculated Checksum into DB! diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 41219d0..fb3f41c 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -594,8 +594,12 @@ function InitRuntimeInformations() // --- Try to extend the script timeout if possible! $iTmp = GetConfigSetting("MiscMaxExecutionTime", 30, CFGLEVEL_GLOBAL); if ( $iTmp != $content['MaxExecutionTime'] && $iTmp > 10 ) - { //Try to extend the runtime in this case! - @ini_set("max_execution_time", $iTmp); + { + //Try to extend the runtime in this case! + if ( !isset($content['IN_PHPLOGCON_COMMANDLINE']) ) + @ini_set("max_execution_time", $iTmp); + + // Get ini setting $content['MaxExecutionTime'] = ini_get("max_execution_time"); } // --- @@ -1431,7 +1435,7 @@ function ReverseResolveIP( $szIP, $prepend, $append ) // Substract 5 seconds we need to finish processing! $scriptruntime = intval(microtime_float() - $gl_starttime); - if ( $scriptruntime > ($content['MaxExecutionTime']-5) ) + if ( $content['MaxExecutionTime'] > 0 && $scriptruntime > ($content['MaxExecutionTime']-5) ) return ""; // Abort if these IP's are postet