mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 23:54:18 +02:00
enh(ups/powerware): output-source mode - can use empty option (#3095)
This commit is contained in:
parent
f847fee903
commit
40e1f6dc02
@ -30,8 +30,8 @@ my $oid_xupsOutputSource = '.1.3.6.1.4.1.534.1.4.5.0';
|
|||||||
my $thresholds = {
|
my $thresholds = {
|
||||||
osource => [
|
osource => [
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['.*', 'CRITICAL'],
|
['.*', 'CRITICAL']
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
my %map_osource_status = (
|
my %map_osource_status = (
|
||||||
@ -40,23 +40,22 @@ my %map_osource_status = (
|
|||||||
3 => 'normal',
|
3 => 'normal',
|
||||||
4 => 'bypass',
|
4 => 'bypass',
|
||||||
5 => 'battery',
|
5 => 'battery',
|
||||||
6 => 'booster',
|
6 => 'booster',
|
||||||
7 => 'reducer',
|
7 => 'reducer',
|
||||||
8 => 'parallelCapacity',
|
8 => 'parallelCapacity',
|
||||||
9 => 'parallelRedundant',
|
9 => 'parallelRedundant',
|
||||||
10 => 'highEfficiencyMode',
|
10 => 'highEfficiencyMode',
|
||||||
11 => 'maintenanceBypass',
|
11 => 'maintenanceBypass'
|
||||||
);
|
);
|
||||||
|
|
||||||
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 => {
|
||||||
{
|
'threshold-overload:s@' => { name => 'threshold_overload' }
|
||||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -64,9 +63,11 @@ sub new {
|
|||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
$self->{overload_th} = {};
|
$self->{overload_th} = {};
|
||||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||||
|
next if ($val eq '');
|
||||||
|
|
||||||
if ($val !~ /^(.*?),(.*)$/) {
|
if ($val !~ /^(.*?),(.*)$/) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -87,9 +88,13 @@ sub run {
|
|||||||
|
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_xupsOutputSource], nothing_quit => 1);
|
my $result = $self->{snmp}->get_leef(oids => [$oid_xupsOutputSource], nothing_quit => 1);
|
||||||
my $exit = $self->get_severity(section => 'osource', value => $map_osource_status{$result->{$oid_xupsOutputSource}});
|
my $exit = $self->get_severity(section => 'osource', value => $map_osource_status{$result->{$oid_xupsOutputSource}});
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Output source status is %s",
|
severity => $exit,
|
||||||
$map_osource_status{$result->{$oid_xupsOutputSource}}));
|
short_msg => sprintf(
|
||||||
|
"Output source status is %s",
|
||||||
|
$map_osource_status{$result->{$oid_xupsOutputSource}}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
@ -99,7 +104,7 @@ sub run {
|
|||||||
sub get_severity {
|
sub get_severity {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
my $status = 'UNKNOWN'; # default
|
my $status = 'UNKNOWN'; # default
|
||||||
|
|
||||||
if (defined($self->{overload_th}->{$options{section}})) {
|
if (defined($self->{overload_th}->{$options{section}})) {
|
||||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||||
if ($options{value} =~ /$_->{filter}/i) {
|
if ($options{value} =~ /$_->{filter}/i) {
|
||||||
@ -114,7 +119,7 @@ sub get_severity {
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user