add ibm bladecenter and lenovo flexsystem snmp plugins

This commit is contained in:
garnier-quentin 2020-04-10 14:53:05 +02:00 committed by Lotfi zaouche
parent 1ab8b50cb9
commit 9ab9734786
14 changed files with 305 additions and 341 deletions

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package network::ibm::bladecenter::snmp::mode::components::faultled; package centreon::common::ibm::nos::snmp::mode::components::faultled;
use strict; use strict;
use warnings; use warnings;
@ -31,7 +31,7 @@ sub check_faultled {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{components}->{faultled}->{total}++; $self->{components}->{faultled}->{total}++;
$self->{output}->output_add(long_msg => $self->{output}->output_add(long_msg =>
sprintf( sprintf(
"Fault LED state is %s", "Fault LED state is %s",
@ -52,13 +52,14 @@ sub check_faultled {
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fault LED"); $self->{output}->output_add(long_msg => 'checking fault LED');
$self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 }; $self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 };
return if ($self->check_filter(section => 'faultled')); return if ($self->check_filter(section => 'faultled'));
my $oid_mmspFaultLED = '.1.3.6.1.4.1.26543.2.5.1.3.10.12.0'; my $oid_mmspFaultLED = '.1.3.6.1.4.1.26543.2.5.1.3.10.12.0';
my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED], nothing_quit => 1); my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED]);
return if (!defined($results->{$oid_mmspFaultLED}));
check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}}); check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}});
} }

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package network::ibm::bladecenter::snmp::mode::components::temperature; package centreon::common::ibm::nos::snmp::mode::components::temperature;
use strict; use strict;
use warnings; use warnings;
@ -27,59 +27,70 @@ sub load {}
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures"); $self->{output}->output_add(long_msg => 'checking temperatures');
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
return if ($self->check_filter(section => 'temperature')); return if ($self->check_filter(section => 'temperature'));
my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.26543.2.5.1.3.1.22.0'; my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.26543.2.5.1.3.1.22.0';
my $oid_hwTemperatureShut = '.1.3.6.1.4.1.26543.2.5.1.3.1.23.0'; my $oid_hwTemperatureShut = '.1.3.6.1.4.1.26543.2.5.1.3.1.23.0';
my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut], nothing_quit => 1); my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut]);
return if (!defined($results->{$oid_hwTemperatureWarn}));
my $instance = 'system';
# .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warn at 66 C / Recover at 61 C)" # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warn at 66 C / Recover at 61 C)"
# .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)"
$results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; $results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i;
my $temperature = $1; my ($temperature, $warning_mib) = ($1, $2);
my $warning = $2;
$results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; $results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i;
if ($1 > $temperature) { $temperature = $1 if ($1 > $temperature);
$temperature = $1; my $critical_mib = ($warning_mib + $2) / 2;
}
my $critical = ($warning + $2) / 2;
$self->{components}->{temperature}->{total}++; $self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => $self->{output}->output_add(long_msg =>
sprintf( sprintf(
"Temperature is %.1f C", "temperature '%s' is %.1f C [instance: %s]",
$temperature $instance,
$temperature,
$instance
) )
); );
my $exit = 'OK'; my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature);
if ($temperature >= $warning) { if ($checked == 0) {
$exit = 'WARNING'; $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warning_mib);
} $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $critical_mib);
if ($temperature >= $critical) { $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
$exit = 'CRITICAL'; $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
$exit = $self->{perfdata}->threshold_check(
value => $temperature,
threshold => [
{ label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' }
]
);
} }
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add( $self->{output}->output_add(
severity => $exit, severity => $exit,
short_msg => sprintf( short_msg => sprintf(
"Temperature is %.1f C", "Temperature '%s' is %.1f C",
$instance,
$temperature $temperature
) )
); );
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'temperature', unit => 'C', unit => 'C',
nlabel => 'hardware.temperature.celsius', nlabel => 'hardware.temperature.celsius',
instances => 'system', instances => 'system',
value => $temperature, value => $temperature,
warning => $warning, warning => $warn,
critical => $critical critical => $crit
); );
} }

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package network::ibm::bladecenter::snmp::mode::cpu; package centreon::common::ibm::nos::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
@ -29,25 +29,25 @@ sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'cpu', type => 0, skipped_code => { -10 => 1 } }, { name => 'cpu', type => 0, skipped_code => { -10 => 1 } }
]; ];
$self->{maps_counters}->{cpu} = [ $self->{maps_counters}->{cpu} = [
{ label => 'average', nlabel => 'cpu.utilization.percentage', set => { { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => {
key_values => [ { name => 'average' } ], key_values => [ { name => 'average_1m' } ],
output_template => '%.2f %%', output_template => 'CPU(s) average usage: %.2f %% (1min)',
perfdatas => [ perfdatas => [
{ label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', { value => 'average_1m_absolute', template => '%.2f',
min => 0, max => 100, unit => '%' }, min => 0, max => 100, unit => '%' }
], ]
} }
}, }
]; ];
} }
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
return $self; return $self;
@ -60,7 +60,7 @@ sub manage_selection {
my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute], nothing_quit => 1); my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute], nothing_quit => 1);
$self->{cpu} = { $self->{cpu} = {
average => $result->{$oid_mpCpuStatsUtil1Minute}, average_1m => $result->{$oid_mpCpuStatsUtil1Minute}
} }
} }
@ -74,11 +74,11 @@ Check CPU usage (over the last minute).
=over 8 =over 8
=item B<--warning-average> =item B<--warning-average-1m>
Warning threshold average CPU utilization. Warning threshold average CPU utilization.
=item B<--critical-average> =item B<--critical-average-1m>
Critical threshold average CPU utilization. Critical threshold average CPU utilization.

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package network::lenovo::flexsystem::snmp::mode::disk; package centreon::common::ibm::nos::snmp::mode::disk;
use base qw(snmp_standard::mode::storage); use base qw(snmp_standard::mode::storage);
@ -39,7 +39,7 @@ sub prefix_storage_output {
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
return $self; return $self;
@ -51,7 +51,7 @@ __END__
=head1 MODE =head1 MODE
Check disk. Check disks.
=over 8 =over 8

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package network::ibm::bladecenter::snmp::mode::environment; package centreon::common::ibm::nos::snmp::mode::environment;
use base qw(centreon::plugins::templates::hardware); use base qw(centreon::plugins::templates::hardware);
@ -27,32 +27,33 @@ use warnings;
sub set_system { sub set_system {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(faultled|temperature)$'; $self->{regexp_threshold_overload_check_section_option} = '^(faultled)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$';
$self->{cb_hook2} = 'snmp_execute'; $self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = { $self->{thresholds} = {
'faultled' => [ 'faultled' => [
['on', 'CRITICAL'], ['on', 'CRITICAL'],
['off', 'OK'], ['off', 'OK']
], ]
}; };
$self->{components_path} = 'network::ibm::bladecenter::snmp::mode::components'; $self->{components_path} = 'centreon::common::ibm::nos::snmp::mode::components';
$self->{components_module} = ['faultled', 'temperature']; $self->{components_module} = ['faultled', 'temperature'];
} }
sub snmp_execute { sub snmp_execute {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
} }
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
}); });
@ -79,6 +80,22 @@ Can be: 'faultled', 'temperature'.
Return an error if no compenents are checked. Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns). If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='faulted,WARNING,on'
=item B<--warning>
Set warning threshold for temperatures (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for temperatures (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back =back
=cut =cut

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package network::ibm::bladecenter::snmp::mode::memory; package centreon::common::ibm::nos::snmp::mode::memory;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
@ -42,7 +42,7 @@ sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'memory', type => 0, skipped_code => { -10 => 1 } }, { name => 'memory', type => 0, skipped_code => { -10 => 1 } }
]; ];
$self->{maps_counters}->{memory} = [ $self->{maps_counters}->{memory} = [
@ -50,35 +50,35 @@ sub set_counters {
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [ perfdatas => [
{ label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
unit => 'B', cast_int => 1 }, unit => 'B', cast_int => 1 }
], ]
} }
}, },
{ label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { { 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' } ], key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [ perfdatas => [
{ label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute',
unit => 'B', cast_int => 1 }, unit => 'B', cast_int => 1 }
], ]
} }
}, },
{ label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => {
key_values => [ { name => 'prct_used' } ], key_values => [ { name => 'prct_used' } ],
output_template => 'Used : %.2f %%', output_template => 'Ram Used : %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100,
unit => '%' }, unit => '%' }
], ]
} }
}, }
]; ];
} }
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
return $self; return $self;
@ -99,7 +99,7 @@ sub manage_selection {
used => $total - $free, used => $total - $free,
free => $free, free => $free,
prct_used => $prct_used, prct_used => $prct_used,
prct_free => 100 - $prct_used, prct_free => 100 - $prct_used
} }
} }

