This commit is contained in:
garnier-quentin 2020-05-04 16:20:16 +02:00 committed by Lotfi zaouche
parent 4d7853a1ab
commit 7088971d51
11 changed files with 668 additions and 328 deletions

View File

@ -1,74 +0,0 @@
#
# Copyright 2020 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 centreon::common::radlan::mode::components::fan;
use strict;
use warnings;
my %map_states = (
1 => 'normal',
2 => 'warning',
3 => 'critical',
4 => 'shutdown',
5 => 'notPresent',
6 => 'notFunctioning',
);
my $mapping = {
rlEnvMonFanStatusDescr => { oid => '.1.3.6.1.4.1.89.83.1.1.1.2' },
rlEnvMonFanState => { oid => '.1.3.6.1.4.1.89.83.1.1.1.3', map => \%map_states },
};
my $oid_rlEnvMonFanStatusEntry = '.1.3.6.1.4.1.89.83.1.1.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_rlEnvMonFanStatusEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking fans');
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
return if ($self->check_filter(section => 'fan'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonFanStatusEntry}})) {
next if ($oid !~ /^$mapping->{rlEnvMonFanState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonFanStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{rlEnvMonFanStatusDescr}));
next if ($result->{rlEnvMonFanState} eq 'notPresent' &&
$self->absent_problem(section => 'fan', instance => $instance, name => $result->{rlEnvMonFanStatusDescr}));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' state is %s [instance: %s]",
$result->{rlEnvMonFanStatusDescr}, $result->{rlEnvMonFanState}, $instance));
my $exit = $self->get_severity(section => 'fan', value => $result->{rlEnvMonFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' state is %s.", $result->{rlEnvMonFanStatusDescr}, $result->{rlEnvMonFanState}));
}
}
}
1;

View File

@ -1,74 +0,0 @@
#
# Copyright 2020 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 centreon::common::radlan::mode::components::psu;
use strict;
use warnings;
my %map_states = (
1 => 'normal',
2 => 'warning',
3 => 'critical',
4 => 'shutdown',
5 => 'notPresent',
6 => 'notFunctioning',
);
my $mapping = {
rlEnvMonSupplyStatusDescr => { oid => '.1.3.6.1.4.1.89.83.1.2.1' },
rlEnvMonSupplyState => { oid => '.1.3.6.1.4.1.89.83.1.2.1.3', map => \%map_states },
};
my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.89.83.1.2.1.2';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking power supplies');
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) {
next if ($oid !~ /^$mapping->{rlEnvMonSupplyState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{rlEnvMonSupplyStatusDescr}));
next if ($result->{rlEnvMonSupplyState} eq 'notPresent' &&
$self->absent_problem(section => 'psu', instance => $instance, name => $result->{rlEnvMonSupplyStatusDescr}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' state is %s [instance: %s]",
$result->{rlEnvMonSupplyStatusDescr}, $result->{rlEnvMonSupplyState}, $instance));
my $exit = $self->get_severity(section => 'psu', value => $result->{rlEnvMonSupplyState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' state is %s.", $result->{rlEnvMonSupplyStatusDescr}, $result->{rlEnvMonSupplyState}));
}
}
}
1;

View File

