Skip to content

Commit

Permalink
fix sending multiple commands over federation host
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Feb 13, 2025
1 parent 5f33f79 commit 1577d7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/Thruk/Utils/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,12 @@ sub _cmd_raw {
if($ENV{'THRUK_USE_LMD'} && $function eq '_raw_query' && $c->req->headers->{'accept'} && $c->req->headers->{'accept'} =~ m/application\/livestatus/mx) {
my $peer = $c->db->lmd_peer;
my $query = $opt->{'args'}->[0];
chomp($query);
$query .= "\nBackends: ".$key."\n";
my @querys = split/\n{2,}/mx, $query;
for my $q (@querys) {
chomp($q);
$q .= "\nBackends: ".$key."\n";
}
$query = join("\n", @querys);
$c->res->body($peer->_raw_query($query));
$c->{'rendered'} = 1;
return;
Expand Down
18 changes: 17 additions & 1 deletion t/scenarios/lmd_federation_multitier_e2e/t/100-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Test::More;

BEGIN {
plan skip_all => 'backends required' if(!-s 'thruk_local.conf' and !defined $ENV{'PLACK_TEST_EXTERNALSERVER_URI'});
plan tests => 282;
plan tests => 294;
}


Expand Down Expand Up @@ -60,6 +60,22 @@ for my $hst (sort keys %{$ids}) {
}
}

###############################################################################
# send muliple commands to sub peers
TestUtils::test_page(
'url' => '/thruk/cgi-bin/cmd.cgi',
'post' => {
'referer' => 'status.cgi',
'selected_services' => 'tier3b;Load;e984d;e984d,tier3b;Ping;e984d',
'selected_hosts' => '',
'quick_command' => '1',
'start_time' => time(),
},
'like' => [ 'Commands successfully submitted' ],
'follow' => 1,
);


###############################################################################
TestUtils::test_command({
cmd => './script/thruk selfcheck lmd',
Expand Down

0 comments on commit 1577d7b

Please sign in to comment.