View File

@ -1,104 +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 network::ibm::bladecenter::snmp::mode::disk;
use base qw(snmp_standard::mode::storage);
use strict;
use warnings;
sub default_storage_type {
my ($self, %options) = @_;
return '^(?!(hrStorageRam)$)';
}
sub prefix_storage_output {
my ($self, %options) = @_;
return "Disk '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check disk.
=over 8
=item B<--warning-usage>
Threshold warning.
=item B<--critical-usage>
Threshold critical.
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=item B<--storage>
Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage').
=item B<--name>
Allows to use storage name with option --storage instead of storage oid index.
=item B<--regexp>
Allows to use regexp to filter storage (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
=item B<--reload-cache-time>
Time in minutes before reloading cache file (default: 180).
=item B<--show-cache>
Display cache storage datas.
=item B<--filter-storage-type>
Filter storage types with a regexp (Default: '^(?!(hrStorageRam)$)').
=back
=cut

View File

@ -30,16 +30,16 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( $self->{modes} = {
'cpu' => 'network::ibm::bladecenter::snmp::mode::cpu', 'cpu' => 'centreon::common::ibm::nos::snmp::mode::cpu',
'disk' => 'network::ibm::bladecenter::snmp::mode::disk', 'disk' => 'centreon::common::ibm::nos::snmp::mode::disk',
'environment' => 'network::ibm::bladecenter::snmp::mode::environment', 'environment' => 'centreon::common::ibm::nos::snmp::mode::environment',
'interfaces' => 'snmp_standard::mode::interfaces', 'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::ibm::bladecenter::snmp::mode::memory', 'memory' => 'centreon::common::ibm::nos::snmp::mode::memory',
'time' => 'snmp_standard::mode::ntp', 'time' => 'snmp_standard::mode::ntp',
'uptime' => 'snmp_standard::mode::uptime', 'uptime' => 'snmp_standard::mode::uptime'
); };
return $self; return $self;
} }