@ -1,148 +0,0 @@
#
# Copyright 2020 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 centreon::common::radlan::mode::cpu;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
($self->{warn1s}, $self->{warn1m}, $self->{warn5m}) = split /,/, $self->{option_results}->{warning};
($self->{crit1s}, $self->{crit1m}, $self->{crit5m}) = split /,/, $self->{option_results}->{critical};
if (($self->{perfdata}->threshold_validate(label => 'warn1s', value => $self->{warn1s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (1sec) threshold '" . $self->{warn1s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warn5m', value => $self->{warn5m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit1s', value => $self->{crit1s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (1sec) threshold '" . $self->{crit1s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit5m', value => $self->{crit5})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_rlCpuUtilEnable = '.1.3.6.1.4.1.89.1.6.0';
my $oid_rlCpuUtilDuringLastSecond = '.1.3.6.1.4.1.89.1.7.0';
my $oid_rlCpuUtilDuringLastMinute = '.1.3.6.1.4.1.89.1.8.0';
my $oid_rlCpuUtilDuringLast5Minutes = '.1.3.6.1.4.1.89.1.9.0';
$self->{result} = $self->{snmp}->get_leef(oids => [ $oid_rlCpuUtilEnable, $oid_rlCpuUtilDuringLastSecond, $oid_rlCpuUtilDuringLastMinute, $oid_rlCpuUtilDuringLast5Minutes ],
nothing_quit => 1);
if (defined($self->{result}->{$oid_rlCpuUtilEnable}) && $self->{result}->{$oid_rlCpuUtilEnable} == 1) {
my $cpu1sec = $self->{result}->{$oid_rlCpuUtilDuringLastSecond};
my $cpu1min = $self->{result}->{$oid_rlCpuUtilDuringLastMinute};
my $cpu5min = $self->{result}->{$oid_rlCpuUtilDuringLast5Minutes};
my $exit1 = $self->{perfdata}->threshold_check(value => $cpu1sec,
threshold => [ { label => 'crit1s', exit_litteral => 'critical' }, { label => 'warn1s', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1min,
threshold => [ { label => 'crit1m', exit_litteral => 'critical' }, { label => 'warn1m', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $cpu5min,
threshold => [ { label => 'crit5m', exit_litteral => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Usage: %.2f%% (1sec), %.2f%% (1min), %.2f%% (5min)",
$cpu1sec, $cpu1min, $cpu5min));
$self->{output}->perfdata_add(label => "cpu_1s", unit => '%',
value => $cpu1sec,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1s'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1s'),
min => 0, max => 100);
$self->{output}->perfdata_add(label => "cpu_1m", unit => '%',
value => $cpu1min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'),
min => 0, max => 100);
$self->{output}->perfdata_add(label => "cpu_5m", unit => '%',
value => $cpu5min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'),
min => 0, max => 100);
} else {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("CPU measurement is not enabled."));
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check cpu usage (RADLAN-rndMng).
=over 8
=item B<--warning>
Threshold warning in percent (1s,1min,5min).
=item B<--critical>
Threshold critical in percent (1s,1min,5min).
=back
=cut

View File

@ -0,0 +1,111 @@
#
# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::fan;
use strict;
use warnings;
use centreon::common::cisco::smallbusiness::snmp::mode::components::resources qw(
$rl_envmon_state
$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable
$oid_rlPhdUnitEnvParamEntry
);
my $mapping_stack = {
new => {
rlPhdUnitEnvParamFan1Status => { oid => '.1.3.6.1.4.1.89.53.15.1.4', map => $rl_envmon_state },
rlPhdUnitEnvParamFan2Status => { oid => '.1.3.6.1.4.1.89.53.15.1.5', map => $rl_envmon_state },
rlPhdUnitEnvParamFan3Status => { oid => '.1.3.6.1.4.1.89.53.15.1.6', map => $rl_envmon_state },
rlPhdUnitEnvParamFan4Status => { oid => '.1.3.6.1.4.1.89.53.15.1.7', map => $rl_envmon_state },
rlPhdUnitEnvParamFan5Status => { oid => '.1.3.6.1.4.1.89.53.15.1.8', map => $rl_envmon_state },
rlPhdUnitEnvParamFan6Status => { oid => '.1.3.6.1.4.1.89.53.15.1.9', map => $rl_envmon_state }
},
old => {
rlPhdUnitEnvParamFan1Status => { oid => '.1.3.6.1.4.1.89.53.15.1.4', map => $rl_envmon_state },
rlPhdUnitEnvParamFan2Status => { oid => '.1.3.6.1.4.1.89.53.15.1.5', map => $rl_envmon_state },
rlPhdUnitEnvParamFan3Status => { oid => '.1.3.6.1.4.1.89.53.15.1.6', map => $rl_envmon_state },
rlPhdUnitEnvParamFan4Status => { oid => '.1.3.6.1.4.1.89.53.15.1.7', map => $rl_envmon_state },
rlPhdUnitEnvParamFan5Status => { oid => '.1.3.6.1.4.1.89.53.15.1.8', map => $rl_envmon_state }
}
};
sub load {
my ($self) = @_;
}
sub check_fan_stack {
my ($self) = @_;
my $num_fans = 5;
$num_fans = 6 if ($self->{radlan_new} == 1);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) {
next if ($oid !~ /^$mapping_stack->{new}->{rlPhdUnitEnvParamFan1Status}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(
mapping => $self->{radlan_new} == 1 ? $mapping_stack->{new} : $mapping_stack->{old},
results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry},
instance => $instance
);
for (my $i = 1; $i <= $num_fans; $i++) {
my $instance2 = 'stack.' . $instance . '.fan.' . $i;
my $name = 'rlPhdUnitEnvParamFan' . $i . 'Status';
next if ($self->check_filter(section => 'fan', instance => $instance2));
next if ($result->{$name} =~ /notPresent/i &&
$self->absent_problem(section => 'fan', instance => $instance2));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is '%s' [instance: %s]",
$instance2,
$result->{$name},
$instance2
)
);
my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{$name});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Fan '%s' status is '%s'",
$instance2,
$result->{$name}
)
);
}
}
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = { name => 'fan', total => 0, skip => 0 };
return if ($self->check_filter(section => 'fan'));
check_fan_stack($self);
}
1;

View File

@ -0,0 +1,140 @@
#
# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::psu;
use strict;
use warnings;
use centreon::common::radlan::snmp::mode::components::resources qw(
$rl_envmon_state
$oid_rlPhdUnitEnvParamEntry
);
my $mapping_stack = {
rlPhdUnitEnvParamMainPSStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.2', map => $rl_envmon_state },
rlPhdUnitEnvParamRedundantPSStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.3', map => $rl_envmon_state }
};
my $mapping = {
rlEnvMonSupplyStatusDescr => { oid => '.1.3.6.1.4.1.89.83.1.2.1.2' },
rlEnvMonSupplyState => { oid => '.1.3.6.1.4.1.89.83.1.2.1.3', map => $rl_envmon_state }
};
my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.89.83.1.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, {
oid => $oid_rlEnvMonSupplyStatusEntry,
$mapping->{rlEnvMonSupplyStatusDescr}->{oid},
$mapping->{rlEnvMonSupplyState}->{oid}
};
}
sub check_psu_stack {
my ($self) = @_;
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) {
next if ($oid !~ /^$mapping_stack->{rlPhdUnitEnvParamMainPSStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping_stack, results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry}, instance => $instance);
foreach (['rlPhdUnitEnvParamMainPSStatus', 'main.psu'], ['rlPhdUnitEnvParamRedundantPSStatus', 'redundant.psu']) {
my $instance2 = 'stack.' . $instance . '.' . $_->[1];
next if ($self->check_filter(section => 'psu', instance => $instance2));
next if ($result->{$_->[0]} =~ /notPresent/i &&
$self->absent_problem(section => 'psu', instance => $instance2));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is '%s' [instance: %s]",
$instance2,
$result->{$_->[0]},
$instance2
)
);
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{$_->[0]});
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'",
$instance2,
$result->{$_->[0]}
)
);
}
}
}
}
sub check_psu {
my ($self) = @_;
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) {
next if ($oid !~ /^$mapping->{rlEnvMonSupplyState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
if ($result->{rlEnvMonSupplyState} =~ /notPresent/i) {
$self->absent_problem(section => 'psu', instance => $instance);
next;
}
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is '%s' [instance: %s]",
$result->{rlEnvMonSupplyStatusDescr},
$result->{rlEnvMonSupplyState},
$instance
)
);
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{rlEnvMonSupplyState});
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'",
$result->{rlEnvMonSupplyStatusDescr},
$result->{rlEnvMonSupplyState}
)
);
}
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
check_psu($self);
check_psu_stack($self);
}
1;

