fix(fujitsu/eternus): mode volume-stats - uninitialized value (#3311)

This commit is contained in:
qgarnier 2021-12-08 16:37:12 +01:00 committed by GitHub
parent 6dff406071
commit 16a18029b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 91 additions and 89 deletions

View File

@ -26,6 +26,12 @@ use strict;
use warnings; use warnings;
use centreon::plugins::misc; use centreon::plugins::misc;
sub prefix_cpu_output {
my ($self, %options) = @_;
return "CPU '" . $options{instance_value}->{display} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -38,20 +44,14 @@ sub set_counters {
key_values => [ { name => 'usage' }, { name => 'display' } ], key_values => [ { name => 'usage' }, { name => 'display' } ],
output_template => 'Usage : %d %%', output_template => 'Usage : %d %%',
perfdatas => [ perfdatas => [
{ label => 'cpu', value => 'usage', template => '%d', { label => 'cpu', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, }
]; ];
} }
sub prefix_cpu_output {
my ($self, %options) = @_;
return "CPU '" . $options{instance_value}->{display} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);

View File

@ -41,7 +41,7 @@ my $thresholds = {
['Not Available', 'CRITICAL'], ['Not Available', 'CRITICAL'],
['Broken', 'CRITICAL'], ['Broken', 'CRITICAL'],
['Not Exist', 'CRITICAL'], ['Not Exist', 'CRITICAL'],
['Unknown', 'UNKNOWN'], ['Unknown', 'UNKNOWN']
], ],
}; };
@ -50,20 +50,20 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "hostname:s" => { name => 'hostname' },
"hostname:s" => { name => 'hostname' }, "ssh-option:s@" => { name => 'ssh_option' },
"ssh-option:s@" => { name => 'ssh_option' }, "ssh-path:s" => { name => 'ssh_path' },
"ssh-path:s" => { name => 'ssh_path' }, "ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, "timeout:s" => { name => 'timeout', default => 30 },
"timeout:s" => { name => 'timeout', default => 30 }, "command:s" => { name => 'command', default => 'show' },
"command:s" => { name => 'command', default => 'show' }, "command-path:s" => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => 'disks' },
"command-options:s" => { name => 'command_options', default => 'disks' }, "filter:s@" => { name => 'filter' },
"filter:s@" => { name => 'filter' }, "threshold-overload:s@" => { name => 'threshold_overload' },
"threshold-overload:s@" => { name => 'threshold_overload' }, "no-component:s" => { name => 'no_component' }
"no-component:s" => { name => 'no_component' }, });
});
$self->{no_components} = undef; $self->{no_components} = undef;
return $self; return $self;
} }

View File

