From 0535e5b3ca61144d77278e02f7547085a92afaf1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 19 Dec 2019 08:57:56 +0100 Subject: [PATCH] Fix #1765 --- .../ups/powerware/snmp/mode/inputlines.pm | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/hardware/ups/powerware/snmp/mode/inputlines.pm b/hardware/ups/powerware/snmp/mode/inputlines.pm index 6b507ec53..9830ce8e1 100644 --- a/hardware/ups/powerware/snmp/mode/inputlines.pm +++ b/hardware/ups/powerware/snmp/mode/inputlines.pm @@ -36,7 +36,7 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'frequence', nlabel => 'lines.input.frequence.hertz', set => { key_values => [ { name => 'xupsInputFrequency', no_value => 0 } ], - output_template => 'Frequence : %.2f Hz', + output_template => 'frequence: %.2f Hz', perfdatas => [ { value => 'xupsInputFrequency_absolute', template => '%.2f', unit => 'Hz' }, @@ -48,7 +48,7 @@ sub set_counters { $self->{maps_counters}->{iline} = [ { label => 'current', nlabel => 'line.input.current.ampere', set => { key_values => [ { name => 'xupsInputCurrent', no_value => 0 } ], - output_template => 'Current : %.2f A', + output_template => 'current: %.2f A', perfdatas => [ { value => 'xupsInputCurrent_absolute', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, @@ -57,7 +57,7 @@ sub set_counters { }, { label => 'voltage', nlabel => 'line.input.voltage.volt', set => { key_values => [ { name => 'xupsInputVoltage', no_value => 0 } ], - output_template => 'Voltage : %.2f V', + output_template => 'voltage: %.2f V', perfdatas => [ { value => 'xupsInputVoltage_absolute', template => '%.2f', unit => 'V', label_extra_instance => 1 }, @@ -66,7 +66,7 @@ sub set_counters { }, { label => 'power', nlabel => 'line.input.power.watt', set => { key_values => [ { name => 'xupsInputWatts', no_value => 0 } ], - output_template => 'Power: %.2f W', + output_template => 'power: %.2f W', perfdatas => [ { value => 'xupsInputWatts_absolute', template => '%.2f', unit => 'W', label_extra_instance => 1 }, @@ -101,8 +101,13 @@ my $mapping = { my $mapping2 = { xupsInputFrequency => { oid => '.1.3.6.1.4.1.534.1.3.1' }, # in dHZ }; +my $mapping3 = { + upsConfigLowVoltageTransferPoint => { oid => '.1.3.6.1.2.1.33.1.9.9' }, + upsConfigHighVoltageTransferPoint => { oid => '.1.3.6.1.2.1.33.1.9.10' }, +}; my $oid_xupsInputEntry = '.1.3.6.1.4.1.534.1.3.4.1'; +my $oid_upsConfig = '.1.3.6.1.2.1.33.1.9'; sub manage_selection { my ($self, %options) = @_; @@ -111,8 +116,10 @@ sub manage_selection { oids => [ { oid => $mapping2->{xupsInputFrequency}->{oid} }, { oid => $oid_xupsInputEntry }, + { oid => $oid_upsConfig, start => $mapping3->{upsConfigLowVoltageTransferPoint}->{oid}, end => $mapping3->{upsConfigHighVoltageTransferPoint}->{oid} }, ], - return_type => 1, nothing_quit => 1 + return_type => 1, + nothing_quit => 1 ); $self->{iline} = {}; @@ -120,7 +127,7 @@ sub manage_selection { next if ($oid !~ /^$oid_xupsInputEntry\.\d+\.(.*)$/); my $instance = $1; next if (defined($self->{iline}->{$instance})); - + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); $self->{iline}->{$instance} = { display => $instance, %$result }; } @@ -134,6 +141,16 @@ sub manage_selection { $result->{xupsInputFrequency} = defined($result->{xupsInputFrequency}) ? ($result->{xupsInputFrequency} * 0.1) : 0; $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+/); + $self->{perfdata}->threshold_validate(label => 'critical-voltage', value => $th) if ($th ne ''); + } } 1; @@ -146,14 +163,9 @@ Check Input lines metrics (frequence, voltage, current and true power) (XUPS-MIB =over 8 -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'frequence', 'voltage', 'current', 'power'. - -=item B<--critical-*> - -Threshold critical. +Thresholds. Can be: 'frequence', 'voltage', 'current', 'power'. =back