View File

@ -0,0 +1,53 @@
#
# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::resources;
use strict;
use warnings;
use Exporter;
our $rl_envmon_state;
our $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable;
our $oid_rlPhdUnitEnvParamEntry;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
$rl_envmon_state
$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable
$oid_rlPhdUnitEnvParamEntry
);
$rl_envmon_state = {
1 => 'normal',
2 => 'warning',
3 => 'critical',
4 => 'shutdown',
5 => 'notPresent',
6 => 'notFunctioning',
7 => 'notAvailable',
8 => 'backingUp',
9 => 'readingFailed'
};
$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable = '.1.3.6.1.4.1.89.53.15.1.15';
$oid_rlPhdUnitEnvParamEntry = '.1.3.6.1.4.1.89.53.15.1';
1;

View File

@ -0,0 +1,124 @@
#
# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::temperature;
use strict;
use warnings;
use centreon::common::radlan::snmp::mode::components::resources qw($oid_rlPhdUnitEnvParamEntry);
my $map_entity_sensor = { 1 => 'ok', 2 => 'unavailable', 3 => 'nonoperational' };
my $mapping = {
new => {
rlPhdUnitEnvParamTempSensorValue => { oid => '.1.3.6.1.4.1.89.53.15.1.10' },
rlPhdUnitEnvParamTempSensorStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.11', map => $map_entity_sensor },
rlPhdUnitEnvParamTempSensorWarningThresholdValue => { oid => '.1.3.6.1.4.1.89.53.15.1.12' },
rlPhdUnitEnvParamTempSensorCriticalThresholdValue => { oid => '.1.3.6.1.4.1.89.53.15.1.13' }
},
old => {
rlPhdUnitEnvParamTempSensorValue => { oid => '.1.3.6.1.4.1.89.53.15.1.9' },
rlPhdUnitEnvParamTempSensorStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.10', map => $map_entity_sensor },
}
};
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
return if ($self->check_filter(section => 'temperature'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) {
next if ($oid !~ /^$mapping->{new}->{rlPhdUnitEnvParamTempSensorValue}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(
mapping => $self->{radlan_new} == 1 ? $mapping->{new} : $mapping->{old},
results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry},
instance => $instance
);
next if ($self->check_filter(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"temperature '%s' status is '%s' [instance = %s, value: %s degree centigrade]",
$instance,
$result->{rlPhdUnitEnvParamTempSensorStatus},
$instance,
$result->{rlPhdUnitEnvParamTempSensorValue}
)
);
my $exit = $self->get_severity(section => 'temperature', value => $result->{rlPhdUnitEnvParamTempSensorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Temperature '%s' status is '%s'",
$instance,
$result->{rlPhdUnitEnvParamTempSensorStatus}
)
);
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{rlPhdUnitEnvParamTempSensorValue});
if ($checked == 0 && defined($result->{rlPhdUnitEnvParamTempSensorWarningThresholdValue})) {
my $warn_th = ':' . $result->{rlPhdUnitEnvParamTempSensorWarningThresholdValue};
my $crit_th = ':' . $result->{rlPhdUnitEnvParamTempSensorCriticalThresholdValue};
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
$exit2 = $self->{perfdata}->threshold_check(
value => $result->{rlPhdUnitEnvParamTempSensorValue},
threshold => [
{ label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' }
]
);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
}
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf(
"Temperature '%s' is %s degree centigrade",
$instance,
$result->{rlPhdUnitEnvParamTempSensorValue}
)
);
}
$self->{output}->perfdata_add(
label => 'temp', unit => 'C',
nlabel => 'hardware.temperature.celsius',
instances => $instance,
value => $result->{rlPhdUnitEnvParamTempSensorValue},
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,120 @@
#
# Copyright 2020 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 centreon::common::radlan::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 => 'cpu', type => 0, cb_prefix_output => 'prefix_message_output', skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{cpu} = [
{ label => 'average-1s', nlabel => 'cpu.utilization.1s.percentage', set => {
key_values => [ { name => 'average_1s' } ],
output_template => '%.2f %% (1s)',
perfdatas => [
{ value => 'average_1s_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' }
]
}
},
{ label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => {
key_values => [ { name => 'average_1m' } ],
output_template => '%.2f %% (1m)',
perfdatas => [
{ value => 'average_1m_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' }
]
}
},
{ label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => {
key_values => [ { name => 'average_5m' } ],
output_template => '%.2f %% (5m)',
perfdatas => [
{ value => 'average_5m_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' }
]
}
}
];
}
sub prefix_message_output {
my ($self, %options) = @_;
return "CPU average usage: ";
}
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_rlCpuUtilDuringLastSecond = '.1.3.6.1.4.1.89.1.7.0';
my $oid_rlCpuUtilDuringLastMinute = '.1.3.6.1.4.1.89.1.8.0';
my $oid_rlCpuUtilDuringLast5Minutes = '.1.3.6.1.4.1.89.1.9.0';
my $result = $options{snmp}->get_leef(
oids => [$oid_rlCpuUtilDuringLastSecond, $oid_rlCpuUtilDuringLastMinute, $oid_rlCpuUtilDuringLast5Minutes],
nothing_quit => 1
);
$self->{cpu} = {
average_1s => $result->{$oid_rlCpuUtilDuringLastSecond},
average_1m => $result->{$oid_rlCpuUtilDuringLastMinute},
average_5m => $result->{$oid_rlCpuUtilDuringLast5Minutes}
}
}
1;
__END__
=head1 MODE
Check cpu usage.
=over 8
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'average-1s' (%), 'average-1m' (%), 'average-5m' (%).
=back
=cut

