-
Notifications
You must be signed in to change notification settings - Fork 42
Export all pages, simplified datefrom, and suppress fix #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,8 @@ | |
| $content['searchstr'] = ""; | ||
| $content['error_occured'] = false; | ||
|
|
||
| $content['ExportAllMatchPages'] = GetConfigSetting("ExportAllMatchPages", 0, CFGLEVEL_USER) == 1; | ||
| $content['SuppressDuplicatedMessages'] = GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1; | ||
| // Check required input parameters | ||
| if ( | ||
| (isset($_GET['op']) && $_GET['op'] == "export") && | ||
|
|
@@ -203,32 +205,65 @@ | |
| if ( $ret == SUCCESS ) | ||
| { | ||
| //Loop through the messages! | ||
| $duplicateCount = 0; //FIXME while readNext record doesnt properly return skip_status keep it outside of loop body | ||
| $szLastMessageTimestamp = 0; | ||
| $DuplicateRecordMaxTsDistance = GetConfigSetting("DuplicateRecordMaxTsDistance", PHP_INT_MAX, CFGLEVEL_USER); | ||
| do | ||
| { | ||
| // --- Extra stuff for suppressing messages | ||
| if ( | ||
| GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1 | ||
| && | ||
| isset($logArray[SYSLOG_MESSAGE]) | ||
| $content['SuppressDuplicatedMessages'] && isset($logArray[SYSLOG_MESSAGE]) | ||
| ) | ||
| { | ||
|
|
||
| if ( !isset($szLastMessage) ) // Only set lastmgr | ||
| $szLastMessage = $logArray[SYSLOG_MESSAGE]; | ||
| else | ||
| // Skip if same msg | ||
| // but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages) | ||
| $tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Export now assumes Prompt for AI agents |
||
| //echo "uID=$uID; duplicates ($duplicateCount); delta ts = $tsDiff; isDublicate=".($szLastMessage == $logArray[SYSLOG_MESSAGE])."<br>\n"; | ||
| if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] && ($tsDiff < $DuplicateRecordMaxTsDistance)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Duplicate suppression reads Prompt for AI agents |
||
| { | ||
| // Skip if same msg | ||
| if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] ) | ||
| $szLastMessageTimestamp = $logArray["timereported"][EVTIME_TIMESTAMP]; | ||
|
|
||
| // --- Extra Loop to get the next entry! | ||
| // FIXME 230122 right now ReadNext skips entries only from custom msgparser (see: classes/logstreamdb.class.php:601) | ||
| do | ||
| { | ||
| // Set last mgr | ||
| $szLastMessage = $logArray[SYSLOG_MESSAGE]; | ||
| $ret = $stream->ReadNext($uID, $logArray); | ||
| $duplicateCount++; | ||
| } while ( $ret == ERROR_MSG_SKIPMESSAGE ); | ||
| // --- | ||
|
|
||
| // Skip entry | ||
| continue; | ||
| }else{ | ||
| //inject entry about suppressed records | ||
| // FIXME any better way of doing that? | ||
| if($duplicateCount > 1){ //ignore if only 1 duplicate | ||
| foreach($content['Columns'] as $mycolkey) | ||
| { | ||
| if ( isset($fields[$mycolkey]) ) | ||
| { | ||
| $content['syslogmessages'][$counter][$mycolkey]['FieldColumn'] = $mycolkey; | ||
| $content['syslogmessages'][$counter][$mycolkey]['uid'] = $uID; | ||
|
|
||
| // Skip entry | ||
| continue; | ||
| if($content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING && $mycolkey == SYSLOG_MESSAGE){ | ||
| $content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = "... suppressed $duplicateCount duplicate(s)..."; | ||
| }else $content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = "\t"; | ||
| } | ||
| } | ||
| $counter++; | ||
| $duplicateCount = 0; //reset suppress counter | ||
| } | ||
| $szLastMessage = $logArray[SYSLOG_MESSAGE]; | ||
| $szLastMessageTimestamp = $logArray["timereported"][EVTIME_TIMESTAMP]; | ||
| } | ||
| } | ||
| // --- | ||
|
|
||
| if(!isset($content['period_start_ts'])){ //store first record ts | ||
| $content['period_start_ts'] = $logArray["timereported"][EVTIME_TIMESTAMP]; | ||
| }//*else if(!isset($content['period_start_ts'])){ // FIXME store last record ts | ||
| $content['period_end_ts'] = $logArray["timereported"][EVTIME_TIMESTAMP]; | ||
| //} | ||
|
|
||
| // --- Now we populate the values array! | ||
| foreach($content['Columns'] as $mycolkey) | ||
|
|
@@ -286,7 +321,17 @@ | |
|
|
||
| // Increment Counter | ||
| $counter++; | ||
| } while ($counter < $content['CurrentViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); | ||
|
|
||
| // --- Extra Loop to get the next entry! | ||
| do | ||
| { | ||
| $ret = $stream->ReadNext($uID, $logArray); | ||
| } while ( $ret == ERROR_MSG_SKIPMESSAGE ); | ||
|
|
||
| if(!$content['ExportAllMatchPages'] && $counter >= $content['CurrentViewEntriesPerPage']){ | ||
| break; | ||
| } | ||
| } while ($ret == SUCCESS); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Trailing suppressed-duplicate groups are dropped when the stream ends before a non-duplicate triggers summary injection. Prompt for AI agents |
||
|
|
||
| if ( $content['read_direction'] == EnumReadDirection::Forward ) | ||
| { | ||
|
|
@@ -331,7 +376,7 @@ | |
| $szOutputMimeType = "text/plain"; | ||
| $szOutputCharset = ""; | ||
|
|
||
| $szOutputFileName = "ExportMessages"; | ||
| $szOutputFileName = "ExportMessages_".date('Ymd\THis',$content['period_start_ts'])."-".date('Ymd\THis',$content['period_end_ts']); | ||
| $szOutputFileExtension = ".txt"; | ||
| $szOPFieldSeparator = " "; | ||
| $szOPFirstLineFieldNames = true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -105,6 +105,9 @@ | |||||
| $content['skipone'] = false; | ||||||
| // --- | ||||||
|
|
||||||
| // Init show suppressed count flag | ||||||
| $content['SUPPRESS_ENABLED'] = GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1; | ||||||
|
|
||||||
| // Init Export Stuff! | ||||||
| $content['EXPORT_ENABLED'] = true; | ||||||
|
|
||||||
|
|
@@ -336,38 +339,78 @@ | |||||
| // --- | ||||||
|
|
||||||
| //Loop through the messages! | ||||||
| $duplicateCountTotal = 0; | ||||||
| $duplicateCount = 0; //FIXME while readNext record doesnt properly return skip_status keep it outside of loop body | ||||||
| $szLastMessageTimestamp = 0; | ||||||
| $DuplicateRecordMaxTsDistance = GetConfigSetting("DuplicateRecordMaxTsDistance", PHP_INT_MAX, CFGLEVEL_USER); | ||||||
| do | ||||||
| { | ||||||
| // --- Extra stuff for suppressing messages | ||||||
| if ( | ||||||
| GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1 | ||||||
| && | ||||||
| isset($logArray[SYSLOG_MESSAGE]) | ||||||
| ) | ||||||
| GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1 | ||||||
| && | ||||||
| isset($logArray[SYSLOG_MESSAGE]) | ||||||
| ) | ||||||
| { | ||||||
|
|
||||||
| if ( !isset($szLastMessage) ) // Only set lastmgr | ||||||
| $szLastMessage = $logArray[SYSLOG_MESSAGE]; | ||||||
| else | ||||||
| // Skip if same msg | ||||||
| // but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages) | ||||||
| $tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]); //sign depends on direction | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Duplicate suppression reads Prompt for AI agents |
||||||
| //echo "uID=$uID; duplicates ($duplicateCount); delta ts = $tsDiff; isDublicate=".($szLastMessage == $logArray[SYSLOG_MESSAGE])."<br>"; | ||||||
| if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] && ($tsDiff < $DuplicateRecordMaxTsDistance)) | ||||||
| { | ||||||
| // Skip if same msg | ||||||
| if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] ) | ||||||
| { | ||||||
| // Set last mgr | ||||||
| $szLastMessage = $logArray[SYSLOG_MESSAGE]; | ||||||
| $szLastMessageTimestamp = $logArray["timereported"][EVTIME_TIMESTAMP]; | ||||||
|
|
||||||
| // --- Extra Loop to get the next entry! | ||||||
| do | ||||||
| // --- Extra Loop to get the next entry! | ||||||
| // FIXME 230122 right now ReadNext skips entries only from custom msgparser (see: classes/logstreamdb.class.php:601) | ||||||
| do | ||||||
| { | ||||||
| $ret = $stream->ReadNext($uID, $logArray); | ||||||
| $duplicateCount++; | ||||||
| } while ( $ret == ERROR_MSG_SKIPMESSAGE ); | ||||||
| // --- | ||||||
|
|
||||||
| // Skip entry | ||||||
| continue; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Suppressed duplicate count is dropped when duplicate runs end at page/stream boundary because pending count is never flushed before loop exit. Prompt for AI agents |
||||||
| }else{ | ||||||
| //inject entry about suppressed records | ||||||
| // FIXME any better way of doing that? | ||||||
| if($duplicateCount > 1){ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Suppression threshold is off by one: a single suppressed duplicate ( Prompt for AI agents
Suggested change
|
||||||
| foreach($content['Columns'] as $mycolkey) | ||||||
| { | ||||||
| $ret = $stream->ReadNext($uID, $logArray); | ||||||
| } while ( $ret == ERROR_MSG_SKIPMESSAGE ); | ||||||
| // --- | ||||||
|
|
||||||
| // Skip entry | ||||||
| continue; | ||||||
| if ( isset($fields[$mycolkey]) ) | ||||||
| { | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['FieldColumn'] = $mycolkey; | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['uid'] = $uID; | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['FieldAlign'] = $fields[$mycolkey]['FieldAlign']; | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = $content['syslogmessages'][$counter]['cssclass']; | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['isnowrap'] = "nowrap"; | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "false"; | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['detailimagealign'] = "TOP"; | ||||||
|
|
||||||
| // Set default link | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['detaillink'] = "#"; | ||||||
|
|
||||||
| if($content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING && $mycolkey == SYSLOG_MESSAGE){ | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = "... suppressed ".($duplicateCount)." duplicate(s)..."; | ||||||
| //$content['syslogmessages'][$counter]['values'][$mycolkey]['rawfieldvalue'] = "rawfield"; // helper variable used for Popups! | ||||||
| //$content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue'] = "encoded field"; // Convert into filter format for submenus | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['ismessagefield'] = false; //don't enable as it's not a real log message | ||||||
| $content['syslogmessages'][$counter]['values'][$mycolkey]['isnowrap'] = ""; | ||||||
|
|
||||||
| }else $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = ""; | ||||||
| } | ||||||
| } | ||||||
| //if enabled, then print it. otherwise this message wll be printed in wrong column! | ||||||
| $content['syslogmessages'][$counter]['MiscShowDebugGridCounter'] = $content['MiscShowDebugGridCounter']; | ||||||
| $counter++; | ||||||
| $duplicateCountTotal += $duplicateCount; | ||||||
| $duplicateCount = 0; //reset suppress counter | ||||||
| } | ||||||
| $szLastMessage = $logArray[SYSLOG_MESSAGE]; | ||||||
| $szLastMessageTimestamp = $logArray["timereported"][EVTIME_TIMESTAMP]; | ||||||
| } | ||||||
| } | ||||||
| $content['main_suppressed_recordcount'] = $duplicateCountTotal; | ||||||
| }// --- End of suppressing | ||||||
| // --- | ||||||
|
|
||||||
| // --- Set CSS Class | ||||||
|
|
@@ -689,6 +732,7 @@ | |||||
| } while ( $ret == ERROR_MSG_SKIPMESSAGE ); | ||||||
| // --- | ||||||
| } while ( $counter < $content['CurrentViewEntriesPerPage'] && ($ret == SUCCESS) ); | ||||||
|
|
||||||
| //print_r ( $content['syslogmessages'] ); | ||||||
|
|
||||||
| // Move below processing - Read First and LAST UID's before start reading the stream! | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Export logic uses
SuppressDuplicatedMessagesinstead of the new export-specificExportSuppressDuplicatedMessages, so export suppression is still incorrectly coupled to view settings.Prompt for AI agents