(plugin) hardware::ups::apc::snmp - metric v2 + option --replace-lasttime-format (#4551)
This commit is contained in:
parent
31fe71833e
commit
c21dd75d02
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"libsnmp-perl"
|
||||
"libsnmp-perl",
|
||||
"libdatetime-format-strptime-perl"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
"files": [
|
||||
"centreon/plugins/script_snmp.pm",
|
||||
"centreon/plugins/snmp.pm",
|
||||
"hardware/ups/apc/snmp/"
|
||||
"snmp_standard/mode/ntp.pm",
|
||||
"snmp_standard/mode/uptime.pm",
|
||||
"hardware/ups/apc/snmp/"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"perl(SNMP)"
|
||||
"perl(SNMP)",
|
||||
"perl(DateTime::Format::Strptime)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use DateTime::Format::Strptime;
|
||||
use DateTime;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
|
@ -187,15 +188,31 @@ sub set_counters {
|
|||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'replace-lasttime-format:s' => { name => 'replace_lasttime_format' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
my $pattern = '%m/%d/%Y';
|
||||
if (defined($self->{option_results}->{replace_lasttime_format}) && $self->{option_results}->{replace_lasttime_format} ne '') {
|
||||
$pattern = $self->{option_results}->{replace_lasttime_format};
|
||||
}
|
||||
|
||||
$self->{strp} = DateTime::Format::Strptime->new(
|
||||
pattern => $pattern,
|
||||
on_error => 'undef'
|
||||
);
|
||||
}
|
||||
|
||||
my $map_battery_status = {
|
||||
1 => 'unknown', 2 => 'batteryNormal', 3 => 'batteryLow'
|
||||
};
|
||||
|
@ -313,10 +330,17 @@ sub manage_selection {
|
|||
if (defined($result->{upsBasicBatteryTimeOnBattery}));
|
||||
$result2->{upsAdvBatteryRunTimeRemaining} = sprintf("%.0f", $result2->{upsAdvBatteryRunTimeRemaining} / 100 / 60)
|
||||
if (defined($result2->{upsAdvBatteryRunTimeRemaining}));
|
||||
$result2->{upsAdvBatteryReplaceIndicator} = 'n/a'
|
||||
if (!defined($result2->{upsAdvBatteryReplaceIndicator}));
|
||||
$self->{global} = { %$result, %$result2 };
|
||||
if (defined($result->{upsBasicBatteryLastReplaceDate}) && $result->{upsBasicBatteryLastReplaceDate} =~ /(\d{2})\/(\d{2})\/(\d{4})/) {
|
||||
my $dt = DateTime->new(year => $3, month => $1, day => $2, hour => 0, minute => 0, second => 0);
|
||||
$self->{global}->{last_replace_time} = time() - $dt->epoch;
|
||||
|
||||
if (defined($result->{upsBasicBatteryLastReplaceDate}) && $result->{upsBasicBatteryLastReplaceDate} ne '') {
|
||||
my $dt = $self->{strp}->parse_datetime($result->{upsBasicBatteryLastReplaceDate});
|
||||
if (defined($dt)) {
|
||||
$self->{global}->{last_replace_time} = time() - $dt->epoch();
|
||||
} else {
|
||||
$self->{output}->output_add(long_msg => "cannot parse date: " . $result->{upsBasicBatteryLastReplaceDate} . ' (please use option --replace-lasttime-format)');
|
||||
}
|
||||
}
|
||||
|
||||
$self->add_battery_pack(snmp_result => $snmp_result);
|
||||
|
@ -338,6 +362,10 @@ Check battery status and battery charge remaining.
|
|||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^status|load$'
|
||||
|
||||
=item B<--replace-lasttime-format>
|
||||
|
||||
Define the date format (default: '%m/%d/%Y').
|
||||
|
||||
=item B<--unknown-status>
|
||||
|
||||
Define the conditions to match for the status to be UNKNOWN (Default: '%{status} =~ /unknown/i').
|
||||
|
|
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -32,68 +32,172 @@ sub custom_status_output {
|
|||
return sprintf("last input line fail cause is '%s'", $self->{result_values}->{last_cause});
|
||||
}
|
||||
|
||||
sub input_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"checking input line '%s' [type: %s]",
|
||||
$options{instance_value}->{inputNum},
|
||||
$options{instance_value}->{inputType}
|
||||
);
|
||||
}
|
||||
|
||||
sub input_bpack_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"input line '%s' [type: %s] ",
|
||||
$options{instance_value}->{inputNum},
|
||||
$options{instance_value}->{inputType}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_phase_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "phase '" . $options{instance_value}->{phaseNum} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'inputs', type => 3, cb_prefix_output => 'prefix_input_output', cb_long_output => 'input_long_output', indent_long_output => ' ', message_multiple => 'All inputs are ok',
|
||||
group => [
|
||||
{ name => 'input_global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'phases', display_long => 1, cb_prefix_output => 'prefix_phase_output', message_multiple => 'phases are ok', type => 1, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'voltage', set => {
|
||||
{ label => 'voltage', nlabel => 'lines.input.voltage.volt', set => {
|
||||
key_values => [ { name => 'voltage' } ],
|
||||
output_template => 'voltage: %s V',
|
||||
perfdatas => [
|
||||
{ label => 'voltage', value => 'voltage', template => '%s',
|
||||
unit => 'V' },
|
||||
],
|
||||
{ template => '%s', unit => 'V' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'frequence', set => {
|
||||
{ label => 'frequence', nlabel => 'lines.input.frequence.hertz', set => {
|
||||
key_values => [ { name => 'frequency' } ],
|
||||
output_template => 'frequence: %s Hz',
|
||||
perfdatas => [
|
||||
{ label => 'frequence', value => 'frequency', template => '%s',
|
||||
unit => 'Hz' },
|
||||
],
|
||||
{ template => '%s', unit => 'Hz' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{ label => 'status', type => 2, set => {
|
||||
key_values => [ { name => 'last_cause' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{input_global} = [
|
||||
{ label => 'line-frequence', nlabel => 'line.input.frequence.hertz', set => {
|
||||
key_values => [ { name => 'frequency' }, { name => 'inputNum' }, { name => 'inputType' } ],
|
||||
output_template => 'frequence: %s Hz',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'Hz',
|
||||
instances => [$self->{result_values}->{inputType} . '.' . $self->{result_values}->{inputNum}],
|
||||
value => sprintf('%s', $self->{result_values}->{frequency}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{phases} = [
|
||||
{ label => 'line-phase-voltage', nlabel => 'line.input.voltage.volt', set => {
|
||||
key_values => [
|
||||
{ name => 'voltage' }, { name => 'inputNum' },
|
||||
{ name => 'inputType' }, { name => 'phaseNum' }
|
||||
],
|
||||
output_template => 'voltage: %s V',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'V',
|
||||
instances => [$self->{result_values}->{inputType} . '.' . $self->{result_values}->{inputNum}, $self->{result_values}->{phaseNum}],
|
||||
value => sprintf('%s', $self->{result_values}->{voltage}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'line-phase-current', nlabel => 'line.input.current.ampere', set => {
|
||||
key_values => [
|
||||
{ name => 'current' }, { name => 'inputNum' },
|
||||
{ name => 'inputType' }, { name => 'phaseNum' }
|
||||
],
|
||||
output_template => 'current: %s A',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'A',
|
||||
instances => [$self->{result_values}->{inputType} . '.' . $self->{result_values}->{inputNum}, $self->{result_values}->{phaseNum}],
|
||||
value => sprintf('%s', $self->{result_values}->{current}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'line-phase-power', nlabel => 'line.input.power.watt', set => {
|
||||
key_values => [
|
||||
{ name => 'power' }, { name => 'inputNum' },
|
||||
{ name => 'inputType' }, { name => 'phaseNum' }
|
||||
],
|
||||
output_template => 'power: %.2f W',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'W',
|
||||
instances => [$self->{result_values}->{inputType} . '.' . $self->{result_values}->{inputNum}, $self->{result_values}->{phaseNum}],
|
||||
value => sprintf('%.2f', $self->{result_values}->{power}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
my $map_status = {
|
||||
1 => 'noTransfer', 2 => 'highLineVoltage', 3 => 'brownout', 4 => 'blackout',
|
||||
5 => 'smallMomentarySag', 6 => 'deepMomentarySag', 7 => 'smallMomentarySpike',
|
||||
8 => 'largeMomentarySpike', 9 => 'selfTest', 10 => 'rateOfVoltageChange',
|
||||
};
|
||||
my $map_input_type = { 1 => 'unknown', 2 => 'main', 3 => 'bypass' };
|
||||
|
||||
my $mapping = {
|
||||
upsAdvInputLineVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.3.2.1' },
|
||||
|
@ -102,7 +206,16 @@ my $mapping = {
|
|||
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' },
|
||||
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' },
|
||||
upsHighPrecInputFrequency => { oid => '.1.3.6.1.4.1.318.1.1.1.3.3.4' }
|
||||
};
|
||||
my $mapping_input = {
|
||||
frequency => { oid => '.1.3.6.1.4.1.318.1.1.1.9.2.2.1.4' }, # upsPhaseInputFrequency
|
||||
type => { oid => '.1.3.6.1.4.1.318.1.1.1.9.2.2.1.5', map => $map_input_type } # upsPhaseInputType
|
||||
};
|
||||
my $mapping_input_phase = {
|
||||
voltage => { oid => '.1.3.6.1.4.1.318.1.1.1.9.2.3.1.3' }, # upsPhaseInputVoltage
|
||||
current => { oid => '.1.3.6.1.4.1.318.1.1.1.9.2.3.1.6' }, # upsPhaseInputCurrent
|
||||
power => { oid => '.1.3.6.1.4.1.318.1.1.1.9.2.3.1.9' } # upsPhaseInputPower
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -130,6 +243,53 @@ sub manage_selection {
|
|||
frequency => defined($result->{upsHighPrecInputFrequency}) && $result->{upsHighPrecInputFrequency} =~ /\d/ ?
|
||||
$result->{upsHighPrecInputFrequency} * 0.1 : $result->{upsAdvInputFrequency},
|
||||
};
|
||||
|
||||
my $oid_inputTable = '.1.3.6.1.4.1.318.1.1.1.9.2.2.1';
|
||||
$snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_inputTable,
|
||||
start => $mapping_input->{frequency}->{oid},
|
||||
end => $mapping_input->{type}->{oid}
|
||||
);
|
||||
|
||||
$self->{inputs} = {};
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping_input->{type}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping_input, results => $snmp_result, instance => $instance);
|
||||
$self->{inputs}->{$instance} = {
|
||||
inputNum => $instance,
|
||||
inputType => $result->{type},
|
||||
input_global => {
|
||||
inputNum => $instance,
|
||||
inputType => $result->{type},
|
||||
frequency => defined($result->{frequency}) && $result->{frequency} != -1 ? $result->{frequency} * 0.1 : undef
|
||||
},
|
||||
phases => {}
|
||||
};
|
||||
}
|
||||
|
||||
my $oid_inputPhaseTable = '.1.3.6.1.4.1.318.1.1.1.9.2.3.1';
|
||||
$snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_inputPhaseTable,
|
||||
start => $mapping_input_phase->{voltage}->{oid},
|
||||
end => $mapping_input_phase->{power}->{oid}
|
||||
);
|
||||
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping_input_phase->{voltage}->{oid}\.(\d+)\.(\d+)$/);
|
||||
my ($input_num, $phase_num) = ($1, $2);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping_input_phase, results => $snmp_result, instance => $input_num . '.' . $phase_num);
|
||||
$self->{inputs}->{$input_num}->{phases}->{$phase_num} = {
|
||||
inputNum => $input_num,
|
||||
inputType => $self->{inputs}->{$input_num}->{inputType},
|
||||
phaseNum => $phase_num,
|
||||
voltage => defined($result->{voltage}) && $result->{voltage} != -1 ? $result->{voltage} : undef,
|
||||
current => defined($result->{current}) && $result->{current} != -1 ? $result->{current} * 0.1 : undef,
|
||||
power => defined($result->{power}) && $result->{power} != -1 ? $result->{power} : undef
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -149,18 +309,19 @@ Example: --filter-counters='^frequence|voltage$'
|
|||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING (Default: '').
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
You can use the following variables: %{last_cause}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (Default: '').
|
||||
Define the conditions to match for the status to be CRITICAL.
|
||||
You can use the following variables: %{last_cause}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'voltage', 'frequence'.
|
||||
Can be: 'voltage', 'frequence', 'line-frequence',
|
||||
'line-phase-voltage', 'line-phase-current', 'line-phase-power'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -26,6 +26,14 @@ use strict;
|
|||
use warnings;
|
||||
use Date::Parse;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_target_time {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -24,66 +24,66 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
return sprintf("output status is '%s'", $self->{result_values}->{status});
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
unknown_default => '%{status} =~ /unknown/i',
|
||||
critical_default => '%{status} !~ /onLine|rebooting/i',
|
||||
set => {
|
||||
key_values => [ { name => 'status' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'load', set => {
|
||||
{ label => 'load', nlabel => 'lines.output.load.percentage', set => {
|
||||
key_values => [ { name => 'load' } ],
|
||||
output_template => 'load: %s %%',
|
||||
perfdatas => [
|
||||
{ label => 'load', value => 'load', template => '%s',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ template => '%s', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'current', set => {
|
||||
{ label => 'current', nlabel => 'lines.output.current.ampere', set => {
|
||||
key_values => [ { name => 'current' } ],
|
||||
output_template => 'current: %s A',
|
||||
perfdatas => [
|
||||
{ label => 'current', value => 'current', template => '%s',
|
||||
min => 0, unit => 'A' },
|
||||
],
|
||||
{ template => '%s', min => 0, unit => 'A' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'voltage', set => {
|
||||
{ label => 'voltage', nlabel => 'lines.output.voltage.volt', set => {
|
||||
key_values => [ { name => 'voltage' } ],
|
||||
output_template => 'voltage: %s V',
|
||||
perfdatas => [
|
||||
{ label => 'voltage', value => 'voltage', template => '%s',
|
||||
unit => 'V' },
|
||||
],
|
||||
{ template => '%s', unit => 'V' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'frequence', set => {
|
||||
{ label => 'frequence', nlabel => 'lines.output.frequence.hertz', set => {
|
||||
key_values => [ { name => 'frequency' } ],
|
||||
output_template => 'frequence: %s Hz',
|
||||
perfdatas => [
|
||||
{ label => 'frequence', value => 'frequency', template => '%s',
|
||||
unit => 'Hz' },
|
||||
],
|
||||
{ template => '%s', unit => 'Hz' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -92,27 +92,16 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /onLine|rebooting/i' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
|
||||
}
|
||||
|
||||
my $map_status = {
|
||||
1 => 'unknown', 2 => 'onLine', 3 => 'onBattery', 4 => 'onSmartBoost',
|
||||
5 => 'timedSleeping', 6 => 'softwareBypass', 7 => 'off',
|
||||
8 => 'rebooting', 9 => 'switchedBypass', 10 => 'hardwareFailureBypass',
|
||||
11 => 'sleepingUntilPowerReturn', 12 => 'onSmartTrim',
|
||||
11 => 'sleepingUntilPowerReturn', 12 => 'onSmartTrim'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
|
@ -124,7 +113,7 @@ my $mapping = {
|
|||
upsHighPrecOutputVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.4.3.1' }, # tenths of VAC
|
||||
upsHighPrecOutputFrequency => { oid => '.1.3.6.1.4.1.318.1.1.1.4.3.2' }, # tenths of Hz
|
||||
upsHighPrecOutputLoad => { oid => '.1.3.6.1.4.1.318.1.1.1.4.3.3' }, # tenths of percent
|
||||
upsHighPrecOutputCurrent => { oid => '.1.3.6.1.4.1.318.1.1.1.4.3.4' }, # tenths of amperes
|
||||
upsHighPrecOutputCurrent => { oid => '.1.3.6.1.4.1.318.1.1.1.4.3.4' } # tenths of amperes
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
|
|
|
@ -119,14 +119,14 @@ my $mapping = {
|
|||
uioSensorStatusSensorName => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.3' },
|
||||
uioSensorStatusTemperatureDegC => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.6' },
|
||||
uioSensorStatusHumidity => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.7' },
|
||||
uioSensorStatusAlarmStatus => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.9', map => $map_alarm_status },
|
||||
uioSensorStatusAlarmStatus => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.9', map => $map_alarm_status }
|
||||
};
|
||||
my $mapping_iem = {
|
||||
iemStatusProbeName => { oid => '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.2' },
|
||||
iemStatusProbeStatus => { oid => '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.3', map => $map_iem_status },
|
||||
iemStatusProbeCurrentTemp => { oid => '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.4' },
|
||||
iemStatusProbeTempUnits => { oid => '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.5', map => $map_iem_unit },
|
||||
iemStatusProbeCurrentHumid => { oid => '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.6' },
|
||||
iemStatusProbeCurrentHumid => { oid => '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.6' }
|
||||
};
|
||||
my $oid_uioSensorStatusEntry = '.1.3.6.1.4.1.318.1.1.25.1.2.1';
|
||||
my $oid_iemStatusProbesEntry = '.1.3.6.1.4.1.318.1.1.10.2.3.2.1';
|
||||
|
@ -179,9 +179,10 @@ sub check_uoi {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'universal_temp', unit => 'C',
|
||||
nlabel => 'sensor.universal.temperature.celsius',
|
||||
nlabel => 'sensor.universal.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $result->{uioSensorStatusSensorName},
|
||||
value => $result->{uioSensorStatusTemperatureDegC},
|
||||
warning => $warn,
|
||||
|
@ -202,9 +203,10 @@ sub check_uoi {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'universal_humidity', unit => '%',
|
||||
nlabel => 'sensor.universal.humidity.percentage',
|
||||
unit => '%',
|
||||
instances => $result->{uioSensorStatusSensorName},
|
||||
value => $result->{uioSensorStatusHumidity},
|
||||
warning => $warn,
|
||||
|
@ -259,8 +261,8 @@ sub check_iem {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'integrated_temp',
|
||||
unit => $result->{iemStatusProbeTempUnits} eq 'celsius' ? 'C' : 'F',
|
||||
nlabel => 'sensor.integrated.temperature.' . $result->{iemStatusProbeTempUnits},
|
||||
instances => $result->{iemStatusProbeName},
|
||||
|
@ -283,9 +285,10 @@ sub check_iem {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'integrated_humidity', unit => '%',
|
||||
nlabel => 'sensor.integrated.humidity.percentage',
|
||||
unit => '%',
|
||||
instances => $result->{iemStatusProbeName},
|
||||
value => $result->{iemStatusProbeCurrentHumid},
|
||||
warning => $warn,
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# Copyright 2023 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package hardware::ups::apc::snmp::mode::uptime;
|
||||
|
||||
use base qw(snmp_standard::mode::uptime);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check system uptime.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-uptime>
|
||||
|
||||
Warning threshold.
|
||||
|
||||
=item B<--critical-uptime>
|
||||
|
||||
Critical threshold.
|
||||
|
||||
=item B<--add-sysdesc>
|
||||
|
||||
Display system description.
|
||||
|
||||
=item B<--force-oid>
|
||||
|
||||
Can choose your oid (numeric format only).
|
||||
|
||||
=item B<--check-overload>
|
||||
|
||||
Uptime counter limit is 4294967296 and overflow.
|
||||
With that option, we manage the counter going back. But there is a few chance we can miss a reboot.
|
||||
|
||||
=item B<--reboot-window>
|
||||
|
||||
To be used with check-overload option. Time in milliseconds (Default: 5000)
|
||||
You increase the chance of not missing a reboot if you decrease that value.
|
||||
|
||||
=item B<--unit>
|
||||
|
||||
Select the unit for performance data and thresholds. May be 's' for seconds, 'm' for minutes,
|
||||
'h' for hours, 'd' for days, 'w' for weeks. Default is seconds
|
||||
|
||||
=back
|
|
@ -27,14 +27,13 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
$self->{modes} = {
|
||||
'battery-status' => 'hardware::ups::apc::snmp::mode::batterystatus',
|
||||
'input-lines' => 'hardware::ups::apc::snmp::mode::inputlines',
|
||||
'output-lines' => 'hardware::ups::apc::snmp::mode::outputlines',
|
||||
'sensors' => 'hardware::ups::apc::snmp::mode::sensors',
|
||||
'time' => 'hardware::ups::apc::snmp::mode::ntp',
|
||||
'uptime' => 'snmp_standard::mode::uptime'
|
||||
'uptime' => 'hardware::ups::apc::snmp::mode::uptime'
|
||||
};
|
||||
|
||||
return $self;
|
||||
|
|
Loading…
Reference in New Issue