mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Syslog report: Moved Event Count Row to left
Enhanced Syslog report generation performance. Needed some changes in the basic report class.
This commit is contained in:
parent
0ca9204246
commit
9b95b35c81
@ -207,7 +207,7 @@ abstract class LogStream {
|
||||
*
|
||||
* @return integer Error stat
|
||||
*/
|
||||
public abstract function ConsolidateDataByField($szConsFieldId, $nRecordLimit, $szSortFieldId, $nSortingOrder, $bIncludeLogStreamFields = false);
|
||||
public abstract function ConsolidateDataByField($szConsFieldId, $nRecordLimit, $szSortFieldId, $nSortingOrder, $bIncludeLogStreamFields = false, $bIncludeMinMaxDateFields = false);
|
||||
|
||||
|
||||
/**
|
||||
@ -252,6 +252,11 @@ abstract class LogStream {
|
||||
public abstract function SaveMessageChecksum( $arrProperitesIn );
|
||||
|
||||
|
||||
/*
|
||||
* Helper function for logstream classes to clear filter based stuff
|
||||
*/
|
||||
public abstract function ResetFilters( );
|
||||
|
||||
/*
|
||||
* Helper functino to trigger initialisation of MsgParsers
|
||||
*/
|
||||
@ -276,6 +281,9 @@ abstract class LogStream {
|
||||
|
||||
OutputDebugMessage("SetFilter combined = '" . $finalfilters . "'. ", DEBUG_DEBUG);
|
||||
|
||||
// Reset Filters first to make sure we do not add multiple filters!
|
||||
$this->_filters = null;
|
||||
|
||||
// Parse Filters from string
|
||||
$this->ParseFilters($finalfilters);
|
||||
|
||||
@ -585,6 +593,23 @@ abstract class LogStream {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to get the internal Field ID by database field name!
|
||||
*/
|
||||
public function GetFieldIDbyDatabaseMapping($szTableType, $szFieldName)
|
||||
{
|
||||
global $content, $dbmapping;
|
||||
|
||||
foreach( $dbmapping[$szTableType]['DBMAPPINGS'] as $myFieldID => $myDBMapping )
|
||||
{
|
||||
if ( $myDBMapping == $szFieldName )
|
||||
return $myFieldID;
|
||||
}
|
||||
|
||||
// Default return!
|
||||
return $szFieldName;
|
||||
}
|
||||
|
||||
/*
|
||||
* --- PIRVATE HELPERS!
|
||||
*/
|
||||
@ -1182,7 +1207,5 @@ abstract class LogStream {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -112,6 +112,15 @@ class LogStreamDB extends LogStream {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to clear the current querystring!
|
||||
*/
|
||||
public function ResetFilters()
|
||||
{
|
||||
// Clear _SQLwhereClause variable!
|
||||
$this->_SQLwhereClause = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the database connection.
|
||||
*
|
||||
@ -744,7 +753,7 @@ class LogStreamDB extends LogStream {
|
||||
*
|
||||
* @return integer Error stat
|
||||
*/
|
||||
public function ConsolidateDataByField($szConsFieldId, $nRecordLimit, $szSortFieldId, $nSortingOrder, $aIncludeCustomFields = null, $bIncludeLogStreamFields = false)
|
||||
public function ConsolidateDataByField($szConsFieldId, $nRecordLimit, $szSortFieldId, $nSortingOrder, $aIncludeCustomFields = null, $bIncludeLogStreamFields = false, $bIncludeMinMaxDateFields = false)
|
||||
{
|
||||
global $content, $dbmapping, $fields;
|
||||
|
||||
@ -794,6 +803,13 @@ class LogStreamDB extends LogStream {
|
||||
else // Only Include ConsolidateField
|
||||
$myDBQueryFields = $myDBConsFieldName . ", ";
|
||||
|
||||
// Add Min and Max fields for DATE if desired
|
||||
if ( $bIncludeMinMaxDateFields )
|
||||
{
|
||||
$myDBQueryFields .= "Min(" . $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_DATE] . ") as FirstOccurrence_Date, ";
|
||||
$myDBQueryFields .= "Max(" . $dbmapping[$szTableType]['DBMAPPINGS'][SYSLOG_DATE] . ") as LastOccurrence_Date, ";
|
||||
}
|
||||
|
||||
if ( $szConsFieldId == $szSortFieldId )
|
||||
$myDBSortedFieldName = "ItemCount";
|
||||
else
|
||||
@ -815,7 +831,7 @@ class LogStreamDB extends LogStream {
|
||||
$szLimitSql = "";
|
||||
|
||||
// Create SQL Where Clause!
|
||||
if ( $this->_SQLwhereClause == "" )
|
||||
if ( strlen($this->_SQLwhereClause) <= 0 )
|
||||
{
|
||||
$res = $this->CreateSQLWhereClause();
|
||||
if ( $res != SUCCESS )
|
||||
@ -832,6 +848,9 @@ class LogStreamDB extends LogStream {
|
||||
" ORDER BY " . $myDBSortedFieldName . " " . $szSortingOrder .
|
||||
$szLimitSql ;
|
||||
|
||||
// Output Debug Informations
|
||||
OutputDebugMessage("LogStreamDB|ConsolidateDataByField: Running Created SQL Query:<br>" . $szSql, DEBUG_DEBUG);
|
||||
|
||||
// Perform Database Query
|
||||
$myquery = mysql_query($szSql, $this->_dbhandle);
|
||||
if ( !$myquery )
|
||||
@ -848,12 +867,17 @@ class LogStreamDB extends LogStream {
|
||||
|
||||
foreach ( $myRow as $myFieldName => $myFieldValue )
|
||||
{
|
||||
if ( $myFieldName == $dbmapping[$szTableType]['DBMAPPINGS'][$szConsFieldId] )
|
||||
$myFieldID = $this->GetFieldIDbyDatabaseMapping($szTableType, $myFieldName);
|
||||
$aNewRow[ $myFieldID ] = $myFieldValue;
|
||||
|
||||
/* if ( $myFieldName == $dbmapping[$szTableType]['DBMAPPINGS'][$szConsFieldId] )
|
||||
$aNewRow[$szConsFieldId] = $myFieldValue;
|
||||
else
|
||||
{
|
||||
$aNewRow[$myFieldName] = $myFieldValue;
|
||||
*/
|
||||
// }
|
||||
}
|
||||
|
||||
// Add new row to result
|
||||
$aResult[] = $aNewRow;
|
||||
}
|
||||
@ -865,7 +889,6 @@ class LogStreamDB extends LogStream {
|
||||
return ERROR_NOMORERECORDS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of GetCountSortedByField
|
||||
*
|
||||
@ -939,6 +962,7 @@ class LogStreamDB extends LogStream {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ============= Beginn of private functions =============
|
||||
*/
|
||||
|
@ -293,15 +293,55 @@ class Report_syslogsummary extends Report {
|
||||
*/
|
||||
private function ConsolidateSyslogmessagesPerHost( $arrHosts )
|
||||
{
|
||||
global $content, $gl_starttime;
|
||||
global $content, $gl_starttime, $fields;
|
||||
|
||||
// Now open the stream for data processing
|
||||
$res = $this->_streamObj->Open( $this->_arrProperties, true );
|
||||
if ( $res == SUCCESS )
|
||||
{
|
||||
// Set reading direction
|
||||
// $this->_streamObj->SetReadDirection( EnumReadDirection::Backward );
|
||||
if ( true )
|
||||
{
|
||||
// --- New Method to consolidate data!
|
||||
// TimeStats
|
||||
$nowtime = microtime_float();
|
||||
$content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s ";
|
||||
|
||||
foreach ( $arrHosts as $myHost )
|
||||
{
|
||||
// Set custom filters
|
||||
$this->_streamObj->ResetFilters();
|
||||
$this->_streamObj->SetFilter( $this->_filterString . " " . $fields[SYSLOG_MESSAGETYPE]['SearchField'] . ":=" . IUT_Syslog . " " . $fields[SYSLOG_HOST]['SearchField'] . ":=" . $myHost );
|
||||
|
||||
// Set Host Item Basics if not set yet
|
||||
$content["report_consdata"][ $myHost ][SYSLOG_HOST] = $myHost;
|
||||
|
||||
// Get Data for single host
|
||||
$content["report_consdata"][ $myHost ]['cons_msgs'] = $this->_streamObj->ConsolidateDataByField( MISC_CHECKSUM, $this->_maxMsgsPerHost, MISC_CHECKSUM, SORTING_ORDER_DESC, null, true, true );
|
||||
|
||||
//print_r ($fields[SYSLOG_MESSAGE]);
|
||||
foreach ( $content["report_consdata"][ $myHost ]['cons_msgs'] as &$myConsData )
|
||||
{
|
||||
// Set Basic data entries
|
||||
if (!isset( $content['filter_facility_list'][$myConsData[SYSLOG_FACILITY]] ))
|
||||
$myConsData[SYSLOG_FACILITY] = SYSLOG_LOCAL0; // Set default in this case
|
||||
if (!isset( $content['filter_severity_list'][$myConsData[SYSLOG_SEVERITY]] ))
|
||||
$myConsData[SYSLOG_SEVERITY] = SYSLOG_NOTICE; // Set default in this case
|
||||
|
||||
// Set Counter and First/Last Event date
|
||||
$myConsData['FirstOccurrence_Date'] = $myConsData[SYSLOG_DATE];
|
||||
$myConsData['LastOccurrence_Date'] = $myConsData[SYSLOG_DATE];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TimeStats
|
||||
$nowtime = microtime_float();
|
||||
$content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s ";
|
||||
// ---
|
||||
}
|
||||
else
|
||||
{
|
||||
// --- Old Method!
|
||||
// Init uid helper
|
||||
$uID = UID_UNKNOWN;
|
||||
|
||||
@ -384,8 +424,13 @@ class Report_syslogsummary extends Report {
|
||||
// TimeStats
|
||||
$nowtime = microtime_float();
|
||||
$content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s ";
|
||||
}
|
||||
else
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Start Postprocessing
|
||||
|
||||
// --- Start Postprocessing
|
||||
foreach( $content["report_consdata"] as &$tmpConsolidatedComputer )
|
||||
{
|
||||
// First use callback function to sort array
|
||||
@ -432,9 +477,7 @@ class Report_syslogsummary extends Report {
|
||||
$tmpMyEvent['syslogfacility_bgcolor'] = $this->GetSeverityBGColor($tmpMyEvent['syslogfacility']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return $ret;
|
||||
// ---
|
||||
}
|
||||
|
||||
// Work done!
|
||||
|
@ -95,30 +95,29 @@
|
||||
<table width="100%" cellpadding="0" cellspacing="1" border="0" align="center" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" align="center" width="50" nowrap>{ln_report_number}</td>
|
||||
<td class="cellmenu1" align="center" width="50" nowrap>{ln_report_count}</td>
|
||||
<td class="cellmenu1" align="center" width="100" nowrap>{ln_report_firstoccurrence}</td>
|
||||
<td class="cellmenu1" align="center" width="100" nowrap>{ln_report_lastoccurrence}</td>
|
||||
<td class="cellmenu1" align="center" width="100" nowrap>{ln_report_severity}</td>
|
||||
<td class="cellmenu1" align="center" width="150" nowrap>{ln_report_facility}</td>
|
||||
<td class="cellmenu1" align="center" width="80" nowrap>{ln_report_syslogtag}</td>
|
||||
<td class="cellmenu1" align="center" width="100%" nowrap>{ln_report_description}</td>
|
||||
<td class="cellmenu1" align="center" width="50" nowrap>{ln_report_count}</td>
|
||||
</tr>
|
||||
<!-- BEGIN cons_msgs -->
|
||||
<tr>
|
||||
<td class="line1" valign="top" align="center">{ZAEHLER}</td>
|
||||
<td class="line1" valign="top" align="center">{FirstOccurrence_Date_Formatted}</td>
|
||||
<td class="line1" valign="top" align="center">{LastOccurrence_Date_Formatted}</td>
|
||||
<td class="lineColouredWhite" valign="top" align="center" bgcolor="{syslogseverity_bgcolor}"><b>{syslogseverity_text}</b></td>
|
||||
<td class="lineColouredWhite" valign="top" align="center" bgcolor="{syslogfacility_bgcolor}"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogfacility&q={syslogfacility_text}" target="_blank">{syslogfacility_text}</a></td>
|
||||
<td class="line1" valign="top" align="center"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogtag&q={syslogtag}" target="_blank">{syslogtag}</a></td>
|
||||
<td class="line1" valign="top" align="left">{msg}</td>
|
||||
<!-- IF ItemCount>=$_colorThreshold -->
|
||||
<td class="lineColouredWhite" valign="top" align="right" bgcolor="#990000"><b>{ItemCount}</b></td>
|
||||
<!-- ENDIF ItemCount>=$_colorThreshold -->
|
||||
<!-- IF ItemCount<$_colorThreshold -->
|
||||
<td class="lineColouredWhite" valign="top" align="right" bgcolor="#AAAAAA"><b>{ItemCount}</b></td>
|
||||
<!-- ENDIF ItemCount<$_colorThreshold -->
|
||||
|
||||
<td class="line1" valign="top" align="center">{FirstOccurrence_Date_Formatted}</td>
|
||||
<td class="line1" valign="top" align="center">{LastOccurrence_Date_Formatted}</td>
|
||||
<td class="lineColouredWhite" valign="top" align="center" bgcolor="{syslogseverity_bgcolor}"><b>{syslogseverity_text}</b></td>
|
||||
<td class="lineColouredWhite" valign="top" align="center" bgcolor="{syslogfacility_bgcolor}"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogfacility&q={syslogfacility_text}" target="_blank">{syslogfacility_text}</a></td>
|
||||
<td class="line1" valign="top" align="center"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogtag&q={syslogtag}" target="_blank">{syslogtag}</a></td>
|
||||
<td class="line1" valign="top" align="left">{msg}</td>
|
||||
</tr>
|
||||
|
||||
<!-- END cons_msgs -->
|
||||
|
@ -68,27 +68,27 @@
|
||||
<table width="100%" cellpadding="0" cellspacing="1" border="1" align="center" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="center" width="50" nowrap>{ln_report_number}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="center" width="50" nowrap>{ln_report_count}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="left" width="100" nowrap>{ln_report_firstoccurrence}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="left" width="100" nowrap>{ln_report_lastoccurrence}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="left" width="100" nowrap>{ln_report_severity}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="left" width="50" nowrap>{ln_report_facility}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="left" width="50" nowrap>{ln_report_syslogtag}</td>
|
||||
<td class="cellmenu1" bgcolor="#9FDAF1" align="center" width="50" nowrap>{ln_report_count}</td>
|
||||
</tr>
|
||||
<!-- BEGIN cons_msgs -->
|
||||
<tr>
|
||||
<td class="line1" valign="top" align="center" rowspan="2">{ZAEHLER}</td>
|
||||
<td class="line1" valign="top" align="left">{FirstOccurrence_Date_Formatted}</td>
|
||||
<td class="line1" valign="top" align="left">{LastOccurrence_Date_Formatted}</td>
|
||||
<td class="line1" valign="top" align="left">{syslogseverity_text}</td>
|
||||
<td class="line1" valign="top" align="left"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogfacility&q={syslogfacility_text}" target="_blank">{syslogfacility_text}</a></td>
|
||||
<td class="line1" valign="top" align="left"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogtag&q={syslogtag}" target="_blank">{syslogtag}</a></td>
|
||||
<!-- IF ItemCount>=$_colorThreshold -->
|
||||
<td class="lineColouredWhite" valign="top" align="right" bgcolor="#DD0000"><b>{ItemCount}</b></td>
|
||||
<!-- ENDIF ItemCount>=$_colorThreshold -->
|
||||
<!-- IF ItemCount<$_colorThreshold -->
|
||||
<td class="lineColouredWhite" valign="top" align="right" bgcolor="#CCCCCC"><b>{ItemCount}</b></td>
|
||||
<!-- ENDIF ItemCount<$_colorThreshold -->
|
||||
<td class="line1" valign="top" align="left">{FirstOccurrence_Date_Formatted}</td>
|
||||
<td class="line1" valign="top" align="left">{LastOccurrence_Date_Formatted}</td>
|
||||
<td class="line1" valign="top" align="left">{syslogseverity_text}</td>
|
||||
<td class="line1" valign="top" align="left"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogfacility&q={syslogfacility_text}" target="_blank">{syslogfacility_text}</a></td>
|
||||
<td class="line1" valign="top" align="left"><a href="http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=syslogtag&q={syslogtag}" target="_blank">{syslogtag}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cellmenu1" align="center" valign="top" nowrap colspan="2" width="200">{ln_report_description}</td>
|
||||
|
@ -566,7 +566,7 @@ function CheckAndSetRunMode()
|
||||
// Define and Inits Syslog variables now!
|
||||
// DEPRECIATED! define_syslog_variables();
|
||||
// Syslog Constants are defined by default anyway!
|
||||
openlog("LogAnalyzer", LOG_PID, LOG_USER);
|
||||
$syslogOpened = openlog("LogAnalyzer", LOG_PID, LOG_USER);
|
||||
|
||||
// --- Check necessary PHP Extensions!
|
||||
$loadedExtensions = get_loaded_extensions();
|
||||
@ -1347,7 +1347,7 @@ function OutputDebugMessage($szDbg, $szDbgLevel = DEBUG_INFO)
|
||||
// Check if the user wants to syslog the error!
|
||||
if ( GetConfigSetting("MiscDebugToSyslog", 0, CFGLEVEL_GLOBAL) == 1 )
|
||||
{
|
||||
syslog(GetPriorityFromDebugLevel($szDbgLevel), $szDbg);
|
||||
$syslogSend = syslog(GetPriorityFromDebugLevel($szDbgLevel), $szDbg);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user