mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Fixed bug id #291, custom filters are now taken care in database logstream sources when cleaning up data.
This commit is contained in:
parent
dad3dbc2fe
commit
318b4f7c70
@ -350,6 +350,8 @@ if ( isset($_GET['op']) )
|
|||||||
{
|
{
|
||||||
// Create LogStream Object
|
// Create LogStream Object
|
||||||
$stream = $tmpSource['ObjRef']->LogStreamFactory($tmpSource['ObjRef']);
|
$stream = $tmpSource['ObjRef']->LogStreamFactory($tmpSource['ObjRef']);
|
||||||
|
|
||||||
|
// Verify if datasource is available
|
||||||
$res = $stream->Verify();
|
$res = $stream->Verify();
|
||||||
if ( $res != SUCCESS )
|
if ( $res != SUCCESS )
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,7 @@ abstract class LogStream {
|
|||||||
protected $_current_uId = -1;
|
protected $_current_uId = -1;
|
||||||
protected $_logStreamConfigObj = null;
|
protected $_logStreamConfigObj = null;
|
||||||
protected $_arrProperties = null;
|
protected $_arrProperties = null;
|
||||||
|
protected $_arrFilterProperties = null; // Helper Array to store all detected properties from Filterstring
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the stream for read access.
|
* Open the stream for read access.
|
||||||
@ -619,7 +620,7 @@ abstract class LogStream {
|
|||||||
// Split key and value
|
// Split key and value
|
||||||
$tmpArray = explode(":", $myEntry, 2);
|
$tmpArray = explode(":", $myEntry, 2);
|
||||||
//print_r ( $tmpArray );
|
//print_r ( $tmpArray );
|
||||||
|
|
||||||
// Continue if empty filter!
|
// Continue if empty filter!
|
||||||
if ( strlen(trim($tmpArray[FILTER_TMP_VALUE])) == 0 )
|
if ( strlen(trim($tmpArray[FILTER_TMP_VALUE])) == 0 )
|
||||||
continue;
|
continue;
|
||||||
@ -978,6 +979,10 @@ abstract class LogStream {
|
|||||||
//done!
|
//done!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add to detected filter array
|
||||||
|
if ( $this->_arrFilterProperties == null || !in_array($tmpKeyName, $this->_arrFilterProperties) )
|
||||||
|
$this->_arrFilterProperties[] = $tmpKeyName;
|
||||||
|
|
||||||
// Ignore if unknown filter!
|
// Ignore if unknown filter!
|
||||||
if ( $tmpFilterType != FILTER_TYPE_UNKNOWN )
|
if ( $tmpFilterType != FILTER_TYPE_UNKNOWN )
|
||||||
{
|
{
|
||||||
|
@ -554,14 +554,36 @@ class LogStreamDB extends LogStream {
|
|||||||
// Perform if Connection is true!
|
// Perform if Connection is true!
|
||||||
if ( $this->_dbhandle != null )
|
if ( $this->_dbhandle != null )
|
||||||
{
|
{
|
||||||
// Create WHERE attachment
|
// --- Init Filters if necessary!
|
||||||
|
if ( $this->_filters == null )
|
||||||
|
$this->SetFilter( "" ); // This will init filters!
|
||||||
|
|
||||||
|
// Create SQL Where Clause!
|
||||||
|
$this->CreateSQLWhereClause();
|
||||||
|
// ---
|
||||||
|
|
||||||
|
// --- Add default WHERE clause
|
||||||
|
if ( strlen($this->_SQLwhereClause) > 0 )
|
||||||
|
$szWhere = $this->_SQLwhereClause;
|
||||||
|
else
|
||||||
|
$szWhere = "";
|
||||||
|
|
||||||
|
// Add Datefilter if necessary!
|
||||||
if ( $nDateTimeStamp > 0 )
|
if ( $nDateTimeStamp > 0 )
|
||||||
$szWhere = " WHERE UNIX_TIMESTAMP(" . $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_DATE] . ") < " . $nDateTimeStamp;
|
{
|
||||||
else
|
if ( strlen($szWhere) > 0 )
|
||||||
$szWhere = "";
|
$szWhere .= " AND ";
|
||||||
|
else
|
||||||
|
$szWhere = " WHERE ";
|
||||||
|
|
||||||
|
// Append Date Filter!
|
||||||
|
$szWhere .= " UNIX_TIMESTAMP(" . $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_DATE] . ") < " . $nDateTimeStamp;
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
// DELETE DATA NOW!
|
// DELETE DATA NOW!
|
||||||
$szSql = "DELETE FROM " . $this->_logStreamConfigObj->DBTableName . $szWhere;
|
$szSql = "DELETE FROM " . $this->_logStreamConfigObj->DBTableName . $szWhere;
|
||||||
|
OutputDebugMessage("LogStreamDB|CleanupLogdataByDate: Created SQL Query:<br>" . $szSql, DEBUG_DEBUG);
|
||||||
$myQuery = mysql_query($szSql, $this->_dbhandle);
|
$myQuery = mysql_query($szSql, $this->_dbhandle);
|
||||||
if ($myQuery)
|
if ($myQuery)
|
||||||
{
|
{
|
||||||
@ -956,9 +978,21 @@ class LogStreamDB extends LogStream {
|
|||||||
|
|
||||||
// Reset WhereClause
|
// Reset WhereClause
|
||||||
$this->_SQLwhereClause = "";
|
$this->_SQLwhereClause = "";
|
||||||
|
|
||||||
|
// --- Build Query Array
|
||||||
|
$arrayQueryProperties = $this->_arrProperties;
|
||||||
|
if ( isset($this->_arrFilterProperties) && $this->_arrFilterProperties != null)
|
||||||
|
{
|
||||||
|
foreach ( $this->_arrFilterProperties as $filterproperty )
|
||||||
|
{
|
||||||
|
if ( $this->_arrProperties == null || !in_array($filterproperty, $this->_arrProperties) )
|
||||||
|
$arrayQueryProperties[] = $filterproperty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
// Loop through all available properties
|
// Loop through all available properties
|
||||||
foreach( $this->_arrProperties as $propertyname )
|
foreach( $arrayQueryProperties as $propertyname )
|
||||||
{
|
{
|
||||||
// If the property exists in the filter array, we have something to filter for ^^!
|
// If the property exists in the filter array, we have something to filter for ^^!
|
||||||
if ( array_key_exists($propertyname, $this->_filters) )
|
if ( array_key_exists($propertyname, $this->_filters) )
|
||||||
|
@ -652,14 +652,36 @@ class LogStreamPDO extends LogStream {
|
|||||||
// Perform if Connection is true!
|
// Perform if Connection is true!
|
||||||
if ( $this->_dbhandle != null )
|
if ( $this->_dbhandle != null )
|
||||||
{
|
{
|
||||||
// Create WHERE attachment
|
// --- Init Filters if necessary!
|
||||||
|
if ( $this->_filters == null )
|
||||||
|
$this->SetFilter( "" ); // This will init filters!
|
||||||
|
|
||||||
|
// Create SQL Where Clause!
|
||||||
|
$this->CreateSQLWhereClause();
|
||||||
|
// ---
|
||||||
|
|
||||||
|
// --- Add default WHERE clause
|
||||||
|
if ( strlen($this->_SQLwhereClause) > 0 )
|
||||||
|
$szWhere = $this->_SQLwhereClause;
|
||||||
|
else
|
||||||
|
$szWhere = "";
|
||||||
|
|
||||||
|
// Add Datefilter if necessary!
|
||||||
if ( $nDateTimeStamp > 0 )
|
if ( $nDateTimeStamp > 0 )
|
||||||
$szWhere = " WHERE " . $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_DATE] . " < '" . date('Y-m-d H:i:s', $nDateTimeStamp) . "'";
|
{
|
||||||
else
|
if ( strlen($szWhere) > 0 )
|
||||||
$szWhere = "";
|
$szWhere .= " AND ";
|
||||||
|
else
|
||||||
|
$szWhere = " WHERE ";
|
||||||
|
|
||||||
|
// Append Date Filter!
|
||||||
|
$szWhere .= $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_DATE] . " < '" . date('Y-m-d H:i:s', $nDateTimeStamp) . "'";
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
// DELETE DATA NOW!
|
// DELETE DATA NOW!
|
||||||
$szSql = "DELETE FROM " . $this->_logStreamConfigObj->DBTableName . $szWhere;
|
$szSql = "DELETE FROM " . $this->_logStreamConfigObj->DBTableName . $szWhere;
|
||||||
|
OutputDebugMessage("LogStreamPDO|CleanupLogdataByDate: Created SQL Query:<br>" . $szSql, DEBUG_DEBUG);
|
||||||
$myQuery = $this->_dbhandle->query($szSql);
|
$myQuery = $this->_dbhandle->query($szSql);
|
||||||
if ( $myQuery )
|
if ( $myQuery )
|
||||||
{
|
{
|
||||||
@ -1126,8 +1148,20 @@ class LogStreamPDO extends LogStream {
|
|||||||
// Reset WhereClause
|
// Reset WhereClause
|
||||||
$this->_SQLwhereClause = "";
|
$this->_SQLwhereClause = "";
|
||||||
|
|
||||||
|
// --- Build Query Array
|
||||||
|
$arrayQueryProperties = $this->_arrProperties;
|
||||||
|
if ( isset($this->_arrFilterProperties) && $this->_arrFilterProperties != null)
|
||||||
|
{
|
||||||
|
foreach ( $this->_arrFilterProperties as $filterproperty )
|
||||||
|
{
|
||||||
|
if ( $this->_arrProperties == null || !in_array($filterproperty, $this->_arrProperties) )
|
||||||
|
$arrayQueryProperties[] = $filterproperty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
// Loop through all available properties
|
// Loop through all available properties
|
||||||
foreach( $this->_arrProperties as $propertyname )
|
foreach( $arrayQueryProperties as $propertyname )
|
||||||
{
|
{
|
||||||
// If the property exists in the filter array, we have something to filter for ^^!
|
// If the property exists in the filter array, we have something to filter for ^^!
|
||||||
if ( array_key_exists($propertyname, $this->_filters) )
|
if ( array_key_exists($propertyname, $this->_filters) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user