plugin_thold icon indicating copy to clipboard operation
plugin_thold copied to clipboard

Monitor tab status filter does not use Default Monitor Status from Settings

Open unka65 opened this issue 3 years ago • 3 comments

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:

  1. Go to Configuration, Settings
  2. Go to Alerting/Thold
  3. Set Default Management Status to Any
  4. Set Default Monitor Status to Breached
  5. Go to Thold monitoring tab (thold/thold_graph.php)
  6. 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);
    }

unka65 avatar Aug 10 '21 19:08 unka65

That would probably need to be a !== to ensure that it isn't comparing '' or false with '0'. Would you agree?

netniV avatar Aug 31 '21 13:08 netniV

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);
    }

unka65 avatar Sep 01 '21 09:09 unka65

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.

netniV avatar Sep 02 '21 00:09 netniV

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.

TheWitness avatar Jul 22 '23 16:07 TheWitness