(plugin) os::picos::snmp - Adding PICOS plugin (#4006)
* initial commit - adding cpu mode for picaOS plugin * adding picaos plugin * correct hardware help mode * enh hardware help mode * fix wrong comparison in qnap psu mode * some fixes according to plugins boss * adding list if mode for interface discovery * rename files * remove wrongly named dir * renaming dep path * renaming path in all files * rename OS name in help * fix regex for interfaces mode
This commit is contained in:
parent
19433b72e1
commit
5dda51e2bb
|
@ -0,0 +1,76 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $oid_picaFanSpeed = '.1.3.6.1.4.1.35098.1.8.0'; # fanSpeed
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => 'checking fan');
|
||||
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
my $instance = 0; # we only have 1 fan
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_picaFanSpeed ], nothing_quit => 1);
|
||||
|
||||
my $fan_speed = $result->{$oid_picaFanSpeed} =~ s/RPM//r;
|
||||
|
||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
|
||||
$self->{components}->{fan}->{total} = 1;
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fan '%s' [instance: %s, rpm: %s]",
|
||||
$instance, $instance, $fan_speed
|
||||
)
|
||||
);
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $fan_speed);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"fan '%s' speed is '%s' rpm", $instance, $fan_speed
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.fan.speed.rpm',
|
||||
unit => 'rpm',
|
||||
instances => $instance,
|
||||
value => $fan_speed,
|
||||
warning => $warn,
|
||||
critical => $crit, min => 0
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'power-on',
|
||||
2 => 'power-off'
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
index => { oid => '.1.3.6.1.4.1.35098.1.11.1.1'},
|
||||
status => { oid => '.1.3.6.1.4.1.35098.1.11.1.3', map => \%map_status },
|
||||
speed => { oid => '.1.3.6.1.4.1.35098.1.11.1.5' },
|
||||
temperature => { oid => '.1.3.6.1.4.1.35098.1.11.1.4' }
|
||||
};
|
||||
|
||||
my $oid_picaRpsuEntry = '.1.3.6.1.4.1.35098.1.11.1';
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking redundancy power supplies");
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
my $snmp_result = $self->{snmp}->get_table(
|
||||
oid => '.1.3.6.1.4.1.35098.1.11',
|
||||
start => $oid_picaRpsuEntry
|
||||
);
|
||||
|
||||
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{index}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
my $celsius_fan_temp = $result->{temperature} =~ s/\s\C.*//r;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"power supply '%s' status is '%s' [instance: %s, fan speed: %s, temperature: %s]",
|
||||
$instance, $result->{status}, $instance, $result->{speed}, $celsius_fan_temp
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'psu', value => $result->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Power supply '%s' status is '%s'", $instance, $result->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($result->{speed} =~ /[0-9]/) {
|
||||
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'psu.fanspeed', instance => $instance, value => $result->{speed});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Power supply '%s' fan speed is %s rpm", $instance, $result->{speed}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.powersupply.fan.speed.rpm',
|
||||
unit => 'rpm',
|
||||
instances => $instance,
|
||||
value => $result->{speed},
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
if ($result->{temperature} =~ /[0-9]/) {
|
||||
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'psu.temperature', instance => $instance, value => $result->{temperature});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Power supply '%s' temperature is %s C", $instance, $celsius_fan_temp
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.powersupply.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $instance,
|
||||
value => $celsius_fan_temp
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::cpu;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'cpu-usage', nlabel => 'cpu.utilization.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' } ],
|
||||
output_template => 'CPU Usage %.2f %%',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', unit => '%', min => 0, max => 100 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'temperature', nlabel => 'cpu.temperature.celsius', set => {
|
||||
key_values => [ { name => 'temperature' } ],
|
||||
output_template => 'CPU Temperature: %s C',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'C' },
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_cpuUsage = '.1.3.6.1.4.1.35098.1.1.0';
|
||||
my $oid_cpuTemperature = '.1.3.6.1.4.1.35098.1.6.0';
|
||||
|
||||
my $oids = [$oid_cpuUsage, $oid_cpuTemperature];
|
||||
my $snmp_result = $options{snmp}->get_leef(oids => $oids, nothing_quit => 1);
|
||||
|
||||
$self->{global} = { prct_used => $snmp_result->{$oid_cpuUsage},
|
||||
temperature => $snmp_result->{$oid_cpuTemperature} =~ s/\s\C.*//r
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check CPU usage and temperature.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-cpu-usage>
|
||||
|
||||
Threshold warning for CPU usage in percentage.
|
||||
|
||||
=item B<--critical-cpu-usage>
|
||||
|
||||
Threshold critical for CPU usage in percentage.
|
||||
|
||||
=item B<--warning-temperature>
|
||||
|
||||
Threshold warning in celsius degrees for CPU.
|
||||
|
||||
=item B<--critical-temperature>
|
||||
|
||||
Threshold critical in celsius degrees for CPU.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,106 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(?:fan|psu)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
psu => [
|
||||
['power-on', 'OK'],
|
||||
['.*', 'CRITICAL']
|
||||
]
|
||||
};
|
||||
|
||||
$self->{components_path} = 'os::picos::snmp::mode::components';
|
||||
$self->{components_module} = ['fan', 'psu'];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check hardware.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'fan', 'psu'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan)
|
||||
Can also exclude specific instance: --filter=fan,0
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='psu,WARNING,power-off'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'fan' speed (syntax: type,regexp,threshold)
|
||||
Example: --warning='fan,.*,10000'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for 'fan' speed (syntax: type,regexp,threshold)
|
||||
Example: --critical='fan,.*,15000'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,316 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::interfaces;
|
||||
|
||||
use base qw(snmp_standard::mode::interfaces);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters_errors {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->SUPER::set_counters_errors(%options);
|
||||
|
||||
push @{$self->{maps_counters}->{int}},
|
||||
{ label => 'input-power', filter => 'add_optical', nlabel => 'interface.input.power.dbm', set => {
|
||||
key_values => [ { name => 'input_power' }, { name => 'display' } ],
|
||||
output_template => 'Input Power : %s dBm',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'dBm', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'bias-current', filter => 'add_optical', nlabel => 'interface.bias.current.milliampere', set => {
|
||||
key_values => [ { name => 'bias_current' }, { name => 'display' } ],
|
||||
output_template => 'Bias Current : %s mA',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'mA', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'output-power', filter => 'add_optical', nlabel => 'interface.output.power.dbm', set => {
|
||||
key_values => [ { name => 'output_power' }, { name => 'display' } ],
|
||||
output_template => 'Output Power : %s dBm',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'dBm', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'voltage', filter => 'add_optical', nlabel => 'interface.voltage.volt', set => {
|
||||
key_values => [ { name => 'voltage' }, { name => 'display' } ],
|
||||
output_template => 'Voltage : %s V',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'V', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'interface-temperature', filter => 'add_optical', nlabel => 'interface.interface.temperature.celsius', set => {
|
||||
key_values => [ { name => 'interface_temperature' }, { name => 'display' } ],
|
||||
output_template => 'interface Temperature : %.2f C',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', unit => 'C', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'add-optical' => { name => 'add_optical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub skip_interface {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return ($self->{checking} =~ /cast|errors|traffic|status|volume|optical/ ? 0 : 1);
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{checking} = '';
|
||||
foreach (('add_global', 'add_status', 'add_errors', 'add_traffic', 'add_cast', 'add_speed', 'add_volume', 'add_optical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{checking} .= $_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub reload_cache_custom {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$options{datas}->{optical_ports} = {};
|
||||
my $oid_picaSfpVendorName = '.1.3.6.1.4.1.35098.1.10.1.2';
|
||||
my $snmp_result = $self->{snmp}->get_table(oid => $oid_picaSfpVendorName);
|
||||
|
||||
foreach (keys %$snmp_result) {
|
||||
next if (! /^$oid_picaSfpVendorName\.(\d+)$/);
|
||||
$options{datas}->{optical_ports}->{$1} = $snmp_result->{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $mapping_optical = {
|
||||
output_power => { oid => '.1.3.6.1.4.1.35098.1.10.1.7' }, # picaSfpTXPower
|
||||
input_power => { oid => '.1.3.6.1.4.1.35098.1.10.1.8' }, # picaSfpRXPower
|
||||
interface_temperature => { oid => '.1.3.6.1.4.1.35098.1.10.1.4' }, # picaSfpTemperature
|
||||
voltage => { oid => '.1.3.6.1.4.1.35098.1.10.1.5' }, # picaSfpVoltage
|
||||
bias_current => { oid => '.1.3.6.1.4.1.35098.1.10.1.6' } # picaSfpBiasCurrent
|
||||
};
|
||||
|
||||
sub custom_load {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return if (!defined($self->{option_results}->{add_optical}));
|
||||
|
||||
my $optical_ports = $self->{statefile_cache}->get(name => 'optical_ports');
|
||||
$self->{snmp}->load(
|
||||
oids => [ map($_->{oid}, values(%$mapping_optical)) ],
|
||||
instances => [keys %$optical_ports]
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_add_result {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return if (!defined($self->{option_results}->{add_optical}));
|
||||
|
||||
my $optical_ports = $self->{statefile_cache}->get(name => 'optical_ports');
|
||||
return if (!defined($optical_ports->{ $options{instance} }));
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping_optical, results => $self->{results}, instance => $options{instance});
|
||||
|
||||
$self->{int}->{ $options{instance} }->{input_power} = undef;
|
||||
if (defined($result->{input_power}) && $result->{input_power} =~ /(^[+-]?\d+\.?\d+)/ ) {
|
||||
$self->{int}->{ $options{instance} }->{input_power} = $1;
|
||||
}
|
||||
|
||||
$self->{int}->{$options{instance}}->{bias_current} = undef;
|
||||
if (defined($result->{bias_current}) && $result->{bias_current} =~ /(^[+-]?\d+\.?\d+)/ ) {
|
||||
$self->{int}->{$options{instance}}->{bias_current} = $1;
|
||||
}
|
||||
|
||||
$self->{int}->{$options{instance}}->{output_power} = undef;
|
||||
if (defined($result->{output_power}) && $result->{output_power} =~ /(^[+-]?\d+\.?\d+)/ ) {
|
||||
$self->{int}->{$options{instance}}->{output_power} = $1;
|
||||
}
|
||||
|
||||
$self->{int}->{$options{instance}}->{interface_temperature} = undef;
|
||||
if (defined($result->{interface_temperature}) && $result->{interface_temperature} =~ /(^[+-]?\d+\.?\d+)/ ) {
|
||||
$self->{int}->{$options{instance}}->{interface_temperature} = $1;
|
||||
}
|
||||
|
||||
$self->{int}->{$options{instance}}->{voltage} = undef;
|
||||
if (defined($result->{voltage}) && $result->{voltage} =~ /(^[+-]?\d+\.?\d+)/ ) {
|
||||
$self->{int}->{$options{instance}}->{voltage} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check interfaces.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--add-global>
|
||||
|
||||
Check global port statistics (By default if no --add-* option is set).
|
||||
|
||||
=item B<--add-status>
|
||||
|
||||
Check interface status.
|
||||
|
||||
=item B<--add-duplex-status>
|
||||
|
||||
Check duplex status (with --warning-status and --critical-status).
|
||||
|
||||
=item B<--add-traffic>
|
||||
|
||||
Check interface traffic.
|
||||
|
||||
=item B<--add-errors>
|
||||
|
||||
Check interface errors.
|
||||
|
||||
=item B<--add-cast>
|
||||
|
||||
Check interface cast.
|
||||
|
||||
=item B<--add-speed>
|
||||
|
||||
Check interface speed.
|
||||
|
||||
=item B<--add-volume>
|
||||
|
||||
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
|
||||
|
||||
=item B<--add-optical>
|
||||
|
||||
Check interface optical metrics.
|
||||
|
||||
=item B<--check-metrics>
|
||||
|
||||
If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"').
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status.
|
||||
Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
|
||||
Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
|
||||
'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
|
||||
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
|
||||
'speed' (b/s).
|
||||
|
||||
And also: 'input-power' (dBm), 'bias-current' (mA), 'output-power' (dBm), 'voltage' (mV), 'interface-temperature' (C).
|
||||
|
||||
=item B<--units-traffic>
|
||||
|
||||
Units of thresholds for the traffic (Default: 'percent_delta') ('percent_delta', 'bps', 'counter').
|
||||
|
||||
=item B<--units-errors>
|
||||
|
||||
Units of thresholds for errors/discards (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter').
|
||||
|
||||
=item B<--units-cast>
|
||||
|
||||
Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter').
|
||||
|
||||
=item B<--nagvis-perfdata>
|
||||
|
||||
Display traffic perfdata to be compatible with nagvis widget.
|
||||
|
||||
=item B<--interface>
|
||||
|
||||
Set the interface (number expected) ex: 1,2,... (empty means 'check all interface').
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Allows to use interface name with option --interface instead of interface oid index (Can be a regexp)
|
||||
|
||||
=item B<--speed>
|
||||
|
||||
Set interface speed for incoming/outgoing traffic (in Mb).
|
||||
|
||||
=item B<--speed-in>
|
||||
|
||||
Set interface speed for incoming traffic (in Mb).
|
||||
|
||||
=item B<--speed-out>
|
||||
|
||||
Set interface speed for outgoing traffic (in Mb).
|
||||
|
||||
=item B<--force-counters32>
|
||||
|
||||
Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy.
|
||||
|
||||
=item B<--reload-cache-time>
|
||||
|
||||
Time in minutes before reloading cache file (default: 180).
|
||||
|
||||
=item B<--oid-filter>
|
||||
|
||||
Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
|
||||
|
||||
=item B<--oid-display>
|
||||
|
||||
Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
|
||||
|
||||
=item B<--oid-extra-display>
|
||||
|
||||
Add an OID to display.
|
||||
|
||||
=item B<--display-transform-src>
|
||||
|
||||
Regexp src to transform display value.
|
||||
|
||||
=item B<--display-transform-dst>
|
||||
|
||||
Regexp dst to transform display value.
|
||||
|
||||
=item B<--show-cache>
|
||||
|
||||
Display cache interface datas.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,108 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::listinterfaces;
|
||||
|
||||
use base qw(snmp_standard::mode::listinterfaces);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub default_oid_filter_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'ifdesc';
|
||||
}
|
||||
|
||||
sub default_oid_display_name {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'ifdesc';
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--interface>
|
||||
|
||||
Set the interface (number expected) ex: 1,2,... (empty means 'check all interface').
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Allows to use interface name with option --interface instead of interface oid index (Can be a regexp)
|
||||
|
||||
=item B<--speed>
|
||||
|
||||
Set interface speed (in Mb).
|
||||
|
||||
=item B<--skip-speed0>
|
||||
|
||||
Don't display interface with speed 0.
|
||||
|
||||
=item B<--filter-status>
|
||||
|
||||
Display interfaces matching the filter (example: 'up').
|
||||
|
||||
=item B<--use-adminstatus>
|
||||
|
||||
Display interfaces with AdminStatus 'up'.
|
||||
|
||||
=item B<--oid-filter>
|
||||
|
||||
Choose OID used to filter interface (default: ifDesc) (values: ifDesc, ifAlias, ifName).
|
||||
|
||||
=item B<--oid-display>
|
||||
|
||||
Choose OID used to display interface (default: ifDesc) (values: ifDesc, ifAlias, ifName).
|
||||
|
||||
=item B<--display-transform-src>
|
||||
|
||||
Regexp src to transform display value. (security risk!!!)
|
||||
|
||||
=item B<--display-transform-dst>
|
||||
|
||||
Regexp dst to transform display value. (security risk!!!)
|
||||
|
||||
=item B<--add-extra-oid>
|
||||
|
||||
Display an OID.
|
||||
Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18'
|
||||
or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*'
|
||||
|
||||
=item B<--add-mac-address>
|
||||
|
||||
Display interface mac address.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,135 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'Memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)',
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{total}),
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{used}),
|
||||
$self->{result_values}->{prct_used},
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{free}),
|
||||
$self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'memory', type => 0, skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{memory} = [
|
||||
{ label => 'usage', nlabel => 'memory.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_picaAvailableMemory = '.1.3.6.1.4.1.35098.1.4.0';
|
||||
my $oid_picaTotalMemory = '.1.3.6.1.4.1.35098.1.2.0';
|
||||
|
||||
my $oids = [$oid_picaAvailableMemory, $oid_picaTotalMemory];
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => $oids, nothing_quit => 1);
|
||||
|
||||
my $free_size = $result->{$oid_picaAvailableMemory} =~ s/KB//r;
|
||||
$free_size *= 1024;
|
||||
my $total_size = $result->{$oid_picaTotalMemory} =~ s/KB//r;
|
||||
$total_size *= 1024;
|
||||
|
||||
my $used_size = $total_size - $free_size;
|
||||
|
||||
my $prct_used = $used_size * 100 / $total_size;
|
||||
my $prct_free = 100 - $prct_used;
|
||||
|
||||
my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size);
|
||||
my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used_size);
|
||||
my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free_size);
|
||||
|
||||
$self->{memory} = {
|
||||
total => $total_size,
|
||||
used => $used_size,
|
||||
free => $free_size,
|
||||
prct_used => $prct_used,
|
||||
prct_free => $prct_free
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check memory usage.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,134 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::mode::temperature;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'switch-temperature', nlabel => 'switch.temperature.celsius', set => {
|
||||
key_values => [ { name => 'switch_temperature' } ],
|
||||
output_template => 'switch temperature: %s C',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'C' },
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'chip-temperature', nlabel => 'chip.temperature.celsius', set => {
|
||||
key_values => [ { name => 'chip_temperature' } ],
|
||||
output_template => 'Chip Temperature: %s C',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'C' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'cpu-temperature', nlabel => 'cpu.temperature.celsius', set => {
|
||||
key_values => [ { name => 'cpu_temperature' } ],
|
||||
output_template => 'CPU Temperature: %s C',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'C' },
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_switchTemperature = '.1.3.6.1.4.1.35098.1.5.0';
|
||||
my $oid_cpuTemperature = '.1.3.6.1.4.1.35098.1.6.0';
|
||||
my $oid_chipTemperature = '.1.3.6.1.4.1.35098.1.7.0';
|
||||
|
||||
my $oids = [$oid_switchTemperature, $oid_chipTemperature, $oid_cpuTemperature];
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => $oids,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
my $switch_temperature = $snmp_result->{$oid_switchTemperature} =~ s/\s\C.*//r;
|
||||
my $cpu_temperature = $snmp_result->{$oid_cpuTemperature} =~ s/\s\C.*//r;
|
||||
my $chip_temperature = $snmp_result->{$oid_chipTemperature} =~ s/\s\C.*//r;
|
||||
|
||||
$self->{global} = {
|
||||
switch_temperature => $switch_temperature,
|
||||
cpu_temperature => $cpu_temperature,
|
||||
chip_temperature => $chip_temperature
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check temperature.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-switch-temperature>
|
||||
|
||||
Threshold warning in celsius degrees for Pica switch.
|
||||
|
||||
=item B<--critical-switch-temperature>
|
||||
|
||||
Threshold critical in celsius degrees for Pica switch.
|
||||
|
||||
=item B<--warning-chip-temperature>
|
||||
|
||||
Threshold warning in celsius degrees for chip.
|
||||
|
||||
=item B<--critical-chip-temperature>
|
||||
|
||||
Threshold critical in celsius degrees for chip.
|
||||
|
||||
=item B<--warning-cpu-temperature>
|
||||
|
||||
Threshold warning in celsius degrees for CPU.
|
||||
|
||||
=item B<--critical-cpu-temperature>
|
||||
|
||||
Threshold critical in celsius degrees for CPU.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# Copyright 2022 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 os::picos::snmp::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_snmp);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'os::picos::snmp::mode::cpu',
|
||||
'hardware' => 'os::picos::snmp::mode::hardware',
|
||||
'interfaces' => 'os::picos::snmp::mode::interfaces',
|
||||
'list-interfaces' => 'os::picos::snmp::mode::listinterfaces',
|
||||
'memory' => 'os::picos::snmp::mode::memory',
|
||||
'temperature' => 'os::picos::snmp::mode::temperature'
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check PICOS through SNMP.
|
||||
|
||||
=cut
|
|
@ -70,7 +70,7 @@ sub check_psu_result {
|
|||
);
|
||||
}
|
||||
|
||||
if ($result->{speed} !~ /[0-9]/) {
|
||||
if ($result->{speed} =~ /[0-9]/) {
|
||||
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'psu.fanspeed', instance => $instance, value => $result->{speed});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
|
|
Loading…
Reference in New Issue