View File

@ -31,7 +31,7 @@ sub check_faultled {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{components}->{faultled}->{total}++; $self->{components}->{faultled}->{total}++;
$self->{output}->output_add(long_msg => $self->{output}->output_add(long_msg =>
sprintf( sprintf(
"Fault LED state is %s", "Fault LED state is %s",
@ -52,13 +52,14 @@ sub check_faultled {
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fault LED"); $self->{output}->output_add(long_msg => 'checking fault LED');
$self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 }; $self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 };
return if ($self->check_filter(section => 'faultled')); return if ($self->check_filter(section => 'faultled'));
my $oid_mmspFaultLED = '.1.3.6.1.4.1.20301.2.5.1.3.10.12.0'; my $oid_mmspFaultLED = '.1.3.6.1.4.1.20301.2.5.1.3.10.12.0';
my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED], nothing_quit => 1); my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED]);
return if (!defined($results->{$oid_mmspFaultLED}));
check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}}); check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}});
} }

View File

@ -23,64 +23,85 @@ package network::lenovo::flexsystem::snmp::mode::components::temperature;
use strict; use strict;
use warnings; use warnings;
sub load {} my $mapping = {
hwInfoTemperatureWarn => { oid => '.1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20' }, # "44 C (Warning at 66 C / Recover at 61 C)"
hwInfoTemperatureShut => { oid => '.1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21' }, # "44 C (Shutdown at 72 C / Recover at 67 C)"
};
my $oid_hwInfoTableEntry = '.1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, {
oid => $oid_hwInfoTableEntry,
start => $mapping->{hwInfoTemperatureWarn}->{oid},
end => $mapping->{hwInfoTemperatureShut}->{oid}
};
}
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures"); $self->{output}->output_add(long_msg => "checking temperatures");
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
return if ($self->check_filter(section => 'temperature')); return if ($self->check_filter(section => 'temperature'));
my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.20301.2.5.1.3.1.22.0'; foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hwInfoTableEntry}})) {
my $oid_hwTemperatureShut = '.1.3.6.1.4.1.20301.2.5.1.3.1.23.0'; next if ($oid !~ /^$mapping->{hwInfoTemperatureShut}->{oid}\.(\d+)$/);
my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut], nothing_quit => 1); my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hwInfoTableEntry}, instance => $instance);
# .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warning at 66 C / Recover at 61 C)" next if ($self->check_filter(section => 'temperature', instance => $instance));
# .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" $self->{components}->{temperature}->{total}++;
$results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i;
my $temperature = $1;
my $warning = $2;
$results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i;
if ($1 > $temperature) {
$temperature = $1;
}
my $critical = ($warning + $2) / 2;
$self->{components}->{temperature}->{total}++; $result->{hwInfoTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i;
my ($temperature, $warning_mib) = ($1, $2);
$self->{output}->output_add(long_msg => $result->{hwInfoTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i;
sprintf( $temperature = $1 if ($1 > $temperature);
"Temperature is %.1f C", my $critical_mib = ($warning_mib + $2) / 2;
$temperature
)
);
my $exit = 'OK';
if ($temperature >= $warning) {
$exit = 'WARNING';
}
if ($temperature >= $critical) {
$exit = 'CRITICAL';
}
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add( $self->{output}->output_add(
severity => $exit, long_msg => sprintf(
short_msg => sprintf( "temperature switch '%s' is %s C [instance: %s]",
"Temperature is %.1f C", $instance,
$temperature $temperature,
$instance
) )
); );
}
$self->{output}->perfdata_add( my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature);
label => 'temperature', unit => 'C', if ($checked == 0) {
nlabel => 'hardware.temperature.celsius', $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warning_mib);
instances => 'system', $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $critical_mib);
value => $temperature, $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
warning => $warning, $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
critical => $critical $exit = $self->{perfdata}->threshold_check(
); value => $temperature,
threshold => [
{ label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' }
]
);
}
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"temperature switch '%s' is %s C",
$instance,
$temperature
)
);
}
$self->{output}->perfdata_add(
nlabel => 'hardware.temperature.celsius', unit => 'C',
instances => 'switch=' . $instance,
value => $temperature,
warning => $warn,
critical => $crit
);
}
} }
1; 1;

