Skip to content

Commit

Permalink
+ Fix #225
Browse files Browse the repository at this point in the history
  • Loading branch information
garnier-quentin committed Dec 1, 2015
1 parent f64aa84 commit a0855a7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ sub run {

my $result = $self->{snmp}->get_table(oid => $oid_upsBattery, nothing_quit => 1);

my $current = defined($result->{$oid_upsBatteryCurrent}) ? $result->{$oid_upsBatteryCurrent} * 0.1 : 0;
my $voltage = defined($result->{$oid_upsBatteryVoltage}) ? $result->{$oid_upsBatteryVoltage} * 0.1 : 0;
my $current = (defined($result->{$oid_upsBatteryCurrent}) && $result->{$oid_upsBatteryCurrent} =~ /\d/) ?
$result->{$oid_upsBatteryCurrent} * 0.1 : 0;
my $voltage = (defined($result->{$oid_upsBatteryVoltage}) && $result->{$oid_upsBatteryVoltage} =~ /\d/) ?
$result->{$oid_upsBatteryVoltage} * 0.1 : 0;
my $temp = defined($result->{$oid_upsBatteryTemperature}) ? $result->{$oid_upsBatteryTemperature} : 0;
my $min_remain = defined($result->{$oid_upsEstimatedMinutesRemaining}) ? $result->{$oid_upsEstimatedMinutesRemaining} : 'unknown';
my $charge_remain = defined($result->{$oid_upsEstimatedChargeRemaining}) ? $result->{$oid_upsEstimatedChargeRemaining} : 'unknown';
my $min_remain = (defined($result->{$oid_upsEstimatedMinutesRemaining}) && $result->{$oid_upsEstimatedMinutesRemaining} =~ /\d/) ?
$result->{$oid_upsEstimatedMinutesRemaining} : 'unknown';
my $charge_remain = (defined($result->{$oid_upsEstimatedChargeRemaining}) && $result->{$oid_upsEstimatedChargeRemaining} =~ /\d/) ?
$result->{$oid_upsEstimatedChargeRemaining} : 'unknown';
my $status = defined($result->{$oid_upsBatteryStatus}) ? $result->{$oid_upsBatteryStatus} : 1; # we put unknown ???

$self->{output}->output_add(severity => ${$battery_status{$status}}[1],
Expand Down

0 comments on commit a0855a7

Please sign in to comment.