enh(ups/powerware): output-source mode - can use empty option (#3095)

This commit is contained in:
qgarnier 2021-09-10 10:19:47 +02:00 committed by GitHub
parent 62cf7b5df1
commit e44aadcf00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,8 +30,8 @@ my $oid_xupsOutputSource = '.1.3.6.1.4.1.534.1.4.5.0';
my $thresholds = {
osource => [
['normal', 'OK'],
['.*', 'CRITICAL'],
],
['.*', 'CRITICAL']
]
};
my %map_osource_status = (
@ -45,7 +45,7 @@ my %map_osource_status = (
8 => 'parallelCapacity',
9 => 'parallelRedundant',
10 => 'highEfficiencyMode',
11 => 'maintenanceBypass',
11 => 'maintenanceBypass'
);
sub new {
@ -53,9 +53,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"threshold-overload:s@" => { name => 'threshold_overload' },
$options{options}->add_options(arguments => {
'threshold-overload:s@' => { name => 'threshold_overload' }
});
return $self;
@ -67,6 +66,8 @@ sub check_options {
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
next if ($val eq '');
if ($val !~ /^(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
@ -87,9 +88,13 @@ sub run {
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}});
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Output source status is %s",
$map_osource_status{$result->{$oid_xupsOutputSource}}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Output source status is %s",
$map_osource_status{$result->{$oid_xupsOutputSource}}
)
);
$self->{output}->display();
$self->{output}->exit();