View File

@ -29,73 +29,80 @@ sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' }, { name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' }
]; ];
$self->{maps_counters}->{cpu} = [ $self->{maps_counters}->{cpu} = [
{ label => 'average', nlabel => 'cpu.utilization.percentage', set => { { label => 'average-1min', nlabel => 'switch.cpu.utilization.1min.percentage', set => {
key_values => [ { name => 'average' }, { name => 'display' } ], key_values => [ { name => 'average_1min' }, { name => 'display' } ],
output_template => '%.2f %%', output_template => '%.2f %% (1min)',
perfdatas => [ perfdatas => [
{ label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', { value => 'average_1min_absolute', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, min => 0, max => 100, unit => '%', label_extra_instance => 1 }
], ]
} }
}, },
{ label => 'average-5min', nlabel => 'switch.cpu.utilization.5min.percentage', set => {
key_values => [ { name => 'average_5min' }, { name => 'display' } ],
output_template => '%.2f %% (5min)',
perfdatas => [
{ value => 'average_5min_absolute', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1 }
]
}
}
]; ];
} }
sub prefix_message_output { sub prefix_message_output {
my ($self, %options) = @_; my ($self, %options) = @_;
return "Switch '" . $options{instance_value}->{display} . "' "; return "Switch '" . $options{instance_value}->{display} . "' CPU average usage: ";
} }
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'filter:s' => { name => 'filter', default => '.*' } 'filter-switch-num:s' => { name => 'filter_switch_num' }
}); });
return $self; return $self;
} }
my $mapping = {
average_1min => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5' }, # mpCpuStatsUtil1MinuteSwRev
average_5min => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.6' } # mpCpuStatsUtil5MinutesSwRev
};
my $oid_mpCpuStatsRevTableEntry = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $oid_mpCpuSwitchNumberRev = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.1'; my $snmp_result = $options{snmp}->get_table(
my $oid_mpCpuStatsUtil1MinuteSwRev = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5'; oid => $oid_mpCpuStatsRevTableEntry,
start => $mapping->{average_1min}->{oid},
my $result = $options{snmp}->get_table(oid => $oid_mpCpuSwitchNumberRev, nothing_quit => 1); nothing_quit => 1
my @instance_oids = ();
foreach my $oid (keys %$result) {
if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) {
push @instance_oids, $oid;
}
}
if (scalar(@instance_oids) == 0) {
$self->{output}->add_option_msg(short_msg => "Cannot find switch number '$self->{option_results}->{filter}'.");
$self->{output}->option_exit();
}
$options{snmp}->load(
oids => [$oid_mpCpuStatsUtil1MinuteSwRev],
instances => \@instance_oids,
instance_regexp => "^" . $oid_mpCpuSwitchNumberRev . '\.(.+)'
); );
my $result2 = $options{snmp}->get_leef();
foreach my $instance (@instance_oids) { $self->{cpu} = {};
$instance =~ /^$oid_mpCpuSwitchNumberRev\.(.+)/; foreach my $oid (keys %$snmp_result) {
$instance = $1; next if ($oid !~ /^$mapping->{average_1min}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_switch_num}) && $self->{option_results}->{filter_switch_num} ne '' &&
$instance !~ /$self->{option_results}->{filter_switch_num}/) {
$self->{output}->output_add(long_msg => "skipping member '" . $instance . "': no matching filter.", debug => 1);
next;
}
$self->{cpu}->{$instance} = { $self->{cpu}->{$instance} = {
display => $result->{$oid_mpCpuSwitchNumberRev . '.' . $instance}, display => $instance,
average => $result2->{$oid_mpCpuStatsUtil1MinuteSwRev . '.' . $instance}, %$result
}; };
} }
} }
@ -110,17 +117,14 @@ Check CPU usage (over the last minute).
=over 8 =over 8
=item B<--filter> =item B<--filter-switch-num>
Filter switch number (Default: '.*'). Filter switch number.
=item B<--warning-average> =item B<--warning-*> B<--critical-*>
Warning threshold average CPU utilization. Thresholds.
Can be: 'average-1min' (%), 'average-5min' (%).
=item B<--critical-average>
Critical threshold average CPU utilization.
=back =back

