Skip to content

Commit

Permalink
feature: Create more filters for the Clog Message Type
Browse files Browse the repository at this point in the history
This minor enhancement made it easier to debug problems in a system with many 10's of thousands of log rows.
  • Loading branch information
TheWitness committed Feb 3, 2022
1 parent 0046763 commit b519f56
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Cacti CHANGELOG
-feature: Allow the get_template_account() function to be hookable by third party plugin
-feature: Allow The User Management interface to be filterable by Realm
-feature: Prevent Template User Accounts from being Removed
-feature: Create more Filters for CLog Types

1.2.19
-security#4356: Further fixes for grave character security protection
Expand Down
28 changes: 22 additions & 6 deletions lib/clog_webapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,28 @@ function filter($clogAdmin, $selectedFile) {
</td>
<td>
<select id='message_type'>
<option value='-1'<?php if (get_request_var('message_type') == '-1') {?> selected<?php }?>><?php print __('All');?></option>
<option value='1'<?php if (get_request_var('message_type') == '1') {?> selected<?php }?>><?php print __('Stats');?></option>
<option value='2'<?php if (get_request_var('message_type') == '2') {?> selected<?php }?>><?php print __('Warnings');?></option>
<option value='3'<?php if (get_request_var('message_type') == '3') {?> selected<?php }?>><?php print __('Errors');?></option>
<option value='4'<?php if (get_request_var('message_type') == '4') {?> selected<?php }?>><?php print __('Debug');?></option>
<option value='5'<?php if (get_request_var('message_type') == '5') {?> selected<?php }?>><?php print __('SQL Calls');?></option>
<?php
$message_types = array(
'-1' => __('All'),
'1' => __('Stats'),
'2' => __('Warnings'),
'3' => __('Warnings++'),
'4' => __('Errors Only'),
'5' => __('Errors++'),
'6' => __('Debug'),
'7' => __('SQL Calls'),
'8' => __('AutoM8'),
'9' => __('Non Stats')
);

foreach ($message_types as $index => $type) {
print "<option value='" . $index . "'";
if (get_request_var('message_type') == $index) {
print ' selected';
}
print '>' . $type . '</option>';
}
?>
</select>
</td>
<td>
Expand Down
51 changes: 46 additions & 5 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1212,20 +1212,61 @@ function tail_file($file_name, $number_of_lines, $message_type = -1, $filter = '
function determine_display_log_entry($message_type, $line, $filter) {
/* determine if we are to display the line */
switch ($message_type) {
case 1: /* stats */
case 1: /* stats only */
$display = (strpos($line, 'STATS') !== false);

break;
case 2: /* warnings */
case 2: /* warnings only */
$display = (strpos($line, 'WARN') !== false);

break;
case 3: /* errors */
case 3: /* warnings + */
$display = (strpos($line, 'WARN') !== false);

if (!$display) {
$display = (strpos($line, 'ERROR') !== false);
}

if (!$display) {
$display = (strpos($line, 'DEBUG') !== false);
}

if (!$display) {
$display = (strpos($line, ' SQL') !== false);
}

break;
case 4: /* errors only */
$display = (strpos($line, 'ERROR') !== false);

break;
case 4: /* debug */
case 5: /* errors + */
$display = (strpos($line, 'ERROR') !== false);

if (!$display) {
$display = (strpos($line, 'DEBUG') !== false);
}

if (!$display) {
$display = (strpos($line, ' SQL') !== false);
}

break;
case 6: /* debug only */
$display = (strpos($line, 'DEBUG') !== false && strpos($line, ' SQL ') === false);

break;
case 5: /* sql calls */
case 7: /* sql calls only */
$display = (strpos($line, ' SQL ') !== false);

break;
case 8: /* AutoM8 Only */
$display = (strpos($line, 'AUTOM8') !== false);

break;
case 9: /* Non Stats */
$display = (strpos($line, 'STATS') === false);

break;
default: /* all other lines */
case -1: /* all */
Expand Down

0 comments on commit b519f56

Please sign in to comment.