(plugin) hardware::ups::powerware::snmp - mode input-lines fix wrong threshold (#3962)
This commit is contained in:
parent
67e668cdf8
commit
70b1de5e13
|
@ -46,41 +46,41 @@ sub set_counters {
|
|||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
}
|
||||
},
|
||||
{ label => 'charge-remaining', , nlabel => 'battery.charge.remaining.percent', set => {
|
||||
key_values => [ { name => 'xupsBatCapacity' } ],
|
||||
output_template => 'remaining capacity: %s %%',
|
||||
perfdatas => [
|
||||
{ value => 'xupsBatCapacity', template => '%s', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ template => '%s', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'charge-remaining-minutes', nlabel => 'battery.charge.remaining.minutes', display_ok => 0, set => {
|
||||
key_values => [ { name => 'xupsBatTimeRemaining' } ],
|
||||
output_template => 'remaining time: %s minutes',
|
||||
perfdatas => [
|
||||
{ value => 'xupsBatTimeRemaining', template => '%s', min => 0, unit => 'm' },
|
||||
],
|
||||
{ template => '%s', min => 0, unit => 'm' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'current', nlabel => 'battery.current.ampere', display_ok => 0, set => {
|
||||
key_values => [ { name => 'xupsBatCurrent', no_value => 0 } ],
|
||||
output_template => 'current: %s A',
|
||||
perfdatas => [
|
||||
{ value => 'xupsBatCurrent', template => '%s', unit => 'A' },
|
||||
],
|
||||
{ template => '%s', unit => 'A' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'voltage', nlabel => 'battery.voltage.volt', display_ok => 0, set => {
|
||||
key_values => [ { name => 'xupsBatVoltage', no_value => 0 } ],
|
||||
output_template => 'voltage: %s V',
|
||||
perfdatas => [
|
||||
{ value => 'xupsBatVoltage', template => '%s', unit => 'V' },
|
||||
],
|
||||
{ template => '%s', unit => 'V' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ sub new {
|
|||
$options{options}->add_options(arguments => {
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /batteryDischarging/i' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -108,7 +108,7 @@ sub check_options {
|
|||
my $map_battery_status = {
|
||||
1 => 'batteryCharging', 2 => 'batteryDischarging',
|
||||
3 => 'batteryFloating', 4 => 'batteryResting',
|
||||
5 => 'unknown',
|
||||
5 => 'unknown'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
|
@ -116,12 +116,12 @@ my $mapping = {
|
|||
xupsBatVoltage => { oid => '.1.3.6.1.4.1.534.1.2.2' }, # in V
|
||||
xupsBatCurrent => { oid => '.1.3.6.1.4.1.534.1.2.3' }, # in dA
|
||||
xupsBatCapacity => { oid => '.1.3.6.1.4.1.534.1.2.4' },
|
||||
xupsBatteryAbmStatus => { oid => '.1.3.6.1.4.1.534.1.2.5', map => $map_battery_status },
|
||||
xupsBatteryAbmStatus => { oid => '.1.3.6.1.4.1.534.1.2.5', map => $map_battery_status }
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
||||
nothing_quit => 1
|
||||
|
|
|
@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub prefix_iline_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Input Line '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -84,12 +90,6 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_iline_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Input Line '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
xupsInputVoltage => { oid => '.1.3.6.1.4.1.534.1.3.4.1.2' }, # in V
|
||||
xupsInputCurrent => { oid => '.1.3.6.1.4.1.534.1.3.4.1.3' }, # in A
|
||||
|
@ -145,15 +145,15 @@ sub manage_selection {
|
|||
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => '0');
|
||||
|
||||
$result->{xupsInputFrequency} = defined($result->{xupsInputFrequency}) ? ($result->{xupsInputFrequency} * 0.1) : 0;
|
||||
$self->{global} = { %$result };
|
||||
$self->{global} = $result;
|
||||
|
||||
$result = $options{snmp}->map_instance(mapping => $mapping3, results => $snmp_result, instance => '0');
|
||||
if ((!defined($self->{option_results}->{'warning-voltage'}) || $self->{option_results}->{'warning-voltage'} eq '') &&
|
||||
(!defined($self->{option_results}->{'critical-voltage'}) || $self->{option_results}->{'critical-voltage'} eq '')
|
||||
) {
|
||||
my $th = '';
|
||||
$th .= $result->{upsConfigHighVoltageTransferPoint} if (defined($result->{upsConfigHighVoltageTransferPoint}) && $result->{upsConfigHighVoltageTransferPoint} =~ /\d+/);
|
||||
$th = $result->{upsConfigLowVoltageTransferPoint} . ':' . $th if (defined($result->{upsConfigLowVoltageTransferPoint}) && $result->{upsConfigLowVoltageTransferPoint} =~ /\d+/);
|
||||
$th .= $result->{upsConfigHighVoltageTransferPoint} if (defined($result->{upsConfigHighVoltageTransferPoint}) && $result->{upsConfigHighVoltageTransferPoint} =~ /\d+/ && $result->{upsConfigHighVoltageTransferPoint} != 0);
|
||||
$th = $result->{upsConfigLowVoltageTransferPoint} . ':' . $th if (defined($result->{upsConfigLowVoltageTransferPoint}) && $result->{upsConfigLowVoltageTransferPoint} =~ /\d+/ && $result->{upsConfigLowVoltageTransferPoint} != 0);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-voltage', value => $th) if ($th ne '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub prefix_oline_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Output Line '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -38,20 +44,18 @@ sub set_counters {
|
|||
key_values => [ { name => 'xupsOutputLoad', no_value => -1 } ],
|
||||
output_template => 'Load : %.2f %%',
|
||||
perfdatas => [
|
||||
{ value => 'xupsOutputLoad', template => '%.2f',
|
||||
min => 0, max => 100 },
|
||||
],
|
||||
{ template => '%.2f', min => 0, max => 100 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'frequence', nlabel => 'lines.output.frequence.hertz', set => {
|
||||
key_values => [ { name => 'xupsOutputFrequency', no_value => 0 } ],
|
||||
output_template => 'Frequence : %.2f Hz',
|
||||
perfdatas => [
|
||||
{ value => 'xupsOutputFrequency', template => '%.2f',
|
||||
unit => 'Hz' },
|
||||
],
|
||||
{ template => '%.2f', unit => 'Hz' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{oline} = [
|
||||
|
@ -59,29 +63,26 @@ sub set_counters {
|
|||
key_values => [ { name => 'xupsOutputCurrent', no_value => 0 } ],
|
||||
output_template => 'Current : %.2f A',
|
||||
perfdatas => [
|
||||
{ value => 'xupsOutputCurrent', template => '%.2f',
|
||||
min => 0, unit => 'A', label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'voltage', nlabel => 'line.output.voltage.volt', set => {
|
||||
key_values => [ { name => 'xupsOutputVoltage', no_value => 0 } ],
|
||||
output_template => 'Voltage : %.2f V',
|
||||
perfdatas => [
|
||||
{ value => 'xupsOutputVoltage', template => '%.2f',
|
||||
unit => 'V', label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%.2f', unit => 'V', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'power', nlabel => 'line.output.power.watt', set => {
|
||||
key_values => [ { name => 'xupsOutputWatts', no_value => 0 } ],
|
||||
output_template => 'Power: %.2f W',
|
||||
perfdatas => [
|
||||
{ value => 'xupsOutputWatts', template => '%.2f',
|
||||
unit => 'W', label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%.2f', unit => 'W', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -96,20 +97,14 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_oline_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Output Line '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
xupsOutputVoltage => { oid => '.1.3.6.1.4.1.534.1.4.4.1.2' }, # in V
|
||||
xupsOutputCurrent => { oid => '.1.3.6.1.4.1.534.1.4.4.1.3' }, # in A
|
||||
xupsOutputWatts => { oid => '.1.3.6.1.4.1.534.1.4.4.1.4' }, # in W
|
||||
xupsOutputWatts => { oid => '.1.3.6.1.4.1.534.1.4.4.1.4' } # in W
|
||||
};
|
||||
my $mapping2 = {
|
||||
xupsOutputLoad => { oid => '.1.3.6.1.4.1.534.1.4.1' }, # in %
|
||||
xupsOutputFrequency => { oid => '.1.3.6.1.4.1.534.1.4.2' }, # in dHZ
|
||||
xupsOutputFrequency => { oid => '.1.3.6.1.4.1.534.1.4.2' } # in dHZ
|
||||
};
|
||||
|
||||
my $oid_xupsOutput = '.1.3.6.1.4.1.534.1.4';
|
||||
|
@ -123,16 +118,16 @@ sub manage_selection {
|
|||
oid => $oid_xupsOutput,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$oid_xupsOutputEntry\.\d+\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if (defined($self->{oline}->{$instance}));
|
||||
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
$self->{oline}->{$instance} = { display => $instance, %$result };
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{oline}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No output lines found.");
|
||||
$self->{output}->option_exit();
|
||||
|
|
Loading…
Reference in New Issue