Permalink
Browse files

passthrough results faster

  • Loading branch information...
sni committed Oct 8, 2018
1 parent abcf249 commit d342172e1a86ed8118a135d202b7770b2faefc95
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/Thruk/Utils/CLI.pm
View
@@ -561,6 +561,11 @@ sub _from_fcgi {
} else {
$res = _run_commands($c, $data->{'options'}, 'fcgi');
}
if(defined $res->{'output'} && $c->req->headers->{'accept'} && $c->req->headers->{'accept'} =~ m/application\/json/mx) {
$c->res->body($res->{'output'});
$c->{'rendered'} = 1;
return;
}
if(ref $res eq 'HASH') {
$res->{'version'} = $c->config->{'version'} unless defined $res->{'version'};
$res->{'branch'} = $c->config->{'branch'} unless defined $res->{'branch'};
@@ -1033,6 +1038,17 @@ sub _cmd_raw {
return(\@res, 0);
}
# passthrough livestatus results if possible
if($ENV{'THRUK_USE_LMD'} && $function eq '_raw_query' && $c->req->headers->{'accept'} && $c->req->headers->{'accept'} =~ m/application\/livestatus/mx) {
my $peer = $Thruk::Backend::Pool::lmd_peer;
my $query = $opt->{'args'}->[0];
chomp($query);
$query .= "\nBackends: ".$key."\n";
$c->res->body($peer->_raw_query($query));
$c->{'rendered'} = 1;
return;
}
local $ENV{'THRUK_USE_LMD'} = ""; # don't try to do LMD stuff since we directly access the real backend
my @res = Thruk::Backend::Pool::do_on_peer($key, $function, $opt->{'args'});
my $res = shift @res;

0 comments on commit d342172

Please sign in to comment.