Implemented record limit into chartdata generation of the disk logstream

This commit is contained in:
Andre Lorbach 2008-09-09 11:22:51 +02:00
parent 5c8a7aba3e
commit b974bd145c
6 changed files with 37 additions and 11 deletions

View File

@ -151,7 +151,7 @@ if ( !$content['error_occured'] )
// $graph->title->SetColor("darkred");
// Setup the tab title
$graph->tabtitle->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaptionID'] ] . '"');
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_COUNTBY'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) );
$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10);
@ -207,7 +207,7 @@ if ( !$content['error_occured'] )
// Setup the tab title
$graph->tabtitle->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaptionID'] ] . '"');
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_COUNTBY'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) );
$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10);
// Setup the X and Y grid

View File

@ -583,11 +583,17 @@ class LogStreamDisk extends LogStream {
*/
public function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit)
{
global $content;
// We loop through all loglines! this may take a while!
$uID = UID_UNKNOWN;
$ret = $this->ReadNext($uID, $logArray);
if ( $ret == SUCCESS )
{
// Initialize Array variable
$aResult = array();
// Loop through messages
do
{
if ( isset($logArray[$szFieldId]) )
@ -595,7 +601,20 @@ class LogStreamDisk extends LogStream {
if ( isset($aResult[ $logArray[$szFieldId] ]) )
$aResult[ $logArray[$szFieldId] ]++;
else
{
// Initialize entry if we haven't exceeded the RecordLImit yet!
if ( count($aResult) < $nRecordLimit )
$aResult[ $logArray[$szFieldId] ] = 1;
else
{
// Count record to others
if ( isset($aResult[ $content['LN_STATS_OTHERS'] ]) )
$aResult[ $content['LN_STATS_OTHERS'] ]++;
else
$aResult[ $content['LN_STATS_OTHERS'] ] = 1;
}
}
/*
if ( isset($aResult[ $logArray[$szFieldId] ][CHARTDATA_COUNT]) )
$aResult[ $logArray[$szFieldId] ][CHARTDATA_COUNT]++;
@ -611,6 +630,14 @@ class LogStreamDisk extends LogStream {
// Sort Array, so the highest count comes first!
array_multisort($aResult, SORT_NUMERIC, SORT_DESC);
if ( isset($aResult[ $content['LN_STATS_OTHERS'] ]) )
{
// This will move the "Others" Element to the last position!
$arrEntryCopy = $aResult[ $content['LN_STATS_OTHERS'] ];
unset($aResult[ $content['LN_STATS_OTHERS'] ]);
$aResult[ $content['LN_STATS_OTHERS'] ] = $arrEntryCopy;
}
// finally return result!
return $aResult;
}

View File

@ -280,8 +280,7 @@ $content['LN_DETAIL_BACKTOLIST'] = "Back to Listview";
$content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version.";
// Stats Site
$content['LN_STATS_COUNTBYSOURCE'] = "Messagecount by Source";
$content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag";
$content['LN_STATS_COUNTBY'] = "Messagecount by '%1'";
$content['LN_STATS_GRAPH'] = "Graph";
$content['LN_GEN_ERROR_INVALIDFIELD'] = "Invalid fieldname";
$content['LN_GEN_ERROR_MISSINGCHARTFIELD'] = "Missing fieldname";

View File

@ -280,8 +280,9 @@ $content['LN_CONVERT_PROCESS'] = "Conversion Progress:";
$content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version.";
// Stats Site
$content['LN_STATS_COUNTBYSOURCE'] = "Messagecount by Source";
$content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag";
$content['LN_STATS_COUNTBY'] = "Messagecount by '%1'";
$content['LN_STATS_OTHERS'] = "All Others";
// $content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag";
$content['LN_STATS_GRAPH'] = "Graph";
$content['LN_GEN_ERROR_INVALIDFIELD'] = "Invalid fieldname";
$content['LN_GEN_ERROR_MISSINGCHARTFIELD'] = "Missing fieldname";

View File

@ -285,8 +285,7 @@ $content['LN_DETAIL_BACKTOLIST'] = "Voltar para a lista";
$content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version.";
// Stats Site
$content['LN_STATS_COUNTBYSOURCE'] = "Messagecount by Source";
$content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag";
$content['LN_STATS_COUNTBY'] = "Messagecount by '%1'";
$content['LN_STATS_GRAPH'] = "Graph";
$content['LN_GEN_ERROR_INVALIDFIELD'] = "Invalid fieldname";
$content['LN_GEN_ERROR_MISSINGCHARTFIELD'] = "Missing fieldname";

View File

@ -22,7 +22,7 @@
<table width="400" cellpadding="0" cellspacing="0" border="0" align="center">
<tr><td class="cellmenu1" align="center"><B>{LN_STATS_GRAPH}: {LN_STATS_COUNTBYSOURCE}</B></td></tr>
<tr><td class="line1"><img src="{BASEPATH}chartgenerator.php?type=2&byfield=FROMHOST&width=400" width="400" height="400"></td></tr>
<tr><td class="line1"><img src="{BASEPATH}chartgenerator.php?type=2&byfield=FROMHOST&width=400&maxrecords=10" width="400" height="400"></td></tr>
</table>
<br><br>
@ -32,7 +32,7 @@
<table width="400" cellpadding="0" cellspacing="0" border="0" align="center">
<tr><td class="cellmenu1" align="center"><B>{LN_STATS_GRAPH}: {LN_STATS_COUNTBYSYSLOGTAG}</B></td></tr>
<tr><td class="line1"><img src="{BASEPATH}chartgenerator.php?type=1&byfield=syslogtag&width=400" width="400" height="400"></td></tr>
<tr><td class="line1"><img src="{BASEPATH}chartgenerator.php?type=1&byfield=syslogtag&width=400&maxrecords=10" width="400" height="400"></td></tr>
</table>
<br><br>