mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-30 00:55:18 +02:00
fix #2540
This commit is contained in:
parent
fd565f2f70
commit
cf199cbdba
@ -36,7 +36,7 @@ sub custom_load_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"charge remaining: %s%% (%s minutes remaining)",
|
||||
'charge remaining: %s%% (%s minutes remaining)',
|
||||
$self->{result_values}->{charge_remain},
|
||||
$self->{result_values}->{minute_remain}
|
||||
);
|
||||
@ -46,7 +46,7 @@ sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } },
|
||||
{ name => 'global', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
@ -129,7 +129,7 @@ my $mapping = {
|
||||
charge_remain => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.4' }, # upsEstimatedChargeRemaining
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.5' }, # upsBatteryVoltage (dV)
|
||||
temperature => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.6' }, # upsBatteryTemperature (degrees Centigrade)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.8' } # upsBatteryCurrent (dA)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.8' } # upsBatteryCurrent (dA)
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
@ -140,8 +140,10 @@ sub manage_selection {
|
||||
nothing_quit => 1
|
||||
);
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
|
||||
$self->{global}->{current} = (defined($self->{global}->{current}) && $self->{global}->{current} =~ /\d/) ? $self->{global}->{current} * 0.1 : 0;
|
||||
$self->{global}->{voltage} = (defined($self->{global}->{voltage}) && $self->{global}->{voltage} =~ /\d/) ? $self->{global}->{voltage} * 0.1 : 0;
|
||||
$self->{global}->{current} = (defined($self->{global}->{current}) && $self->{global}->{current} =~ /\d/ && $self->{global}->{current} != -1 && $self->{global}->{current} != 65535) ?
|
||||
$self->{global}->{current} * 0.1 : 0;
|
||||
$self->{global}->{voltage} = (defined($self->{global}->{voltage}) && $self->{global}->{voltage} =~ /\d/ && $self->{global}->{voltage} != -1 && $self->{global}->{voltage} != 65535) ?
|
||||
$self->{global}->{voltage} * 0.1 : 0;
|
||||
$self->{global}->{temperature} = (defined($self->{global}->{temperature}) && $self->{global}->{temperature} =~ /\d/) ? $self->{global}->{temperature} * 0.1 : 0;
|
||||
$self->{global}->{minute_remain} = (defined($self->{global}->{minute_remain}) && $self->{global}->{minute_remain} =~ /\d/) ? $self->{global}->{minute_remain} : 'unknown';
|
||||
$self->{global}->{charge_remain} = (defined($self->{global}->{charge_remain}) && $self->{global}->{charge_remain} =~ /\d/) ? $self->{global}->{charge_remain} : undef;
|
||||
|
@ -110,7 +110,7 @@ sub manage_selection {
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
foreach (('current', 'voltage')) {
|
||||
$result->{$_} = 0 if (defined($result->{$_}) && ($result->{$_} eq '' || $result->{$_} == -1 || $result->{$_} == -65535));
|
||||
$result->{$_} = 0 if (defined($result->{$_}) && ($result->{$_} eq '' || $result->{$_} == -1 || $result->{$_} == 65535));
|
||||
$result->{$_} *= 0.1;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ sub manage_selection {
|
||||
}
|
||||
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => 0);
|
||||
$self->{global}->{frequency} = defined($self->{global}->{frequency}) && $self->{global}->{frequency} != -1 && $self->{global}->{frequency} != -65535
|
||||
$self->{global}->{frequency} = defined($self->{global}->{frequency}) && $self->{global}->{frequency} != -1 && $self->{global}->{frequency} != 65535
|
||||
? ($self->{global}->{frequency} * 0.1) : 0;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ my $map_status = {
|
||||
my $mapping = {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.2' }, # upsOutputVoltage (Volt)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.3' }, # upsOutputCurrent (dA)
|
||||
percent_load => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.4' } # upsOutputPercentLoad
|
||||
percent_load => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.4' } # upsOutputPercentLoad
|
||||
};
|
||||
my $mapping2 = {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.1', map => $map_status } # upsOutputSource
|
||||
@ -133,10 +133,11 @@ sub manage_selection {
|
||||
next if (defined($self->{oline}->{$instance}));
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
if (defined($self->{option_results}->{ignore_zero_counters})) {
|
||||
foreach (keys %$result) {
|
||||
delete $result->{$_} if ($result->{$_} == 0);
|
||||
}
|
||||
foreach (keys %$result) {
|
||||
delete $result->{$_} if (
|
||||
(defined($self->{option_results}->{ignore_zero_counters}) && $result->{$_} == 0) ||
|
||||
($result->{$_} == -1 || $result->{$_} == 65535)
|
||||
);
|
||||
}
|
||||
$result->{current} *= 0.1 if (defined($result->{current}));
|
||||
$result->{voltage} *= 0.1 if (defined($result->{voltage}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user