enhance apc input-lines
This commit is contained in:
parent
3f50262676
commit
ef48f61939
|
@ -24,20 +24,12 @@ use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf("Last input line fail cause is '%s'", $self->{result_values}->{last_cause});
|
return sprintf("last input line fail cause is '%s'", $self->{result_values}->{last_cause});
|
||||||
return $msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub custom_status_calc {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->{result_values}->{last_cause} = $options{new_datas}->{$self->{instance} . '_upsAdvInputLineFailCause'};
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
|
@ -49,26 +41,26 @@ sub set_counters {
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'voltage', set => {
|
{ label => 'voltage', set => {
|
||||||
key_values => [ { name => 'upsAdvInputLineVoltage' } ],
|
key_values => [ { name => 'voltage' } ],
|
||||||
output_template => 'Voltage: %s V',
|
output_template => 'voltage: %s V',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'voltage', value => 'upsAdvInputLineVoltage_absolute', template => '%s',
|
{ label => 'voltage', value => 'voltage_absolute', template => '%s',
|
||||||
unit => 'V' },
|
unit => 'V' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'frequence', set => {
|
{ label => 'frequence', set => {
|
||||||
key_values => [ { name => 'upsAdvInputFrequency' } ],
|
key_values => [ { name => 'frequency' } ],
|
||||||
output_template => 'Frequence: %s Hz',
|
output_template => 'frequence: %s Hz',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'frequence', value => 'upsAdvInputFrequency_absolute', template => '%s',
|
{ label => 'frequence', value => 'frequency_absolute', template => '%s',
|
||||||
unit => 'Hz' },
|
unit => 'Hz' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'status', threshold => 0, set => {
|
{ label => 'status', threshold => 0, set => {
|
||||||
key_values => [ { name => 'upsAdvInputLineFailCause' } ],
|
key_values => [ { name => 'last_cause' } ],
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
closure_custom_calc => \&catalog_status_calc,
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||||
|
@ -97,24 +89,25 @@ sub check_options {
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
my %map_status = (
|
my $map_status = {
|
||||||
1 => 'noTransfer', 2 => 'highLineVoltage', 3 => 'brownout', 4 => 'blackout',
|
1 => 'noTransfer', 2 => 'highLineVoltage', 3 => 'brownout', 4 => 'blackout',
|
||||||
5 => 'smallMomentarySag', 6 => 'deepMomentarySag', 7 => 'smallMomentarySpike',
|
5 => 'smallMomentarySag', 6 => 'deepMomentarySag', 7 => 'smallMomentarySpike',
|
||||||
8 => 'largeMomentarySpike', 9 => 'selfTest', 10 => 'rateOfVoltageChange',
|
8 => 'largeMomentarySpike', 9 => 'selfTest', 10 => 'rateOfVoltageChange',
|
||||||
);
|
};
|
||||||
|
|
||||||
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' },
|
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' },
|
upsAdvConfigLowTransferVolt => { oid => '.1.3.6.1.4.1.318.1.1.1.5.2.3' },
|
||||||
|
upsHighPrecInputLineVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.3.3.1' },
|
||||||
|
upsHighPrecInputFrequency => { oid => '.1.3.6.1.4.1.318.1.1.1.3.3.4' },
|
||||||
};
|
};
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{global} = {};
|
|
||||||
my $snmp_result = $options{snmp}->get_leef(
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
||||||
nothing_quit => 1
|
nothing_quit => 1
|
||||||
|
@ -130,9 +123,13 @@ sub manage_selection {
|
||||||
$self->{perfdata}->threshold_validate(label => 'critical-voltage', value => $th) if ($th ne '');
|
$self->{perfdata}->threshold_validate(label => 'critical-voltage', value => $th) if ($th ne '');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $name (keys %{$mapping}) {
|
$self->{global} = {
|
||||||
$self->{global}->{$name} = $result->{$name};
|
last_cause => $result->{upsAdvInputLineFailCause},
|
||||||
}
|
voltage => defined($result->{upsHighPrecInputLineVoltage}) && $result->{upsHighPrecInputLineVoltage} =~ /\d/ ?
|
||||||
|
$result->{upsHighPrecInputLineVoltage} * 0.1 : $result->{upsAdvInputLineVoltage},
|
||||||
|
frequency => defined($result->{upsHighPrecInputFrequency}) && $result->{upsHighPrecInputFrequency} =~ /\d/ ?
|
||||||
|
$result->{upsHighPrecInputFrequency} * 0.1 : $result->{upsAdvInputFrequency},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue