Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions src/network/cambium/cnmatrix/snmp/mode/components/psu.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# Copyright 2026 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 network::cambium::cnmatrix::snmp::mode::components::psu;

use strict;
use warnings;

my %map_psu_status = (
1 => 'ok',
2 => 'error',
);

my $mapping = {
cnInternalPowerSupplyStatus => { oid => '.1.3.6.1.4.1.17713.24.4.30.1.2', map => \%map_psu_status },
};
my $oid_cnInternalPowerSupplyTableEntry = '.1.3.6.1.4.1.17713.24.4.30.1';

sub load {
my ($self) = @_;

push @{$self->{request}}, { oid => $oid_cnInternalPowerSupplyTableEntry };
}

sub check {
my ($self) = @_;

$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));

foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cnInternalPowerSupplyTableEntry}})) {
next if ($oid !~ /^$mapping->{ cnInternalPowerSupplyStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(
mapping => $mapping,
results => $self->{results}->{$oid_cnInternalPowerSupplyTableEntry},
instance => $instance
);

next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;

$self->{output}->output_add(
long_msg => sprintf("Power supply '%s' status is %s [instance: %s].",
$instance, $result->{ cnInternalPowerSupplyStatus},
$instance
));
my $exit = $self->get_severity(section => 'psu', value => $result->{ cnInternalPowerSupplyStatus});
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->{ cnInternalPowerSupplyStatus}
));
}
}
}

1;
107 changes: 107 additions & 0 deletions src/network/cambium/cnmatrix/snmp/mode/hardware.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#
# Copyright 2026 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 network::cambium::cnmatrix::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} = '^psu$';

$self->{cb_hook2} = 'snmp_execute';

$self->{thresholds} = {
psu => [
['ok', 'OK'],
['error', 'CRITICAL'],
],
};

$self->{components_path} = 'network::cambium::cnmatrix::snmp::mode::components';
$self->{components_module} = [ '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_performance => 1);
bless $self, $class;

$options{options}->add_options(arguments => {});

return $self;
}

1;

__END__

=head1 MODE

Check Hardware (Power Supplies).

=over 8

=item B<--component>

Which component to check (default: '.*').
Can be: 'psu'.

=item B<--filter>

Exclude the items given as a comma-separated list (example: --filter=psu).
You can also exclude items from specific instances: --filter=psu,1

=item B<--absent-problem>

Return an error if an entity is not 'present' (default is skipping) (comma separated list)
Can be specific or global: --absent-problem=psu,1

=item B<--no-component>

Define the expected status if no components are found (default: critical).

=item B<--threshold-overload>

Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)'

=item B<--warning-count-*>

Define the warning threshold for the number of components of one type (replace '*' with the component type).

=item B<--critical-count-*>

Define the critical threshold for the number of components of one type (replace '*' with the component type).

=back

=cut
Loading