mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-23 21:55:16 +02:00
enh h3c hardware mode to allow count thresholds (#1080)
* enh h3c hardware mode to allow count thresholds * + use ternary operator
This commit is contained in:
parent
e939f54562
commit
04bb08a6e6
@ -37,7 +37,7 @@ my %map_default_status = (
|
|||||||
33 => 'sfpBothError',
|
33 => 'sfpBothError',
|
||||||
41 => 'fanError',
|
41 => 'fanError',
|
||||||
51 => 'psuError',
|
51 => 'psuError',
|
||||||
61 => 'rpsError(',
|
61 => 'rpsError',
|
||||||
71 => 'moduleFaulty',
|
71 => 'moduleFaulty',
|
||||||
81 => 'sensorError',
|
81 => 'sensorError',
|
||||||
91 => 'hardwareFaulty',
|
91 => 'hardwareFaulty',
|
||||||
@ -64,10 +64,12 @@ sub check {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = $self->get_long_name(instance => $instance);
|
my $name = '';
|
||||||
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{$options{component}}->{total}++;
|
$self->{components}->{$options{component}}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance = %s]",
|
||||||
$options{component}, $name, $result->{EntityExtErrorStatus}, $instance));
|
ucfirst($options{component}), $name, $result->{EntityExtErrorStatus}, $instance));
|
||||||
my $exit = $self->get_severity(section => $options{component}, value => $result->{EntityExtErrorStatus});
|
my $exit = $self->get_severity(section => $options{component}, value => $result->{EntityExtErrorStatus});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
@ -52,7 +52,9 @@ sub check {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = $self->get_long_name(instance => $instance);
|
my $name = '';
|
||||||
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{fan}->{total}++;
|
$self->{components}->{fan}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]",
|
||||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
$name, $result->{EntityExtErrorStatus}, $instance));
|
||||||
|
@ -52,7 +52,9 @@ sub check {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = $self->get_long_name(instance => $instance);
|
my $name = '';
|
||||||
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{psu}->{total}++;
|
$self->{components}->{psu}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]",
|
||||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
$name, $result->{EntityExtErrorStatus}, $instance));
|
||||||
|
@ -65,7 +65,9 @@ sub check {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = $self->get_long_name(instance => $instance);
|
my $name = '';
|
||||||
|
$name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1);
|
||||||
|
$name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne '');
|
||||||
$self->{components}->{sensor}->{total}++;
|
$self->{components}->{sensor}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance = %s]",
|
||||||
|
@ -113,7 +113,8 @@ sub set_system {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$self->{components_path} = 'network::h3c::snmp::mode::components';
|
$self->{components_path} = 'network::h3c::snmp::mode::components';
|
||||||
$self->{components_module} = ['fan', 'psu', 'slot', 'temperature'];
|
$self->{components_module} = ['chassis', 'backplane', 'container', 'psu', 'fan', 'sensor',
|
||||||
|
'module', 'port', 'stack', 'cpu', 'other', 'unknown'];
|
||||||
|
|
||||||
$self->{mapping_name} = {
|
$self->{mapping_name} = {
|
||||||
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
||||||
@ -162,6 +163,7 @@ sub new {
|
|||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>
|
||||||
{
|
{
|
||||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
||||||
|
"short-name" => { name => 'short_name' },
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
@ -171,6 +173,8 @@ sub new {
|
|||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::check_options(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
$self->{short_name} = (defined($self->{option_results}->{short_name})) ? 1 : 0;
|
||||||
|
|
||||||
$self->{statefile_cache}->check_options(%options);
|
$self->{statefile_cache}->check_options(%options);
|
||||||
}
|
}
|
||||||
@ -211,6 +215,12 @@ sub write_cache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_short_name {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return $self->{results}->{$oid_entPhysicalEntry}->{$oid_entPhysicalName . '.' . $options{instance}};
|
||||||
|
}
|
||||||
|
|
||||||
sub get_long_name {
|
sub get_long_name {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -279,7 +289,7 @@ Check Hardware (Fans, Power Supplies, Module,...).
|
|||||||
=item B<--component>
|
=item B<--component>
|
||||||
|
|
||||||
Which component to check (Default: '.*').
|
Which component to check (Default: '.*').
|
||||||
Can be: 'fan', 'psu', 'other', 'unknown', 'sensor', 'chassis', 'backplane',
|
Can be: 'fan', 'psu', 'other', 'unknown', 'sensor', 'chassis', 'backplane',
|
||||||
'container', 'module', 'port', 'stack', 'cpu'.
|
'container', 'module', 'port', 'stack', 'cpu'.
|
||||||
|
|
||||||
=item B<--filter>
|
=item B<--filter>
|
||||||
@ -313,6 +323,18 @@ Example: --warning='temperature,.*,40'
|
|||||||
Set critical threshold for 'temperature' (syntax: type,regexp,threshold)
|
Set critical threshold for 'temperature' (syntax: type,regexp,threshold)
|
||||||
Example: --critical='temperature,.*,45'
|
Example: --critical='temperature,.*,45'
|
||||||
|
|
||||||
|
=item B<--warning-count-*>
|
||||||
|
|
||||||
|
Set warning threshold for component count.
|
||||||
|
Can be: 'fan', 'psu', 'other', 'unknown', 'sensor', 'chassis', 'backplane',
|
||||||
|
'container', 'module', 'port', 'stack', 'cpu'.
|
||||||
|
|
||||||
|
=item B<--critical-count-*>
|
||||||
|
|
||||||
|
Set critical threshold for component count.
|
||||||
|
Can be: 'fan', 'psu', 'other', 'unknown', 'sensor', 'chassis', 'backplane',
|
||||||
|
'container', 'module', 'port', 'stack', 'cpu'.
|
||||||
|
|
||||||
=item B<--reload-cache-time>
|
=item B<--reload-cache-time>
|
||||||
|
|
||||||
Time in seconds before reloading cache file (Default: 180).
|
Time in seconds before reloading cache file (Default: 180).
|
||||||
@ -320,4 +342,4 @@ Use '-1' to disable cache reload.
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user