From 68b39abe32fe0f8a318a37992fc5fa41e45c106e Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Tue, 17 Nov 2009 15:55:04 +0100 Subject: [PATCH] Starting to implement checksum feature into report engine --- src/classes/reports/report.class.php | 9 ++++++ .../reports/report.eventlog.monilog.class.php | 28 +++++++++++++++++-- .../report.eventlog.monilog.template.html | 26 +++++++++++++++++ src/include/constants_logstream.php | 26 +++++++++++++++++ src/reportgenerator.php | 2 -- 5 files changed, 86 insertions(+), 5 deletions(-) diff --git a/src/classes/reports/report.class.php b/src/classes/reports/report.class.php index bca723c..a4bd4d3 100644 --- a/src/classes/reports/report.class.php +++ b/src/classes/reports/report.class.php @@ -298,6 +298,15 @@ abstract class Report { return $this->_customComment; } + /* + * Helper function to return the ReportVersion + */ + public function GetReportVersion() + { + // return Filebasename + return $this->_reportVersion; + } + /* * Helper function to trigger initialisation */ diff --git a/src/classes/reports/report.eventlog.monilog.class.php b/src/classes/reports/report.eventlog.monilog.class.php index 3c8e372..fbe8b29 100644 --- a/src/classes/reports/report.eventlog.monilog.class.php +++ b/src/classes/reports/report.eventlog.monilog.class.php @@ -87,6 +87,7 @@ class Report_monilog extends Report { // $this->_arrProperties[] = SYSLOG_EVENT_CATEGORY; // $this->_arrProperties[] = SYSLOG_EVENT_USER; $this->_arrProperties[] = SYSLOG_MESSAGE; + $this->_arrProperties[] = MISC_CHECKSUM; } @@ -98,7 +99,7 @@ class Report_monilog extends Report { */ public function startDataProcessing() { - global $content, $severity_colors; + global $content, $severity_colors, $gl_starttime; // Set Filter string $this->_streamObj->SetFilter( $this->_filterString ); @@ -114,13 +115,20 @@ class Report_monilog extends Report { // Get Settings and set to global content variable $content["report_title"] = $this->GetCustomTitle(); $content["report_comment"] = $this->GetCustomComment(); + $content["report_version"] = $this->GetReportVersion(); // --- Report logic starts here + $content["report_rendertime"] = ""; + // Step 1: Gather Summaries // Obtain data from the logstream! $content["report_summary"] = $this->_streamObj->ConsolidateDataByField( SYSLOG_SEVERITY, 0, SYSLOG_SEVERITY, SORTING_ORDER_DESC, null, false ); + // TimeStats + $nowtime = microtime_float(); + $content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s, "; + // If data is valid, we have an array! if ( is_array($content["report_summary"]) && count($content["report_summary"]) > 0 ) { @@ -147,12 +155,21 @@ class Report_monilog extends Report { // Get List of hosts $content["report_computers"] = $this->_streamObj->ConsolidateItemListByField( SYSLOG_HOST, $this->_maxHosts, SYSLOG_HOST, SORTING_ORDER_DESC ); + // TimeStats + $nowtime = microtime_float(); + $content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s, "; + // Create plain hosts list for Consolidate function foreach ( $content["report_computers"] as $tmpComputer ) $arrHosts[] = $tmpComputer[SYSLOG_HOST]; // This function will consolidate the Events based per Host! $this->ConsolidateEventsPerHost($arrHosts); + + // TimeStats + $nowtime = microtime_float(); + $content["report_rendertime"] .= number_format($nowtime - $gl_starttime, 2, '.', '') . "s "; + // --- } else @@ -236,8 +253,13 @@ class Report_monilog extends Report { $content["report_consdata"][ $logArray[SYSLOG_HOST] ][SYSLOG_HOST] = $logArray[SYSLOG_HOST]; } - // Calc crc32 from message, we use this as index - $strChecksum = crc32( $logArray[SYSLOG_MESSAGE] ); + // Calc checksum + 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] ); + $strChecksum = $logArray[MISC_CHECKSUM]; + } // Check if entry exists in result array if ( isset($content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]) ) 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 4e4e20f..1cbf7ed 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 @@ -105,5 +105,31 @@ + + + + + + + + + + + +
Made by Adiscon GmbH (2009) +  Report Version {report_version} + +  Partners: + +  Rsyslog | +  WinSyslog + + + {LN_FOOTER_PAGERENDERED}: {report_rendertime} +  | {LN_FOOTER_DBQUERIES}: {TOTALQUERIES} + +
+ + \ No newline at end of file diff --git a/src/include/constants_logstream.php b/src/include/constants_logstream.php index c66bced..7cab322 100644 --- a/src/include/constants_logstream.php +++ b/src/include/constants_logstream.php @@ -69,6 +69,10 @@ define('SYSLOG_WEBLOG_STATUS', 'http_status'); define('SYSLOG_WEBLOG_BYTESSEND', 'http_bytessend'); define('SYSLOG_WEBLOG_REFERER', 'http_referer'); define('SYSLOG_WEBLOG_USERAGENT', 'http_useragent'); + +// Other fields +define('MISC_SYSTEMID', 'misc_systenid'); +define('MISC_CHECKSUM', 'misc_checksum'); // --- // Define possible FIELD Types @@ -294,6 +298,26 @@ $fields[SYSLOG_WEBLOG_USERAGENT]['FieldAlign'] = "left"; $fields[SYSLOG_WEBLOG_USERAGENT]['SearchField'] = SYSLOG_WEBLOG_USERAGENT; $fields[SYSLOG_WEBLOG_USERAGENT]['SearchOnline'] = true; +// Misc fields +$fields[MISC_SYSTEMID]['FieldID'] = MISC_SYSTEMID; +$fields[MISC_SYSTEMID]['FieldDefine'] = 'MISC_SYSTEMID'; +$fields[MISC_SYSTEMID]['FieldCaption'] = 'SystemID'; +$fields[MISC_SYSTEMID]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[MISC_SYSTEMID]['Sortable'] = false; +$fields[MISC_SYSTEMID]['DefaultWidth'] = "50"; +$fields[MISC_SYSTEMID]['FieldAlign'] = "center"; +$fields[MISC_SYSTEMID]['SearchField'] = MISC_SYSTEMID; +$fields[MISC_SYSTEMID]['SearchOnline'] = false; +$fields[MISC_CHECKSUM]['FieldID'] = MISC_CHECKSUM; +$fields[MISC_CHECKSUM]['FieldDefine'] = 'MISC_CHECKSUM'; +$fields[MISC_CHECKSUM]['FieldCaption'] = 'Checksum'; +$fields[MISC_CHECKSUM]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[MISC_CHECKSUM]['Sortable'] = false; +$fields[MISC_CHECKSUM]['DefaultWidth'] = "50"; +$fields[MISC_CHECKSUM]['FieldAlign'] = "center"; +$fields[MISC_CHECKSUM]['SearchField'] = MISC_CHECKSUM; +$fields[MISC_CHECKSUM]['SearchOnline'] = false; + // Message is the last element, this order is important for the Detail page for now! $fields[SYSLOG_MESSAGE]['FieldID'] = SYSLOG_MESSAGE; $fields[SYSLOG_MESSAGE]['FieldDefine'] = 'SYSLOG_MESSAGE'; @@ -322,6 +346,8 @@ $dbmapping['monitorware']['DBMAPPINGS'][SYSLOG_EVENT_LOGTYPE] = "EventLogType"; $dbmapping['monitorware']['DBMAPPINGS'][SYSLOG_EVENT_SOURCE] = "EventSource"; $dbmapping['monitorware']['DBMAPPINGS'][SYSLOG_EVENT_CATEGORY] = "EventCategory"; $dbmapping['monitorware']['DBMAPPINGS'][SYSLOG_EVENT_USER] = "EventUser"; +$dbmapping['monitorware']['DBMAPPINGS'][MISC_SYSTEMID] = "SystemID"; +$dbmapping['monitorware']['DBMAPPINGS'][MISC_CHECKSUM] = "Checksum"; $dbmapping['syslogng']['ID'] = "syslogng"; $dbmapping['syslogng']['DisplayName'] = "SyslogNG"; diff --git a/src/reportgenerator.php b/src/reportgenerator.php index 8d41b90..4847cbe 100644 --- a/src/reportgenerator.php +++ b/src/reportgenerator.php @@ -218,7 +218,6 @@ if ( !$content['error_occured'] ) // Output to browser $page -> output(); - // --- } } @@ -229,7 +228,6 @@ if ( !$content['error_occured'] ) $content['error_details'] = $content['LN_GEN_ERROR_MISSINGSAVEDREPORTID']; } } - } else {