@ -38,38 +38,38 @@ sub set_counters {
key_values => [ { name => 'read_iops' }, { name => 'display' } ], key_values => [ { name => 'read_iops' }, { name => 'display' } ],
output_template => 'Read IOPS : %d', output_template => 'Read IOPS : %d',
perfdatas => [ perfdatas => [
{ label => 'read_iops', value => 'read_iops', template => '%d', { label => 'read_iops', template => '%d',
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-iops', nlabel => 'port.io.write.usage.iops', set => { { label => 'write-iops', nlabel => 'port.io.write.usage.iops', set => {
key_values => [ { name => 'write_iops' }, { name => 'display' } ], key_values => [ { name => 'write_iops' }, { name => 'display' } ],
output_template => 'Write IOPS : %d', output_template => 'Write IOPS : %d',
perfdatas => [ perfdatas => [
{ label => 'write_iops', value => 'write_iops', template => '%d', { label => 'write_iops', template => '%d',
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'read-traffic', nlabel => 'port.traffic.read.usage.bitspersecond', set => { { label => 'read-traffic', nlabel => 'port.traffic.read.usage.bitspersecond', set => {
key_values => [ { name => 'read_traffic' }, { name => 'display' } ], key_values => [ { name => 'read_traffic' }, { name => 'display' } ],
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2, output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'read_traffic', value => 'read_traffic', template => '%d', { label => 'read_traffic', template => '%d',
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-traffic', nlabel => 'port.traffic.write.usage.bitspersecond', set => { { label => 'write-traffic', nlabel => 'port.traffic.write.usage.bitspersecond', set => {
key_values => [ { name => 'write_traffic' }, { name => 'display' } ], key_values => [ { name => 'write_traffic' }, { name => 'display' } ],
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2, output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'write_traffic', value => 'write_traffic', template => '%d', { label => 'write_traffic', template => '%d',
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, }
]; ];
} }

View File

@ -100,7 +100,7 @@ sub set_counters {
output_template => 'Status : %s', output_error_template => 'Status : %s', output_template => 'Status : %s', output_error_template => 'Status : %s',
output_use => 'status', output_use => 'status',
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'), closure_custom_threshold_check => $self->can('custom_threshold_output')
} }
}, },
{ label => 'usage', nlabel => 'raidgroup.space.usage.bytes', set => { { label => 'usage', nlabel => 'raidgroup.space.usage.bytes', set => {
@ -108,9 +108,9 @@ sub set_counters {
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'), closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'), closure_custom_threshold_check => $self->can('custom_usage_threshold')
} }
}, }
]; ];
} }

View File

@ -26,6 +26,12 @@ use strict;
use warnings; use warnings;
use centreon::plugins::misc; use centreon::plugins::misc;
sub prefix_volume_output {
my ($self, %options) = @_;
return "Volume '" . $options{instance_value}->{display} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -38,45 +44,45 @@ sub set_counters {
key_values => [ { name => 'read_iops' }, { name => 'display' } ], key_values => [ { name => 'read_iops' }, { name => 'display' } ],
output_template => 'Read IOPS : %d', output_template => 'Read IOPS : %d',
perfdatas => [ perfdatas => [
{ label => 'read_iops', value => 'read_iops', template => '%d', { label => 'read_iops', template => '%d',
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-iops', nlabel => 'volume.io.write.usage.iops', set => { { label => 'write-iops', nlabel => 'volume.io.write.usage.iops', set => {
key_values => [ { name => 'write_iops' }, { name => 'display' } ], key_values => [ { name => 'write_iops' }, { name => 'display' } ],
output_template => 'Write IOPS : %d', output_template => 'Write IOPS : %d',
perfdatas => [ perfdatas => [
{ label => 'write_iops', value => 'write_iops', template => '%d', { label => 'write_iops', template => '%d',
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'read-traffic', nlabel => 'volume.traffic.read.usage.bitspersecond', set => { { label => 'read-traffic', nlabel => 'volume.traffic.read.usage.bitspersecond', set => {
key_values => [ { name => 'read_throughput' }, { name => 'display' } ], key_values => [ { name => 'read_throughput' }, { name => 'display' } ],
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2, output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'read_throughput', value => 'read_throughput', template => '%d', { label => 'read_throughput', template => '%d',
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-traffic', nlabel => 'volume.traffic.write.usage.bitspersecond', set => { { label => 'write-traffic', nlabel => 'volume.traffic.write.usage.bitspersecond', set => {
key_values => [ { name => 'write_throughput' }, { name => 'display' } ], key_values => [ { name => 'write_throughput' }, { name => 'display' } ],
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2, output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2,
perfdatas => [ perfdatas => [
{ label => 'write_throughput', value => 'write_throughput', template => '%d', { label => 'write_throughput', template => '%d',
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'read-response-time', nlabel => 'volume.io.read.time.response.milliseconds', set => { { label => 'read-response-time', nlabel => 'volume.io.read.time.response.milliseconds', set => {
key_values => [ { name => 'read_response_time' }, { name => 'display' } ], key_values => [ { name => 'read_response_time' }, { name => 'display' } ],
output_template => 'Read Response Time : %d ms', output_template => 'Read Response Time : %d ms',
perfdatas => [ perfdatas => [
{ label => 'read_response_time', value => 'read_response_time', template => '%d', { label => 'read_response_time', template => '%d',
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-response-time', nlabel => 'volume.io.write.time.response.milliseconds', set => { { label => 'write-response-time', nlabel => 'volume.io.write.time.response.milliseconds', set => {
@ -92,62 +98,56 @@ sub set_counters {
key_values => [ { name => 'read_processing_time' }, { name => 'display' } ], key_values => [ { name => 'read_processing_time' }, { name => 'display' } ],
output_template => 'Read Processing Time : %d ms', output_template => 'Read Processing Time : %d ms',
perfdatas => [ perfdatas => [
{ label => 'read_processing_time', value => 'read_processing_time', template => '%d', { label => 'read_processing_time', template => '%d',
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-processing-time', nlabel => 'volume.io.write.time.processing.milliseconds', set => { { label => 'write-processing-time', nlabel => 'volume.io.write.time.processing.milliseconds', set => {
key_values => [ { name => 'write_processing_time' }, { name => 'display' } ], key_values => [ { name => 'write_processing_time' }, { name => 'display' } ],
output_template => 'Write Processing Time : %d ms', output_template => 'Write Processing Time : %d ms',
perfdatas => [ perfdatas => [
{ label => 'write_processing_time', value => 'write_processing_time', template => '%d', { label => 'write_processing_time', template => '%d',
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'read-cache-hit-rate', nlabel => 'volume.io.read.cache.hits.percentage', set => { { label => 'read-cache-hit-rate', nlabel => 'volume.io.read.cache.hits.percentage', set => {
key_values => [ { name => 'read_cache_hit_rate' }, { name => 'display' } ], key_values => [ { name => 'read_cache_hit_rate' }, { name => 'display' } ],
output_template => 'Read Cache Hit Rate : %d %%', output_template => 'Read Cache Hit Rate : %d %%',
perfdatas => [ perfdatas => [
{ label => 'read_cache_hit_rate', value => 'read_cache_hit_rate', template => '%d', { label => 'read_cache_hit_rate', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, },
{ label => 'write-cache-hit-rate', nlabel => 'volume.io.write.cache.hits.percentage', set => { { label => 'write-cache-hit-rate', nlabel => 'volume.io.write.cache.hits.percentage', set => {
key_values => [ { name => 'write_cache_hit_rate' }, { name => 'display' } ], key_values => [ { name => 'write_cache_hit_rate' }, { name => 'display' } ],
output_template => 'Write Cache Hit Rate : %d %%', output_template => 'Write Cache Hit Rate : %d %%',
perfdatas => [ perfdatas => [
{ label => 'write_cache_hit_rate', value => 'write_cache_hit_rate', template => '%d', { label => 'write_cache_hit_rate', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }
], ]
} }
}, }
]; ];
} }
sub prefix_volume_output {
my ($self, %options) = @_;
return "Volume '" . $options{instance_value}->{display} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' }, 'hostname:s' => { name => 'hostname' },
"ssh-option:s@" => { name => 'ssh_option' }, 'ssh-option:s@' => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' }, 'ssh-path:s' => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, 'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 }, 'timeout:s' => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'show' }, 'command:s' => { name => 'command', default => 'show' },
"command-path:s" => { name => 'command_path' }, 'command-path:s' => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => ' performance -type host-io' }, 'command-options:s' => { name => 'command_options', default => ' performance -type host-io' },
"filter-name:s" => { name => 'filter_name' }, 'filter-name:s' => { name => 'filter_name' }
}); });
return $self; return $self;
@ -202,11 +202,13 @@ sub manage_selection {
} }
next if (/----|Name/i); next if (/----|Name/i);
my $value = centreon::plugins::misc::trim($_); my $value = centreon::plugins::misc::trim($_);
my @matches = split /\s+/, $value; my @matches = split(/\s+/, $value);
next if (!defined($matches[1]));
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$matches[1] !~ /$self->{option_results}->{filter_name}/) { $matches[1] !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $matches[1] . "': no matching filter name."); $self->{output}->output_add(long_msg => "Skipping '" . $matches[1] . "': no matching filter name.", debug => 1);
next; next;
} }