Fix #1764
This commit is contained in:
parent
fd365411c7
commit
22be9f084f
|
@ -50,7 +50,7 @@ sub set_counters {
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'voltage', set => {
|
{ label => 'voltage', set => {
|
||||||
key_values => [ { name => 'upsAdvInputLineVoltage' } ],
|
key_values => [ { name => 'upsAdvInputLineVoltage' } ],
|
||||||
output_template => 'Voltage : %s V',
|
output_template => 'Voltage: %s V',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'voltage', value => 'upsAdvInputLineVoltage_absolute', template => '%s',
|
{ label => 'voltage', value => 'upsAdvInputLineVoltage_absolute', template => '%s',
|
||||||
unit => 'V' },
|
unit => 'V' },
|
||||||
|
@ -59,7 +59,7 @@ sub set_counters {
|
||||||
},
|
},
|
||||||
{ label => 'frequence', set => {
|
{ label => 'frequence', set => {
|
||||||
key_values => [ { name => 'upsAdvInputFrequency' } ],
|
key_values => [ { name => 'upsAdvInputFrequency' } ],
|
||||||
output_template => 'Frequence : %s Hz',
|
output_template => 'Frequence: %s Hz',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'frequence', value => 'upsAdvInputFrequency_absolute', template => '%s',
|
{ label => 'frequence', value => 'upsAdvInputFrequency_absolute', template => '%s',
|
||||||
unit => 'Hz' },
|
unit => 'Hz' },
|
||||||
|
@ -83,8 +83,8 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '' },
|
'critical-status:s' => { name => 'critical_status', default => '' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -104,20 +104,31 @@ my %map_status = (
|
||||||
);
|
);
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
upsAdvInputLineVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.1' },
|
upsAdvInputLineVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.1' },
|
||||||
upsAdvInputFrequency => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.4' },
|
upsAdvInputFrequency => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.4' },
|
||||||
upsAdvInputLineFailCause => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.5', map => \%map_status },
|
upsAdvInputLineFailCause => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.5', map => \%map_status },
|
||||||
|
upsAdvConfigHighTransferVolt => { oid => '.1.3.6.1.4.1.318.1.1.1.5.2.2' },
|
||||||
|
upsAdvConfigLowTransferVolt => { oid => '.1.3.6.1.4.1.318.1.1.1.5.2.3' },
|
||||||
};
|
};
|
||||||
my $oid_upsAdvInput = '.1.3.6.1.4.1.318.1.1.1.3.2';
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{global} = {};
|
$self->{global} = {};
|
||||||
my $snmp_result = $options{snmp}->get_table(oid => $oid_upsAdvInput,
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
nothing_quit => 1);
|
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
|
my $result = $options{snmp}->map_instance(mapping => $mapping, 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->{upsAdvConfigHighTransferVolt} if (defined($result->{upsAdvConfigHighTransferVolt}) && $result->{upsAdvConfigHighTransferVolt} =~ /\d+/);
|
||||||
|
$th = $result->{upsAdvConfigLowTransferVolt} . ':' . $th if (defined($result->{upsAdvConfigLowTransferVolt}) && $result->{upsAdvConfigLowTransferVolt} =~ /\d+/);
|
||||||
|
$self->{perfdata}->threshold_validate(label => 'critical-voltage', value => $th) if ($th ne '');
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $name (keys %{$mapping}) {
|
foreach my $name (keys %{$mapping}) {
|
||||||
$self->{global}->{$name} = $result->{$name};
|
$self->{global}->{$name} = $result->{$name};
|
||||||
|
@ -149,14 +160,9 @@ Can used special variables like: %{last_cause}
|
||||||
Set critical threshold for status (Default: '').
|
Set critical threshold for status (Default: '').
|
||||||
Can used special variables like: %{last_cause}
|
Can used special variables like: %{last_cause}
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Threshold warning.
|
Thresholds.
|
||||||
Can be: 'voltage', 'frequence'.
|
|
||||||
|
|
||||||
=item B<--critical-*>
|
|
||||||
|
|
||||||
Threshold critical.
|
|
||||||
Can be: 'voltage', 'frequence'.
|
Can be: 'voltage', 'frequence'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
Loading…
Reference in New Issue