View File

@ -27,15 +27,16 @@ use warnings;
sub set_system { sub set_system {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(faultled|temperature)$'; $self->{regexp_threshold_overload_check_section_option} = '^(?:faultled)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$';
$self->{cb_hook2} = 'snmp_execute'; $self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = { $self->{thresholds} = {
'faultled' => [ 'faultled' => [
['on', 'CRITICAL'], ['on', 'CRITICAL'],
['off', 'OK'], ['off', 'OK']
], ]
}; };
$self->{components_path} = 'network::lenovo::flexsystem::snmp::mode::components'; $self->{components_path} = 'network::lenovo::flexsystem::snmp::mode::components';
@ -46,11 +47,12 @@ sub snmp_execute {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
} }
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
@ -79,6 +81,22 @@ Can be: 'faultled', 'temperature'.
Return an error if no compenents are checked. Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns). If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='faulted,WARNING,on'
=item B<--warning>
Set warning threshold for temperatures (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for temperatures (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back =back
=cut =cut

View File

@ -46,33 +46,33 @@ sub set_counters {
]; ];
$self->{maps_counters}->{memory} = [ $self->{maps_counters}->{memory} = [
{ label => 'usage', nlabel => 'memory.usage.bytes', set => { { label => 'usage', nlabel => 'switch.memory.usage.bytes', set => {
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [ perfdatas => [
{ label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, unit => 'B', cast_int => 1, label_extra_instance => 1 }
], ]
} }
}, },
{ label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { { label => 'usage-free', display_ok => 0, nlabel => 'switch.memory.free.bytes', set => {
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [ perfdatas => [
{ label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute',
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, unit => 'B', cast_int => 1, label_extra_instance => 1 }
], ]
} }
}, },
{ label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { { label => 'usage-prct', display_ok => 0, nlabel => 'switch.memory.usage.percentage', set => {
key_values => [ { name => 'prct_used' } ], key_values => [ { name => 'prct_used' }, { name => 'display' } ],
output_template => 'Used : %.2f %%', output_template => 'Ram Used : %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100,
unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, unit => '%', label_extra_instance => 1 }
], ]
} }
}, }
]; ];
} }
@ -84,57 +84,52 @@ sub prefix_message_output {
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'filter:s' => { name => 'filter', default => '.*' } 'filter-switch-num:s' => { name => 'filter_switch_num' }
}); });
return $self; return $self;
} }
my $mapping = {
total => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.3' }, # totalMemoryStatsRev
free => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.4' } # memoryFreeStatsRev
};
my $oid_memoryStatsEntry = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $oid_switchNumber = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.1'; my $snmp_result = $options{snmp}->get_table(
my $oid_totalMemoryStatsRev = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.3'; # in bytes oid => $oid_memoryStatsEntry,
my $oid_memoryFreeStatsRev = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.4'; # in bytes start => $mapping->{total}->{oid},
end => $mapping->{free}->{oid},
my $result = $options{snmp}->get_table(oid => $oid_switchNumber, nothing_quit => 1); nothing_quit => 1
my @instance_oids = ();
foreach my $oid (keys %$result) {
if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) {
push @instance_oids, $oid;
}
}
if (scalar(@instance_oids) == 0) {
$self->{output}->add_option_msg(short_msg => "Cannot find switch number '$self->{option_results}->{filter}'.");
$self->{output}->option_exit();
}
$options{snmp}->load(
oids => [$oid_totalMemoryStatsRev, $oid_memoryFreeStatsRev],
instances => \@instance_oids,
instance_regexp => "^" . $oid_switchNumber . '\.(.+)'
); );
my $result2 = $options{snmp}->get_leef();
foreach my $instance (@instance_oids) { $self->{memory} = {};
$instance =~ /^$oid_switchNumber\.(.+)/; foreach my $oid (keys %$snmp_result) {
$instance = $1; next if ($oid !~ /^$mapping->{free}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
my $free = $result2->{$oid_memoryFreeStatsRev . '.' . $instance}; if (defined($self->{option_results}->{filter_switch_num}) && $self->{option_results}->{filter_switch_num} ne '' &&
my $total = $result2->{$oid_totalMemoryStatsRev . '.' . $instance}; $instance !~ /$self->{option_results}->{filter_switch_num}/) {
my $prct_used = ($total - $free) * 100 / $total; $self->{output}->output_add(long_msg => "skipping member '" . $instance . "': no matching filter.", debug => 1);
next;
}
my $prct_used = ($result->{total} - $result->{free}) * 100 / $result->{total};
$self->{memory}->{$instance} = { $self->{memory}->{$instance} = {
display => $result->{$oid_switchNumber . '.' . $instance}, display => $instance,
total => $total,
used => $total - $free,
free => $free,
prct_used => $prct_used, prct_used => $prct_used,
prct_free => 100 - $prct_used, prct_free => 100 - $prct_used,
used => $result->{total} - $result->{free},
%$result
}; };
} }
} }
@ -149,9 +144,9 @@ Check memory usage.
=over 8 =over 8
=item B<--filter> =item B<--filter-switch-num>
Filter switch number (Default: '.*'). Filter switch number.
=item B<--warning-*> B<--critical-*> =item B<--warning-*> B<--critical-*>

View File

@ -31,14 +31,14 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( %{$self->{modes}} = (
'cpu' => 'network::lenovo::flexsystem::snmp::mode::cpu', 'cpu' => 'network::lenovo::flexsystem::snmp::mode::cpu',
'disk' => 'network::lenovo::flexsystem::snmp::mode::disk', 'disk' => 'centreon::common::ibm::nos::snmp::mode::disk',
'environment' => 'network::lenovo::flexsystem::snmp::mode::environment', 'environment' => 'network::lenovo::flexsystem::snmp::mode::environment',
'interfaces' => 'snmp_standard::mode::interfaces', 'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::lenovo::flexsystem::snmp::mode::memory', 'memory' => 'network::lenovo::flexsystem::snmp::mode::memory',
'time' => 'snmp_standard::mode::ntp', 'time' => 'snmp_standard::mode::ntp',
'uptime' => 'snmp_standard::mode::uptime', 'uptime' => 'snmp_standard::mode::uptime',
); );
return $self; return $self;