mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-21 20:54:47 +02:00
add option container-name
This commit is contained in:
parent
c685367f76
commit
851c26f35d
@ -337,6 +337,19 @@ sub api_get_containers {
|
|||||||
if (defined($content_total->{$options{container_id}})) {
|
if (defined($content_total->{$options{container_id}})) {
|
||||||
$content_total->{$options{container_id}}->{Stats} = $self->internal_api_get_container_stats(node_name => $content_total->{$options{container_id}}->{NodeName}, container_id => $options{container_id});
|
$content_total->{$options{container_id}}->{Stats} = $self->internal_api_get_container_stats(node_name => $content_total->{$options{container_id}}->{NodeName}, container_id => $options{container_id});
|
||||||
}
|
}
|
||||||
|
} elsif (defined($options{container_name}) && $options{container_name} ne '') {
|
||||||
|
my $container_id;
|
||||||
|
|
||||||
|
foreach (keys %$content_total) {
|
||||||
|
if ($content_total->{$_}->{Name} eq $options{container_name}) {
|
||||||
|
$container_id = $_;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($container_id)) {
|
||||||
|
$content_total->{$container_id}->{Stats} = $self->internal_api_get_container_stats(node_name => $content_total->{$container_id}->{NodeName}, container_id => $container_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach my $container_id (keys %{$content_total}) {
|
foreach my $container_id (keys %{$content_total}) {
|
||||||
$content_total->{$container_id}->{Stats} = $self->internal_api_get_container_stats(node_name => $content_total->{$container_id}->{NodeName}, container_id => $container_id);
|
$content_total->{$container_id}->{Stats} = $self->internal_api_get_container_stats(node_name => $content_total->{$container_id}->{NodeName}, container_id => $container_id);
|
||||||
|
@ -217,6 +217,7 @@ sub new {
|
|||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>
|
||||||
{
|
{
|
||||||
"container-id:s" => { name => 'container_id' },
|
"container-id:s" => { name => 'container_id' },
|
||||||
|
"container-name:s" => { name => 'container_name' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"use-name" => { name => 'use_name' },
|
"use-name" => { name => 'use_name' },
|
||||||
"warning-container-status:s" => { name => 'warning_container_status', default => '' },
|
"warning-container-status:s" => { name => 'warning_container_status', default => '' },
|
||||||
@ -263,7 +264,8 @@ sub manage_selection {
|
|||||||
|
|
||||||
$self->{containers} = {};
|
$self->{containers} = {};
|
||||||
$self->{containers_traffic} = {};
|
$self->{containers_traffic} = {};
|
||||||
my $result = $options{custom}->api_get_containers(container_id => $self->{option_results}->{container_id}, statefile => $self->{statefile_cache_containers});
|
my $result = $options{custom}->api_get_containers(container_id => $self->{option_results}->{container_id},
|
||||||
|
container_name => $self->{option_results}->{container_name}, statefile => $self->{statefile_cache_containers});
|
||||||
|
|
||||||
foreach my $container_id (keys %{$result}) {
|
foreach my $container_id (keys %{$result}) {
|
||||||
next if (!defined($result->{$container_id}->{Stats}));
|
next if (!defined($result->{$container_id}->{Stats}));
|
||||||
@ -309,7 +311,8 @@ sub manage_selection {
|
|||||||
$self->{cache_name} = "docker_" . $self->{mode} . '_' . join('_', @$hostnames) . '_' . $options{custom}->get_port() . '_' .
|
$self->{cache_name} = "docker_" . $self->{mode} . '_' . join('_', @$hostnames) . '_' . $options{custom}->get_port() . '_' .
|
||||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||||
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
|
||||||
(defined($self->{option_results}->{container_id}) ? md5_hex($self->{option_results}->{container_id}) : md5_hex('all'));
|
(defined($self->{option_results}->{container_id}) ? md5_hex($self->{option_results}->{container_id}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{container_name}) ? md5_hex($self->{option_results}->{container_name}) : md5_hex('all'));
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -326,6 +329,10 @@ Check container usage.
|
|||||||
|
|
||||||
Exact container ID.
|
Exact container ID.
|
||||||
|
|
||||||
|
=item B<--container-name>
|
||||||
|
|
||||||
|
Exact container name (if multiple names: names separated by ':').
|
||||||
|
|
||||||
=item B<--use-name>
|
=item B<--use-name>
|
||||||
|
|
||||||
Use docker name for perfdata and display.
|
Use docker name for perfdata and display.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user