enhance typo

This commit is contained in:
garnier-quentin 2020-04-03 14:57:02 +02:00
parent 58685519fc
commit e565cb8008
4 changed files with 60 additions and 43 deletions

View File

@ -33,32 +33,41 @@ my $oid_acsPowerSupply = '.1.3.6.1.4.1.10418.16.2.1.8';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_acsPowerSupply };
}
sub check_psu {
my ($self, %options) = @_;
return if ($self->check_filter(section => 'psu', instance => $options{instance}));
return if ($options{state} eq 'powerNotInstalled' &&
$self->absent_problem(section => 'psu', instance => $options{instance}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s.",
$options{instance}, $options{state}
));
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is %s.",
$options{instance}, $options{state}
)
);
my $exit = $self->get_severity(section => 'psu', value => $options{state});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
$options{instance}, $options{state}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Power supply '%s' status is %s",
$options{instance},
$options{state}
)
);
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
@ -68,4 +77,4 @@ sub check {
check_psu($self, state => $result->{acsPowerSupplyStatePw2}, instance => '2');
}
1;
1;

View File

@ -27,26 +27,26 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(psu)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
psu => [
['statePowerOn', 'OK'],
['statePowerOff', 'CRITICAL'],
['powerNotInstalled', 'OK'],
],
['powerNotInstalled', 'OK']
]
};
$self->{components_path} = 'hardware::kvm::avocent::acs::6000::snmp::mode::components';
$self->{components_module} = ['psu'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
@ -55,10 +55,9 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -101,4 +100,4 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(statePowerOn)$)'
=back
=cut
=cut

View File

@ -27,38 +27,48 @@ my %map_states = (1 => 'statePowerOn', 2 => 'statePowerOff', 9999 => 'powerNotIn
my $mapping = {
acsPowerSupplyStatePw1 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.2', map => \%map_states },
acsPowerSupplyStatePw2 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.3', map => \%map_states },
acsPowerSupplyStatePw2 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.3', map => \%map_states }
};
my $oid_acsPowerSupply = '.1.3.6.1.4.1.10418.26.2.1.8';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_acsPowerSupply };
}
sub check_psu {
my ($self, %options) = @_;
return if ($self->check_filter(section => 'psu', instance => $options{instance}));
return if ($options{state} eq 'powerNotInstalled' &&
$self->absent_problem(section => 'psu', instance => $options{instance}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s.",
$options{instance}, $options{state}
));
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is %s.",
$options{instance},
$options{state}
)
);
my $exit = $self->get_severity(section => 'psu', value => $options{state});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
$options{instance}, $options{state}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Power supply '%s' status is %s",
$options{instance},
$options{state}
)
);
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
@ -68,4 +78,4 @@ sub check {
check_psu($self, state => $result->{acsPowerSupplyStatePw2}, instance => '2');
}
1;
1;

View File

@ -27,17 +27,17 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(psu)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
psu => [
['statePowerOn', 'OK'],
['statePowerOff', 'CRITICAL'],
['powerNotInstalled', 'OK'],
],
['powerNotInstalled', 'OK']
]
};
$self->{components_path} = 'hardware::kvm::avocent::acs::8000::snmp::mode::components';
@ -55,10 +55,9 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
@ -101,4 +100,4 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(statePowerOn)$)'
=back
=cut
=cut