diff --git a/plugins/plugins-available/agents/lib/Thruk/Controller/agents.pm b/plugins/plugins-available/agents/lib/Thruk/Controller/agents.pm index dd667b3ac..0d80e2f99 100644 --- a/plugins/plugins-available/agents/lib/Thruk/Controller/agents.pm +++ b/plugins/plugins-available/agents/lib/Thruk/Controller/agents.pm @@ -97,12 +97,29 @@ sub _process_show { } $c->stash->{data} = Thruk::Backend::Manager::sort_result({}, $hosts, ['_AGENT_SECTION', 'host_name', 'site']); - my $versions = $c->db->get_services(filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'hosts' ), + my $services = $c->db->get_services(filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'hosts' ), 'host_custom_variables' => { '~' => 'AGENT .+' }, - 'description' => 'agent version', + 'description' => { '~' => '^(agent version|agent inventory)$' }, ], ); - $c->stash->{versions} = Thruk::Base::array2hash($versions, "host_name"); + my $info = {}; + for my $svc (@{$services}) { + my $extra = $info->{$svc->{'host_name'}} // {}; + if($svc->{'description'} eq 'agent version') { + my $v = $svc->{'plugin_output'}; + $v =~ s/^.*\sv/v/gmx; + $extra->{'version'} = $v; + $extra->{'state'} = $svc->{'state'}; + $extra->{'has_been_checked'} = $svc->{'has_been_checked'}; + } + if($svc->{'description'} eq 'agent inventory') { + $extra->{'inv_state'} = $svc->{'state'}; + $extra->{'inv_out'} = $svc->{'plugin_output'}; + $extra->{'inv_out'} =~ s/^\w+\ \-\ //gmx; + } + $info->{$svc->{'host_name'}} = $extra; + } + $c->stash->{info} = $info; # set fallback backend for start page so the apply button can be shown if(!$c->req->parameters->{'backend'} && !$c->stash->{'param_backend'}) { diff --git a/plugins/plugins-available/agents/lib/Thruk/Utils/CLI/Agents.pm b/plugins/plugins-available/agents/lib/Thruk/Utils/CLI/Agents.pm index d3b8e87ed..d56339ac6 100644 --- a/plugins/plugins-available/agents/lib/Thruk/Utils/CLI/Agents.pm +++ b/plugins/plugins-available/agents/lib/Thruk/Utils/CLI/Agents.pm @@ -477,7 +477,7 @@ sub _check_inventory { (scalar @{$checks->{'new'}} != 1 ? 's' : ''), $perfdata, join("\n", @details), - ), 2); + ), 1); } my @details; diff --git a/plugins/plugins-available/agents/templates/agents.tt b/plugins/plugins-available/agents/templates/agents.tt index 93745776c..38d532fe4 100644 --- a/plugins/plugins-available/agents/templates/agents.tt +++ b/plugins/plugins-available/agents/templates/agents.tt @@ -43,14 +43,14 @@ [% h.name | html %] [% state = 'PENDING' %] - [% IF versions.exists(hostname) %] - [% state = servicestatetext(versions.$hostname) %] + [% IF info.exists(hostname) %] + [% state = servicestatetext(info.$hostname) %] [% END %]
[% state %]
[% peer_name(h) | html %] [% agent.type | html %] [% agent.type | html %] - [% IF versions.exists(hostname) %][% versions.$hostname.plugin_output.replace('^.*\sv', 'v') | html %][% END %] + [% IF info.exists(hostname) && info.$hostname.exists("version") %][% info.$hostname.version | html %][% END %]
@@ -59,6 +59,12 @@ data => { 'action' => 'remove', 'hostname' => h.name, backend => h.peer_key, CSRFtoken => get_user_token(c), }, button => { class => 'iconOnly', title => "Remove this host with all services.", onclick => "return(confirm('really remove host?'))", html => '' }, }%] + [% IF info.exists(hostname) && info.$hostname.exists("inv_state") && info.$hostname.inv_state != 0 %] + + + + [% info.$hostname.inv_state %] + [% END %]