mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 03:09:21 +02:00
Added support to save checksums of messages in database logstream classes
This commit is contained in:
parent
c501247211
commit
5d0b3255ee
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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";
|
||||
|
@ -281,9 +281,6 @@ abstract class Report {
|
||||
|
||||
// Call report function to init advanced settings!
|
||||
$this->InitAdvancedSettings();
|
||||
|
||||
// echo "TODO SetCustomFilters";
|
||||
// exit;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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 ]) )
|
||||
|
@ -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!
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user