View File

@ -18,49 +18,73 @@
# limitations under the License. # limitations under the License.
# #
package centreon::common::radlan::mode::environment; package centreon::common::radlan::snmp::mode::environment;
use base qw(centreon::plugins::templates::hardware); use base qw(centreon::plugins::templates::hardware);
use strict; use strict;
use warnings; use warnings;
use centreon::common::radlan::snmp::mode::components::resources qw(
$oid_rlPhdUnitEnvParamEntry
$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable
);
sub set_system { sub set_system {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^fan|psu$'; $self->{regexp_threshold_overload_check_section_option} = '^(?:fan|psu|temperature)$';
$self->{regexp_threshold_numeric_check_section_option} = '^temperature$';
$self->{cb_hook2} = 'snmp_execute'; $self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = { $self->{thresholds} = {
default => [ default => [
['shutdown', 'WARNING'], ['normal', 'OK'],
['notPresent', 'OK'],
['warning', 'WARNING'], ['warning', 'WARNING'],
['critical', 'CRITICAL'], ['critical', 'CRITICAL'],
['shutdown', 'CRITICAL'],
['notFunctioning', 'CRITICAL'], ['notFunctioning', 'CRITICAL'],
['notPresent', 'OK'],
['normal', 'OK'],
], ],
temperature => [
['ok', 'OK'],
['unavailable', 'OK'],
['nonoperational', 'CRITICAL'],
]
}; };
$self->{components_path} = 'centreon::common::radlan::mode::components'; $self->{components_path} = 'centreon::common::radlan::snmp::mode::components';
$self->{components_module} = ['fan', 'psu']; $self->{components_module} = ['psu', 'fan', 'temperature'];
} }
sub snmp_execute { sub snmp_execute {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
push @{$self->{request}}, {
oid => $oid_rlPhdUnitEnvParamEntry,
start => '.1.3.6.1.4.1.89.53.15.1.2', # rlPhdUnitEnvParamMainPSStatus
end => $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable
};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
$self->{radlan_new} = 0;
foreach (keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}}) {
if (/^$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable\./) {
$self->{radlan_new} = 1;
last;
}
}
} }
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => {}); $options{options}->add_options(arguments => {
});
return $self; return $self;
} }
@ -70,24 +94,24 @@ __END__
=head1 MODE =head1 MODE
Check environment (RADLAN-HWENVIROMENT). Check environment.
=over 8 =over 8
=item B<--component> =item B<--component>
Which component to check (Default: 'all'). Which component to check (Default: '.*').
Can be: 'psu', 'fan'. Can be: 'fan', 'psu', 'temperature'.
=item B<--filter> =item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=psu) Exclude some parts (comma seperated list) (Example: --filter=psu)
Can also exclude specific instance: --filter=fan,1 Can also exclude specific instance: --filter=psu,0
=item B<--absent-problem> =item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list) Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=psu Can be specific or global: --absent-problem=fan#2#
=item B<--no-component> =item B<--no-component>
@ -96,10 +120,21 @@ If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload> =item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp) Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays). It used before default thresholds (order stays).
Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)' Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)'
=item B<--warning>
Set warning threshold (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back =back
=cut =cut

View File

@ -0,0 +1,52 @@
#
# Copyright 2020 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::dell::xseries::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->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'centreon::common::radlan::snmp::mode::cpu',
'hardware' => 'centreon::common::radlan::snmp::mode::environment',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'uptime' => 'snmp_standard::mode::uptime'
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Dell X-Series in SNMP.
=cut

View File

@ -30,12 +30,11 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'warning:s' => { name => 'warning', default => '' },
"warning:s" => { name => 'warning', default => '' }, 'critical:s' => { name => 'critical', default => '' },
"critical:s" => { name => 'critical', default => '' }, 'average' => { name => 'average' },
"average" => { name => 'average' }, });
});
return $self; return $self;
} }
@ -83,7 +82,7 @@ sub run {
my $oid_CpuLoad15m = '.1.3.6.1.4.1.2021.10.1.3.3'; my $oid_CpuLoad15m = '.1.3.6.1.4.1.2021.10.1.3.3';
my $result = $self->{snmp}->get_leef(oids => [$oid_CpuLoad1m, $oid_CpuLoad5m, $oid_CpuLoad15m], nothing_quit => 1); my $result = $self->{snmp}->get_leef(oids => [$oid_CpuLoad1m, $oid_CpuLoad5m, $oid_CpuLoad15m], nothing_quit => 1);
my ($msg, $cpu_load1, $cpu_load5, $cpu_load15); my ($msg, $cpu_load1, $cpu_load5, $cpu_load15);
$result->{$oid_CpuLoad1m} =~ s/,/\./g; $result->{$oid_CpuLoad1m} =~ s/,/\./g;
$result->{$oid_CpuLoad5m} =~ s/,/\./g; $result->{$oid_CpuLoad5m} =~ s/,/\./g;
@ -92,8 +91,10 @@ sub run {
if (defined($self->{option_results}->{average})) { if (defined($self->{option_results}->{average})) {
my $result2 = $self->{snmp}->get_table(oid => $oid_CountCpu); my $result2 = $self->{snmp}->get_table(oid => $oid_CountCpu);
if (scalar(keys %$result2) <= 0){ if (scalar(keys %$result2) <= 0){
$self->{output}->output_add(severity => 'unknown', $self->{output}->output_add(
short_msg => 'Unable to get number of CPUs'); severity => 'unknown',
short_msg => 'Unable to get number of CPUs'
);
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }