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
fc2760a77a
commit
6e433f98fb
|
@ -37,7 +37,7 @@ my %map_default_status = (
|
|||
33 => 'sfpBothError',
|
||||
41 => 'fanError',
|
||||
51 => 'psuError',
|
||||
61 => 'rpsError(',
|
||||
61 => 'rpsError',
|
||||
71 => 'moduleFaulty',
|
||||
81 => 'sensorError',
|
||||
91 => 'hardwareFaulty',
|
||||
|
@ -64,10 +64,12 @@ sub check {
|
|||
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->{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});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
|
|
|
@ -52,7 +52,9 @@ sub check {
|
|||
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->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]",
|
||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
||||
|
|
|
@ -52,7 +52,9 @@ sub check {
|
|||
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->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]",
|
||||
$name, $result->{EntityExtErrorStatus}, $instance));
|
||||
|
|
|
@ -65,7 +65,9 @@ sub check {
|
|||
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->{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_module} = ['fan', 'psu', 'slot', 'temperature'];
|
||||
$self->{components_module} = ['chassis', 'backplane', 'container', 'psu', 'fan', 'sensor',
|
||||
'module', 'port', 'stack', 'cpu', 'other', 'unknown'];
|
||||
|
||||
$self->{mapping_name} = {
|
||||
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
||||
|
@ -162,6 +163,7 @@ sub new {
|
|||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
||||
"short-name" => { name => 'short_name' },
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
|
@ -171,6 +173,8 @@ sub new {
|
|||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{short_name} = (defined($self->{option_results}->{short_name})) ? 1 : 0;
|
||||
|
||||
$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 {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -279,7 +289,7 @@ Check Hardware (Fans, Power Supplies, Module,...).
|
|||
=item B<--component>
|
||||
|
||||
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'.
|
||||
|
||||
=item B<--filter>
|
||||
|
@ -313,6 +323,18 @@ Example: --warning='temperature,.*,40'
|
|||
Set critical threshold for 'temperature' (syntax: type,regexp,threshold)
|
||||
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>
|
||||
|
||||
Time in seconds before reloading cache file (Default: 180).
|
||||
|
@ -320,4 +342,4 @@ Use '-1' to disable cache reload.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue