plugin_thold
plugin_thold copied to clipboard
Monitor tab status filter does not use Default Monitor Status from Settings
Describe the bug The Alerting/Thold configuration settings has two default status filter settings, Management and Monitor. I did not find the Monitor filter setting being used in the plugin. The Monitor tab does not use the Monitor filter setting.
To Reproduce Steps to reproduce the behavior:
- Go to Configuration, Settings
- Go to Alerting/Thold
- Set Default Management Status to Any
- Set Default Monitor Status to Breached
- Go to Thold monitoring tab (thold/thold_graph.php)
- Filter Status defaults to All (setting thold_filter_default)
Expected behavior It would seem ideal for the Monitoring tab filter Status to use the Default Monitor Status value thold_monitor_default from Settings.
Plugin:
- Version: Cacti 1.2.16, Thold develop as of 7/25/21
- Source: Cacti Debian package, Thold github
Additional context The default for the Monitor tab was added in issue/feature #167 but the retrieved setting in thold_graph.php was reverted in issue #190 which seems like an unrelated issue. The following change, thold_filter_default to thold_monitor_default, works for me as seems was intended in the enhancement.
thold_graph.php function tholds() { ... From:
$default_status = read_config_option('thold_filter_default');
if (empty($default_status)) {
set_config_option('thold_filter_default', '-1');
$default_status = '-1';
}
To:
$default_status = read_config_option('thold_monitor_default');
// Disabled is '0' considered empty
if (empty($default_status) && $default_status != '0') {
$default_status = '-1';
set_config_option('thold_monitor_default', $default_status);
}
That would probably need to be a !== to ensure that it isn't comparing '' or false with '0'. Would you agree?
I am not familiar with the comparison operators. I defer to you of what should be done if the main issue is even valid. I looked at the PHP doc. It seems that instead of using function empty(), function is_null() considers '0' a value and so would not need the additional compare. I tested deleting the setting from the table and also with default of Disabled. It seems to work.
$default_status = read_config_option('thold_monitor_default');
if (is_null($default_status)) {
$default_status = '-1';
set_config_option('thold_monitor_default', $default_status);
}
If you compare using !=
or ==
this is a relatively equal operator. So, false == 0
would be true. However, !==
or ===
are exactly equal to, so false === 0
would be false.
Need a separate monitor issue for that. I looked at the code, and there is a user contributed hack in there that I'm uncertain of. More on that later.