From d2eb2bb0bfe5b88f73a9978cf3850a3b328bb26e Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Wed, 18 Nov 2009 16:54:39 +0100 Subject: [PATCH] Fixed multiple minor report issues --- src/classes/logstreamdisk.class.php | 14 ++++--- src/classes/reports/report.class.php | 2 +- .../reports/report.eventlog.monilog.class.php | 40 +++++++++++++++++-- .../report.eventlog.monilog.template.html | 2 +- src/include/constants_errors.php | 2 +- src/lang/en/main.php | 5 +++ 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index 23121c2..69e5cd8 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -665,6 +665,10 @@ class LogStreamDisk extends LogStream { // We loop through all loglines! this may take a while! $uID = UID_UNKNOWN; + + // Needed to reset file position! + $this->Sseek($uID, EnumSeek::BOS, 0); + $ret = $this->Read($uID, $logArray); if ( $ret == SUCCESS ) { @@ -721,9 +725,6 @@ class LogStreamDisk extends LogStream { $aResult[ $content['LN_STATS_OTHERS'] ] = $arrEntryCopy; } - // Needed to reset file position! - $this->Sseek($uID, EnumSeek::BOS, 0); - // finally return result! if ( count($aResult) > 0 ) return $aResult; @@ -751,6 +752,10 @@ class LogStreamDisk extends LogStream { // We loop through all loglines! this may take a while! $uID = UID_UNKNOWN; + + // Needed to reset file position! + $this->Sseek($uID, EnumSeek::BOS, 0); + $ret = $this->Read($uID, $logArray); if ( $ret == SUCCESS ) { @@ -819,9 +824,6 @@ class LogStreamDisk extends LogStream { $aResult[ $content['LN_STATS_OTHERS'] ] = $arrEntryCopy; } - // Needed to reset file position! - $this->Sseek($uID, EnumSeek::BOS, 0); - // finally return result! if ( count($aResult) > 0 ) return $aResult; diff --git a/src/classes/reports/report.class.php b/src/classes/reports/report.class.php index a4bd4d3..fdb5192 100644 --- a/src/classes/reports/report.class.php +++ b/src/classes/reports/report.class.php @@ -130,7 +130,7 @@ abstract class Report { // Fix Filename manually for FILE LOGSTREAM! if ( $content['Sources'][$this->_mySourceID]['SourceType'] == SOURCE_DISK ) - $this->_streamCfgObj->FileName = CheckAndPrependRootPath(DB_StripSlahes($content['Sources'][$this->_mySourceID]['DiskFile'])); + $this->_streamCfgObj->FileName = CheckAndPrependRootPath( $content['Sources'][$this->_mySourceID]['DiskFile'] ); } else return ERROR_SOURCENOTFOUND; diff --git a/src/classes/reports/report.eventlog.monilog.class.php b/src/classes/reports/report.eventlog.monilog.class.php index 5290068..a0959c5 100644 --- a/src/classes/reports/report.eventlog.monilog.class.php +++ b/src/classes/reports/report.eventlog.monilog.class.php @@ -233,18 +233,24 @@ class Report_monilog extends Report { $res = $this->_streamObj->Open( $this->_arrProperties, true ); if ( $res == SUCCESS ) { + // Set reading direction - $this->_streamObj->SetReadDirection( EnumReadDirection::Backward ); +// $this->_streamObj->SetReadDirection( EnumReadDirection::Backward ); // Init uid helper $uID = UID_UNKNOWN; - // Set reading direction - $this->_streamObj->Sseek($uID, EnumSeek::EOS, 0); + // Set position to BEGIN of FILE + $this->_streamObj->Sseek($uID, EnumSeek::BOS, 0); // Start reading data $ret = $this->_streamObj->Read($uID, $logArray); +// TimeStats +global $gl_starttime; +$nowtime = microtime_float(); +$content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s "; + // Found first data record if ( $ret == SUCCESS ) { @@ -265,6 +271,8 @@ class Report_monilog extends Report { // Calc crc32 from message, we use this as index $logArray[MISC_CHECKSUM] = crc32( $logArray[SYSLOG_MESSAGE] ); $strChecksum = $logArray[MISC_CHECKSUM]; + + // TODO, save calculated Checksum into DB! } // Check if entry exists in result array @@ -295,11 +303,15 @@ class Report_monilog extends Report { $content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['LastEvent_Date'] = $logArray[SYSLOG_DATE]; } } - + // Get next data record $ret = $this->_streamObj->ReadNext($uID, $logArray); } while ( $ret == SUCCESS ); +// TimeStats +$nowtime = microtime_float(); +$content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s "; + // Start Postprocessing foreach( $content["report_consdata"] as &$tmpConsolidatedComputer ) { @@ -309,12 +321,32 @@ class Report_monilog extends Report { // Remove entries according to _maxEventsPerHost if ( count($tmpConsolidatedComputer['cons_events']) > $this->_maxEventsPerHost ) { + $iDropCount = 0; + do { array_pop($tmpConsolidatedComputer['cons_events']); + $iDropCount++; } while ( count($tmpConsolidatedComputer['cons_events']) > $this->_maxEventsPerHost ); + + // Append a dummy entry which shows count of all other events + if ( $iDropCount > 0 ) + { + $lastEntry[SYSLOG_SEVERITY] = 5; + $lastEntry[SYSLOG_EVENT_ID] = "-"; + $lastEntry[SYSLOG_EVENT_SOURCE] = $content['LN_GEN_ALL_OTHER_EVENTS']; + $lastEntry[SYSLOG_MESSAGE] = $content['LN_GEN_ALL_OTHER_EVENTS']; + $lastEntry['ItemCount'] = $iDropCount; + $lastEntry['FirstEvent_Date'] = "-"; + $lastEntry['LastEvent_Date'] = "-"; + + $tmpConsolidatedComputer['cons_events'][] = $lastEntry; + } } +// TimeStats +$nowtime = microtime_float(); +$content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s "; // PostProcess Events! foreach( $tmpConsolidatedComputer["cons_events"] as &$tmpMyEvent ) diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html b/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html index 1cbf7ed..e49e1a3 100644 --- a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html +++ b/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html @@ -122,7 +122,7 @@ - {LN_FOOTER_PAGERENDERED}: {report_rendertime} + {LN_REPORT_FOOTER_ENDERED}: {report_rendertime}  | {LN_FOOTER_DBQUERIES}: {TOTALQUERIES} diff --git a/src/include/constants_errors.php b/src/include/constants_errors.php index 5238cfd..6094b31 100644 --- a/src/include/constants_errors.php +++ b/src/include/constants_errors.php @@ -66,6 +66,6 @@ define('ERROR_MSG_NOMATCH', 18); define('ERROR_CHARTS_NOTCONFIGURED', 20); define('ERROR_MSG_SKIPMESSAGE', 21); define('ERROR_MSG_SCANABORTED', 23); -define('ERROR_REPORT_NODATA', 24); +define('ERROR_REPORT_NODATA', 25); ?> \ No newline at end of file diff --git a/src/lang/en/main.php b/src/lang/en/main.php index f93b21f..4866459 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -339,5 +339,10 @@ $content['LN_ORACLE_WHOIS'] = "WHOIS Lookup for '%1' value '%2'"; $content['LN_GEN_ERROR_MISSINGSAVEDREPORTID'] = "Invalid or missing savedreport id"; $content['LN_GEN_ERROR_REPORTGENFAILED'] = "Failed generating report '%1' with the following error reason: %2"; $content['LN_GEN_ERROR_WHILEREPORTGEN'] = "Error occured while generating report"; + $content['LN_GEN_ERROR_REPORT_NODATA'] = "No data found for report generation"; + $content['LN_GEN_ALL_OTHER_EVENTS'] = "All other events"; + $content['LN_REPORT_FOOTER_ENDERED'] = "Report rendered in:"; + + ?> \ No newline at end of file