Skip to content

Commit

Permalink
fix using custom variables starting with multiple underlines
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jul 2, 2024
1 parent c6ba1f0 commit de4ce72
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ This file documents the revision history for the Monitoring Webinterface Thruk.
next:
- fix recurring downtimes crontab entry for 2nd/3rd days of month
- fix sessions removed early when using kerberos authentication
- fix using custom variables starting with multiple underlines
- Rest:
- add transformation and disaggregation functions
- add support for timeperiod / time queries in where clause
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,7 @@ t/scenarios/backend_naemon/t/300-controller_extinfo.t
t/scenarios/backend_naemon/t/300-controller_status.t
t/scenarios/backend_naemon/t/300-controller_tac.t
t/scenarios/backend_naemon/t/local/010-custom_vars_default_view.t
t/scenarios/backend_naemon/t/local/020-custom_vars_filter.t
t/scenarios/backend_naemon/thruk.conf
t/scenarios/backend_naemon/thruk_local.conf
t/scenarios/backend_nagios4/docker-compose.yml
Expand Down
1 change: 0 additions & 1 deletion lib/Thruk/Utils/Status.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,6 @@ sub single_search {
}
elsif ( $filter->{'type'} eq 'custom variable' ) {
my $pre = uc($filter->{'val_pre'});
if(substr($pre, 0, 1) eq '_') { $pre = substr($pre, 1); }
push @hostfilter, { custom_variables => { $op => $pre." ".$value } };
push @hosttotalsfilter, { custom_variables => { $op => $pre." ".$value } };
my $cop = '-or';
Expand Down
36 changes: 36 additions & 0 deletions t/scenarios/backend_naemon/t/local/020-custom_vars_filter.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use warnings;
use strict;
use Test::More;

BEGIN {
use lib('t');
require TestUtils;
import TestUtils;
}

plan tests => 27;

$ENV{'THRUK_TEST_AUTH'} = 'omdadmin:omd';
$ENV{'PLACK_TEST_EXTERNALSERVER_URI'} = 'http://127.0.0.1/demo';

use_ok("Thruk::Utils::IO");

###########################################################
# verify that we use the correct thruk binary
TestUtils::test_command({
cmd => '/bin/bash -c "type thruk"',
like => ['/\/thruk\/script\/thruk/'],
}) or BAIL_OUT("wrong thruk path");

###########################################################
TestUtils::test_page(
url => '/thruk/cgi-bin/status.cgi?style=hostdetail&dfl_s0_type=custom variable&dfl_s0_val_pre=TEST&dfl_s0_op=%3D&dfl_s0_value=test var hst',
like => ['host=test'],
);

TestUtils::test_page(
url => '/thruk/cgi-bin/status.cgi?style=hostdetail&dfl_s0_type=custom variable&dfl_s0_val_pre=_IMPACT&dfl_s0_op=%3D&dfl_s0_value=dbl underscore hst',
like => ['host=test'],
);

###########################################################

0 comments on commit de4ce72

Please sign in to comment.