From aeaa9a5742dafd7ad13617651b8356b1bca444f6 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 10:18:58 +0100 Subject: [PATCH 01/37] Create plugin.pm --- centreon-plugins/network/raisecom/snmp/plugin.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/plugin.pm diff --git a/centreon-plugins/network/raisecom/snmp/plugin.pm b/centreon-plugins/network/raisecom/snmp/plugin.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/plugin.pm @@ -0,0 +1 @@ + From a7823dc6c59c0f1b7cb805f06c21d69b41387608 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 10:19:25 +0100 Subject: [PATCH 02/37] Create cpu.pm --- centreon-plugins/network/raisecom/snmp/mode/cpu.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/cpu.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm @@ -0,0 +1 @@ + From 6f7ad7955a0f9d466da606d4c9a8e903c5797eba Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 10:19:35 +0100 Subject: [PATCH 03/37] Create memory.pm --- centreon-plugins/network/raisecom/snmp/mode/memory.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/memory.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -0,0 +1 @@ + From 5e608b86db78f15614e0205738439ff7a0430902 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 10:23:02 +0100 Subject: [PATCH 04/37] Update plugin.pm --- .../network/raisecom/snmp/plugin.pm | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/plugin.pm b/centreon-plugins/network/raisecom/snmp/plugin.pm index 8b1378917..8ae11cea7 100644 --- a/centreon-plugins/network/raisecom/snmp/plugin.pm +++ b/centreon-plugins/network/raisecom/snmp/plugin.pm @@ -1 +1,49 @@ +# +# Copyright 2017 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::raisecom::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} = '0.1'; + %{$self->{modes}} = ( + 'cpu' => 'network::raisecom::snmp::mode::cpu', + 'memory' => 'network::raisecom::snmp::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Raisecom devices through SNMP + +=cut From 74cd5998701c5bc3294fcc948a1a09db9ff160e8 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:11:00 +0100 Subject: [PATCH 05/37] Update cpu.pm --- .../network/raisecom/snmp/mode/cpu.pm | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm index 8b1378917..b0d60ce87 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm @@ -1 +1,130 @@ +# +# Copyright 2017 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::raisecom::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_cpu_output' } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => '1s', set => { + key_values => [ { name => 'raisecomCPUUtilization1sec' } ], + output_template => '1 seconde : %.2f %%', + perfdatas => [ + { label => 'cpu_1s', value => 'raisecomCPUUtilization1sec_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => '1m', set => { + key_values => [ { name => 'raisecomCPUUtilization1min' } ], + output_template => '1 minute : %.2f %%', + perfdatas => [ + { label => 'cpu_1m', value => 'raisecomCPUUtilization1min_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + { label => '10m', set => { + key_values => [ { name => 'raisecomCPUUtilization10min' } ], + output_template => '10 minutes : %.2f %%', + perfdatas => [ + { label => 'cpu_10m', value => 'raisecomCPUUtilization10min_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + ]; +} + +sub prefix_cpu_output { + my ($self, %options) = @_; + + return "CPU Usage "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # + my $oid_raisecomCPUUtilization1sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.1'; + my $oid_raisecomCPUUtilization1min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.3'; + my $oid_raisecomCPUUtilization10min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.4'; + + my $results = $options{snmp}->get_leef(oids => [$oid_raisecomCPUUtilization1sec, $oid_raisecomCPUUtilization1min, + $oid_raisecomCPUUtilization10min ], + nothing_quit => 1); + + $self->{cpu} = { raisecomCPUUtilization1sec => $results->{$oid_raisecomCPUUtilization1sec}, + raisecomCPUUtilization1min => $results->{$oid_raisecomCPUUtilization1min}, + raisecomCPUUtilization10min => $results->{$oid_raisecomCPUUtilization10min}, + }; +} + +1; + +__END__ + +=head1 MODE + +Check CPU usage + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(1s|1m)$' + +=item B<--warning-*> + +Threshold warning. +Can be: '1s', '1m', '10m' + +=item B<--critical-*> + +Threshold critical. +Can be: '1s', '1m', '10m' + +=back + +=cut From 0acbe6a5d1d01dcd72ab45318fef578776cf391b Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:25:46 +0100 Subject: [PATCH 06/37] Update memory.pm --- .../network/raisecom/snmp/mode/memory.pm | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 8b1378917..84f50dd59 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -1 +1,172 @@ +# +# Copyright 2017 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::raisecom::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + + my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}); + return $msg; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0, cb_prefix_output => 'prefix_memory_output' }, + { name => 'flash', type => 0, cb_prefix_output => 'prefix_flash_output' } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'memory', set => { + key_values => [ { name => 'prct_used'}, { name => 'used' }, { name => 'free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + threshold_use => 'prct_used_absolute', + perfdatas => [ + { label => 'memory', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, + min => 0, max => 'total_absolute', unit => 'B' }, + ], + } + }, + ]; + $self->{maps_counters}->{flash} = [ + { label => 'flash', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + threshold_use => 'prct_used_absolute', + perfdatas => [ + { label => 'flash', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, + min => 0, max => 'total_absolute', unit => 'B' }, + ], + } + }, + ]; +} + +sub prefix_memory_output { + my ($self, %options) = @_; + + return "Memory "; +} + +sub prefix_flash_output { + my ($self, %options) = @_; + + return "Flash "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($total_bytes, $used_bytes, $free_bytes); + + # TRAPEZE-NETWORKS-SYSTEM-MIB + my $oid_trpzSysFlashMemoryUsedBytes = '.1.3.6.1.4.1.14525.4.8.1.1.3.0'; + my $oid_trpzSysFlashMemoryTotalBytes = '.1.3.6.1.4.1.14525.4.8.1.1.4.0'; + my $oid_trpzSysCpuMemoryInstantUsage = '.1.3.6.1.4.1.14525.4.8.1.1.12.1.0'; + my $oid_trpzSysCpuMemoryUsedBytes = '.1.3.6.1.4.1.14525.4.8.1.1.1.0'; + my $oid_trpzSysCpuMemoryTotalBytes = '.1.3.6.1.4.1.14525.4.8.1.1.2.0'; + my $oid_trpzSysCpuMemorySize = '.1.3.6.1.4.1.14525.4.8.1.1.6.0'; + + my $results = $options{snmp}->get_leef(oids => [$oid_trpzSysFlashMemoryUsedBytes, $oid_trpzSysFlashMemoryTotalBytes, $oid_trpzSysCpuMemoryUsedBytes, + $oid_trpzSysCpuMemoryInstantUsage, $oid_trpzSysCpuMemorySize, $oid_trpzSysCpuMemoryTotalBytes ], + nothing_quit => 1); + + if (defined($results->{$oid_trpzSysCpuMemorySize}) || $results->{$oid_trpzSysCpuMemorySize} != 0) { + $total_bytes = $results->{$oid_trpzSysCpuMemorySize} * 1024; + $used_bytes = $results->{$oid_trpzSysCpuMemoryInstantUsage} * 1024; + $free_bytes = $total_bytes - $used_bytes; + } else { + $total_bytes = $results->{$oid_trpzSysCpuMemoryTotalBytes}; + $used_bytes = $results->{$oid_trpzSysCpuMemoryUsedBytes}; + $free_bytes = $total_bytes - $used_bytes; + } + + my $free_bytes_flash = $results->{$oid_trpzSysFlashMemoryTotalBytes} - $results->{$oid_trpzSysFlashMemoryUsedBytes}; + + $self->{memory} = {display => 'memory', + prct_used => $used_bytes * 100 / $total_bytes, + used => $used_bytes, + free => $free_bytes, + total => $total_bytes, + }; + + $self->{flash} = {display => 'flash', + prct_used => $results->{$oid_trpzSysFlashMemoryUsedBytes} * 100 / $results->{$oid_trpzSysFlashMemoryTotalBytes}, + used => $results->{$oid_trpzSysFlashMemoryUsedBytes}, + free => $free_bytes_flash, + total => $results->{$oid_trpzSysFlashMemoryTotalBytes}, + }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^(memory)$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'memory', 'flash' + +=item B<--critical-*> + +Threshold critical. +Can be: 'memory', 'flash' + +=back + +=cut From 668d17ca0455e536429e786341e38e35515961a0 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:30:39 +0100 Subject: [PATCH 07/37] Update cpu.pm --- .../network/raisecom/snmp/mode/cpu.pm | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm index b0d60ce87..e8e5c625e 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm @@ -42,6 +42,15 @@ sub set_counters { ], } }, + { label => '5s', set => { + key_values => [ { name => 'raisecomCPUUtilization5sec' } ], + output_template => '5 secondes : %.2f %%', + perfdatas => [ + { label => 'cpu_5s', value => 'raisecomCPUUtilization5sec_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, { label => '1m', set => { key_values => [ { name => 'raisecomCPUUtilization1min' } ], output_template => '1 minute : %.2f %%', @@ -60,6 +69,15 @@ sub set_counters { ], } }, + { label => '2h', set => { + key_values => [ { name => 'raisecomCPUUtilization2h' } ], + output_template => '2 hours : %.2f %%', + perfdatas => [ + { label => 'cpu_2h', value => 'raisecomCPUUtilization2h_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, ]; } @@ -87,16 +105,21 @@ sub manage_selection { # my $oid_raisecomCPUUtilization1sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.1'; + my $oid_raisecomCPUUtilization5sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.2'; my $oid_raisecomCPUUtilization1min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.3'; my $oid_raisecomCPUUtilization10min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.4'; + my $oid_raisecomCPUUtilization2h = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.5'; - my $results = $options{snmp}->get_leef(oids => [$oid_raisecomCPUUtilization1sec, $oid_raisecomCPUUtilization1min, - $oid_raisecomCPUUtilization10min ], + my $results = $options{snmp}->get_leef(oids => [$oid_raisecomCPUUtilization1sec, $oid_raisecomCPUUtilization5sec, + $oid_raisecomCPUUtilization1min, , $oid_raisecomCPUUtilization10min, + $oid_raisecomCPUUtilization2h ], nothing_quit => 1); $self->{cpu} = { raisecomCPUUtilization1sec => $results->{$oid_raisecomCPUUtilization1sec}, + raisecomCPUUtilization5sec => $results->{$oid_raisecomCPUUtilization5sec}, raisecomCPUUtilization1min => $results->{$oid_raisecomCPUUtilization1min}, raisecomCPUUtilization10min => $results->{$oid_raisecomCPUUtilization10min}, + raisecomCPUUtilization2h => $results->{$oid_raisecomCPUUtilization2h}, }; } @@ -118,12 +141,12 @@ Example: --filter-counters='^(1s|1m)$' =item B<--warning-*> Threshold warning. -Can be: '1s', '1m', '10m' +Can be: '1s', '5s', '1m', '10m', '2h' =item B<--critical-*> Threshold critical. -Can be: '1s', '1m', '10m' +Can be: '1s', '5s', '1m', '10m', '2h' =back From dbd9fe03791b120c44734ad4630a74e3c8117ddb Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:36:07 +0100 Subject: [PATCH 08/37] Update cpu.pm --- centreon-plugins/network/raisecom/snmp/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm index e8e5c625e..076828cea 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm @@ -103,7 +103,7 @@ sub new { sub manage_selection { my ($self, %options) = @_; - # + # RAISECOM-SYSTEM-MIB my $oid_raisecomCPUUtilization1sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.1'; my $oid_raisecomCPUUtilization5sec = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.2'; my $oid_raisecomCPUUtilization1min = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3.3'; From 04bcfd67a2966c6981a133e674aba4547783df2e Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:41:53 +0100 Subject: [PATCH 09/37] Update memory.pm --- .../network/raisecom/snmp/mode/memory.pm | 63 ++++--------------- 1 file changed, 12 insertions(+), 51 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 84f50dd59..d06d346ae 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -43,8 +43,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'memory', type => 0, cb_prefix_output => 'prefix_memory_output' }, - { name => 'flash', type => 0, cb_prefix_output => 'prefix_flash_output' } + { name => 'memory', type => 0, cb_prefix_output => 'prefix_memory_output' } ]; $self->{maps_counters}->{memory} = [ @@ -59,18 +58,6 @@ sub set_counters { } }, ]; - $self->{maps_counters}->{flash} = [ - { label => 'flash', set => { - key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], - closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', - perfdatas => [ - { label => 'flash', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, - ], - } - }, - ]; } sub prefix_memory_output { @@ -79,12 +66,6 @@ sub prefix_memory_output { return "Memory "; } -sub prefix_flash_output { - my ($self, %options) = @_; - - return "Flash "; -} - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -103,43 +84,23 @@ sub manage_selection { my ($total_bytes, $used_bytes, $free_bytes); - # TRAPEZE-NETWORKS-SYSTEM-MIB - my $oid_trpzSysFlashMemoryUsedBytes = '.1.3.6.1.4.1.14525.4.8.1.1.3.0'; - my $oid_trpzSysFlashMemoryTotalBytes = '.1.3.6.1.4.1.14525.4.8.1.1.4.0'; - my $oid_trpzSysCpuMemoryInstantUsage = '.1.3.6.1.4.1.14525.4.8.1.1.12.1.0'; - my $oid_trpzSysCpuMemoryUsedBytes = '.1.3.6.1.4.1.14525.4.8.1.1.1.0'; - my $oid_trpzSysCpuMemoryTotalBytes = '.1.3.6.1.4.1.14525.4.8.1.1.2.0'; - my $oid_trpzSysCpuMemorySize = '.1.3.6.1.4.1.14525.4.8.1.1.6.0'; + # RAISECOM-SYSTEM-MIB + my $oid_raisecomAvailableMemory = '.1.3.6.1.4.1.8886.1.1.3.2.0'; + my $oid_raisecomTotalMemory = '.1.3.6.1.4.1.8886.1.1.3.1.0'; - my $results = $options{snmp}->get_leef(oids => [$oid_trpzSysFlashMemoryUsedBytes, $oid_trpzSysFlashMemoryTotalBytes, $oid_trpzSysCpuMemoryUsedBytes, - $oid_trpzSysCpuMemoryInstantUsage, $oid_trpzSysCpuMemorySize, $oid_trpzSysCpuMemoryTotalBytes ], + my $results = $options{snmp}->get_leef(oids => [$oid_raisecomAvailableMemory, $oid_raisecomTotalMemory ], nothing_quit => 1); - if (defined($results->{$oid_trpzSysCpuMemorySize}) || $results->{$oid_trpzSysCpuMemorySize} != 0) { - $total_bytes = $results->{$oid_trpzSysCpuMemorySize} * 1024; - $used_bytes = $results->{$oid_trpzSysCpuMemoryInstantUsage} * 1024; - $free_bytes = $total_bytes - $used_bytes; - } else { - $total_bytes = $results->{$oid_trpzSysCpuMemoryTotalBytes}; - $used_bytes = $results->{$oid_trpzSysCpuMemoryUsedBytes}; - $free_bytes = $total_bytes - $used_bytes; - } - - my $free_bytes_flash = $results->{$oid_trpzSysFlashMemoryTotalBytes} - $results->{$oid_trpzSysFlashMemoryUsedBytes}; - + $total_bytes = $results->{$oid_raisecomTotalMemory}; + $free_bytes = $results->{$oid_raisecomAvailableMemory}; + $used_bytes = $total_bytes - $free_bytes; + $self->{memory} = {display => 'memory', prct_used => $used_bytes * 100 / $total_bytes, used => $used_bytes, free => $free_bytes, total => $total_bytes, - }; - - $self->{flash} = {display => 'flash', - prct_used => $results->{$oid_trpzSysFlashMemoryUsedBytes} * 100 / $results->{$oid_trpzSysFlashMemoryTotalBytes}, - used => $results->{$oid_trpzSysFlashMemoryUsedBytes}, - free => $free_bytes_flash, - total => $results->{$oid_trpzSysFlashMemoryTotalBytes}, - }; + }; } 1; @@ -160,12 +121,12 @@ Example: --filter-counters='^(memory)$' =item B<--warning-*> Threshold warning. -Can be: 'memory', 'flash' +Can be: 'memory' =item B<--critical-*> Threshold critical. -Can be: 'memory', 'flash' +Can be: 'memory' =back From 670af01f95f29798b4bc32346920fa5a5c28e715 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:43:08 +0100 Subject: [PATCH 10/37] Update memory.pm --- centreon-plugins/network/raisecom/snmp/mode/memory.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index d06d346ae..35250998f 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -52,7 +52,7 @@ sub set_counters { closure_custom_output => $self->can('custom_usage_output'), threshold_use => 'prct_used_absolute', perfdatas => [ - { label => 'memory', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, + { label => 'used', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, min => 0, max => 'total_absolute', unit => 'B' }, ], } From cf2770e38f736e49da9e148d81fe96f288c0ca78 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 11:44:12 +0100 Subject: [PATCH 11/37] Update memory.pm --- centreon-plugins/network/raisecom/snmp/mode/memory.pm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 35250998f..0dd815dd8 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -113,20 +113,13 @@ Check memory usage =over 8 -=item B<--filter-counters> - -Only display some counters (regexp can be used). -Example: --filter-counters='^(memory)$' - -=item B<--warning-*> +=item B<--warning> Threshold warning. -Can be: 'memory' -=item B<--critical-*> +=item B<--critical> Threshold critical. -Can be: 'memory' =back From 00559906c8988f4a9db36cd8489de883419ba5f9 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:01:09 +0100 Subject: [PATCH 12/37] Update memory.pm --- .../network/raisecom/snmp/mode/memory.pm | 118 ++++++++---------- 1 file changed, 54 insertions(+), 64 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 0dd815dd8..10c78879a 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -20,52 +20,11 @@ package network::raisecom::snmp::mode::memory; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; -sub custom_usage_output { - my ($self, %options) = @_; - - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); - - my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}); - return $msg; -} - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'memory', type => 0, cb_prefix_output => 'prefix_memory_output' } - ]; - - $self->{maps_counters}->{memory} = [ - { label => 'memory', set => { - key_values => [ { name => 'prct_used'}, { name => 'used' }, { name => 'free' }, { name => 'total' } ], - closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', - perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, - ], - } - }, - ]; -} - -sub prefix_memory_output { - my ($self, %options) = @_; - - return "Memory "; -} - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -74,33 +33,64 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); - return $self; } -sub manage_selection { +sub check_options { my ($self, %options) = @_; - - my ($total_bytes, $used_bytes, $free_bytes); - - # RAISECOM-SYSTEM-MIB + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + my $oid_raisecomAvailableMemory = '.1.3.6.1.4.1.8886.1.1.3.2.0'; my $oid_raisecomTotalMemory = '.1.3.6.1.4.1.8886.1.1.3.1.0'; - - my $results = $options{snmp}->get_leef(oids => [$oid_raisecomAvailableMemory, $oid_raisecomTotalMemory ], - nothing_quit => 1); - - $total_bytes = $results->{$oid_raisecomTotalMemory}; - $free_bytes = $results->{$oid_raisecomAvailableMemory}; - $used_bytes = $total_bytes - $free_bytes; - $self->{memory} = {display => 'memory', - prct_used => $used_bytes * 100 / $total_bytes, - used => $used_bytes, - free => $free_bytes, - total => $total_bytes, - }; + my $oids = [$oid_raisecomAvailableMemory, $oid_raisecomTotalMemory]; + + my $result = $self->{snmp}->get_leef(oids => $oids, + nothing_quit => 1); + + my $free_size = $result->{$oid_raisecomAvailableMemory} * 1024; + my $total_size = $result->{$oid_raisecomAvailableMemory} * 1024; + my $used_size = $total_size - $free_size; + + my $prct_used = $used_size * 100 / $total_size; + my $prct_free = 100 - $prct_used; + my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + 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->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory Total: %s, Used: %s (%.2f%%), Free: %s (%.2f%%)", + $total_value . " " . $total_unit, + $used_value . " " . $used_unit, $prct_used, + $free_value . " " . $free_unit, $prct_free)); + + $self->{output}->perfdata_add(label => "used", unit => 'B', + value => $used_size, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), + min => 0, max => $total_size); + + $self->{output}->display(); + $self->{output}->exit(); } 1; @@ -109,17 +99,17 @@ __END__ =head1 MODE -Check memory usage +Check memory usage. =over 8 =item B<--warning> -Threshold warning. +Threshold warning in percent. =item B<--critical> -Threshold critical. +Threshold critical in percent. =back From a7056ffbb333af55f247173b4e83c73e4da4f084 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:02:22 +0100 Subject: [PATCH 13/37] Update memory.pm --- centreon-plugins/network/raisecom/snmp/mode/memory.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 10c78879a..7528c93a9 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -66,7 +66,7 @@ sub run { nothing_quit => 1); my $free_size = $result->{$oid_raisecomAvailableMemory} * 1024; - my $total_size = $result->{$oid_raisecomAvailableMemory} * 1024; + my $total_size = $result->{$oid_raisecomTotalMemory} * 1024; my $used_size = $total_size - $free_size; my $prct_used = $used_size * 100 / $total_size; From fc125cd7c3d6d28624036eec7cddb81b8f775114 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:10:44 +0100 Subject: [PATCH 14/37] Update memory.pm --- centreon-plugins/network/raisecom/snmp/mode/memory.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 7528c93a9..c54e462dd 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -65,8 +65,8 @@ sub run { my $result = $self->{snmp}->get_leef(oids => $oids, nothing_quit => 1); - my $free_size = $result->{$oid_raisecomAvailableMemory} * 1024; - my $total_size = $result->{$oid_raisecomTotalMemory} * 1024; + my $free_size = $result->{$oid_raisecomAvailableMemory}; + my $total_size = $result->{$oid_raisecomTotalMemory}; my $used_size = $total_size - $free_size; my $prct_used = $used_size * 100 / $total_size; From 3ce8edb7137822ea2fea18a0be03c8e1b6147051 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:13:38 +0100 Subject: [PATCH 15/37] Update cpu.pm --- centreon-plugins/network/raisecom/snmp/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm index 076828cea..a8cbb1e8c 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm @@ -129,7 +129,7 @@ __END__ =head1 MODE -Check CPU usage +Check CPU usage. =over 8 From 8af3aa65f4de96b66368830f6cb449c4e1d6442c Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:17:24 +0100 Subject: [PATCH 16/37] Update plugin.pm --- centreon-plugins/network/raisecom/snmp/plugin.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/plugin.pm b/centreon-plugins/network/raisecom/snmp/plugin.pm index 8ae11cea7..8294d0df6 100644 --- a/centreon-plugins/network/raisecom/snmp/plugin.pm +++ b/centreon-plugins/network/raisecom/snmp/plugin.pm @@ -33,6 +33,9 @@ sub new { %{$self->{modes}} = ( 'cpu' => 'network::raisecom::snmp::mode::cpu', 'memory' => 'network::raisecom::snmp::mode::memory', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'hardware' => 'network::raisecom::snmp::mode::hardware', ); return $self; From 7c093fe9647ebba6b6218308f5ce13493d84afa5 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:19:32 +0100 Subject: [PATCH 17/37] Create hardware.pm --- centreon-plugins/network/raisecom/snmp/mode/hardware.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/hardware.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -0,0 +1 @@ + From 48c5d150567925e79518b859b58753132908b294 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:20:18 +0100 Subject: [PATCH 18/37] Create temperature.pm --- .../network/raisecom/snmp/mode/components/temperature.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm @@ -0,0 +1 @@ + From 55e82ea9ce08a80524d507597a232f904ff1060f Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:20:29 +0100 Subject: [PATCH 19/37] Create fan.pm --- centreon-plugins/network/raisecom/snmp/mode/components/fan.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/fan.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm @@ -0,0 +1 @@ + From 6e05582d4f4295e1a39e962903ca80ab779abb6b Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:20:46 +0100 Subject: [PATCH 20/37] Create psu.pm --- centreon-plugins/network/raisecom/snmp/mode/components/psu.pm | 1 + 1 file changed, 1 insertion(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/psu.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm @@ -0,0 +1 @@ + From c16c072b3f78f574c2a3d45712d28c7baa8f0a7f Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 13:25:32 +0100 Subject: [PATCH 21/37] Update hardware.pm --- .../network/raisecom/snmp/mode/hardware.pm | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm index 8b1378917..7c42c9c74 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -1 +1,117 @@ +# +# Copyright 2017 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::raisecom::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|psu)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + fan => [ + ['bad', 'CRITICAL'], + ['good', 'OK'], + ['notPresent', 'OK'], + ], + psu => [ + ['bad', 'CRITICAL'], + ['good', 'OK'], + ['notPresent', 'OK'], + ], + }; + + $self->{components_path} = 'network::raisecom::mode::components'; + $self->{components_module} = ['fan', 'psu', 'temperature']; +} + +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); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware (fans, temperatures, power supplies). + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'fan', 'psu', 'temperature'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1 + +=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='fan,CRITICAL,^(?!(good)$)' + +=item B<--warning> + +Set warning threshold for temperatures, fan speed (syntax: type,instance,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for temperatures, fan speed (syntax: type,instance,threshold) +Example: --critical='temperature,.*,40' + +=back + +=cut + From fb661bcabc054e27b5b1942681fef3b8960e3753 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:19:01 +0100 Subject: [PATCH 22/37] Update temperature.pm --- .../snmp/mode/components/temperature.pm | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm index 8b1378917..8803aed9e 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm @@ -1 +1,69 @@ +# +# Copyright 2017 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::raisecom::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' }, +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{raisecomTemperatureValue}->{oid} }; +} + +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}->{$mapping->{raisecomTemperatureValue}->{oid}}})) { + $oid =~ /^$mapping->{raisecomTemperatureValue}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{raisecomTemperatureValue}->{oid}}, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + + $self->{components}->{temperature}->{total}++; + $self->{output}->output_add(long_msg => sprintf("temperature '%s' is %.2f C [instance: %s].", + $instance, $result->{raisecomTemperatureValue}, $instance + )); + + if (defined($result->{raisecomTemperatureValue}) && $result->{raisecomTemperatureValue} =~ /[0-9]/) { + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{sysChassisTempTemperature}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is %.2f C", $instance, $result->{raisecomTemperatureValue})); + } + $self->{output}->perfdata_add(label => "temp_" . $instance, unit => 'C', + value => sprintf("%.2f", $result->{raisecomTemperatureValue}), + warning => $warn, + critical => $crit); + } + } +} + +1; From c422de029047763ca5e68a69d58fb01c63c3145f Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:20:53 +0100 Subject: [PATCH 23/37] Update psu.pm --- .../raisecom/snmp/mode/components/psu.pm | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm index 8b1378917..bd721727f 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm @@ -1 +1,72 @@ +# +# Copyright 2017 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::raisecom::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 0 => 'bad', + 1 => 'good', + 2 => 'notPresent', +); + +my $mapping = { + sysChassisPowerSupplyStatus => { oid => '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1.2', map => \%map_status }, +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{sysChassisPowerSupplyStatus}->{oid} }; +} + +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}->{$mapping->{sysChassisPowerSupplyStatus}->{oid}}})) { + $oid =~ /^$mapping->{sysChassisPowerSupplyStatus}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{sysChassisPowerSupplyStatus}->{oid}}, instance => $instance); + + next if ($result->{sysChassisPowerSupplyStatus} =~ /notPresent/i && + $self->absent_problem(section => 'psu', 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->{sysChassisPowerSupplyStatus}, $instance + )); + my $exit = $self->get_severity(section => 'psu', value => $result->{sysChassisPowerSupplyStatus}); + 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->{sysChassisPowerSupplyStatus})); + } + } +} + +1; From d575e623d6d53070490cad2983e6f1c59d22555d Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:21:14 +0100 Subject: [PATCH 24/37] Update fan.pm --- .../raisecom/snmp/mode/components/fan.pm | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm index 8b1378917..d3be38bfb 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm @@ -1 +1,87 @@ +# +# Copyright 2017 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::f5::bigip::mode::components::fan; + +use strict; +use warnings; + +my %map_status = ( + 0 => 'bad', + 1 => 'good', + 2 => 'notPresent', +); + +my $mapping = { + sysChassisFanStatus => { oid => '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1.2', map => \%map_status }, + sysChassisFanSpeed => { oid => '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1.3' }, +}; +my $oid_sysChassisFanEntry = '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_sysChassisFanEntry }; +} + +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_sysChassisFanEntry}})) { + next if ($oid !~ /^$mapping->{sysChassisFanStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sysChassisFanEntry}, instance => $instance); + + next if ($result->{sysChassisFanStatus} =~ /notPresent/i && + $self->absent_problem(section => 'fan', instance => $instance)); + next if ($self->check_filter(section => 'fan', instance => $instance)); + + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance: %s, speed: %s].", + $instance, $result->{sysChassisFanStatus}, $instance, + defined($result->{sysChassisFanSpeed}) ? $result->{sysChassisFanSpeed} : '-')); + my $exit = $self->get_severity(section => 'fan', value => $result->{sysChassisFanStatus}); + 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'", + $instance, $result->{sysChassisFanStatus})); + } + + if (defined($result->{sysChassisFanSpeed}) && $result->{sysChassisFanSpeed} =~ /[0-9]/) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{sysChassisFanSpeed}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("fan speed '%s' is %s rpm", $instance, $result->{sysChassisFanSpeed})); + } + $self->{output}->perfdata_add(label => "fan_" . $instance, unit => 'rpm', + value => $result->{sysChassisFanSpeed}, + warning => $warn, + critical => $crit, + min => 0); + } + } +} + +1; From 3208b08ccae2c9ed216edace4c4ade5dc0236846 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:25:07 +0100 Subject: [PATCH 25/37] Update hardware.pm --- centreon-plugins/network/raisecom/snmp/mode/hardware.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm index 7c42c9c74..9c1fa87ce 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::raisecom::mode::hardware; +package network::raisecom::snmp::mode::hardware; use base qw(centreon::plugins::templates::hardware); From ef551b9a6ea4cc37f87857a34cb16c542afefa2d Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:26:29 +0100 Subject: [PATCH 26/37] Update fan.pm --- centreon-plugins/network/raisecom/snmp/mode/components/fan.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm index d3be38bfb..e44c318fb 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::f5::bigip::mode::components::fan; +package network::raisecom::snmp::mode::components::fan; use strict; use warnings; From e8aaa4304e186f3324c076b7a2395fb974b047a5 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:26:50 +0100 Subject: [PATCH 27/37] Update psu.pm --- centreon-plugins/network/raisecom/snmp/mode/components/psu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm index bd721727f..90027b02a 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::raisecom::mode::components::psu; +package network::raisecom::snmp::mode::components::psu; use strict; use warnings; From b7de0e3317de6a738700277ef4b8c01ad08d689f Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:27:07 +0100 Subject: [PATCH 28/37] Update temperature.pm --- .../network/raisecom/snmp/mode/components/temperature.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm index 8803aed9e..ae3ac349d 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::raisecom::mode::components::temperature; +package network::raisecom::snmp::mode::components::temperature; use strict; use warnings; From 14362b92e8eba5a46124701978b9c70f039d3283 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:29:01 +0100 Subject: [PATCH 29/37] Update hardware.pm --- centreon-plugins/network/raisecom/snmp/mode/hardware.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm index 9c1fa87ce..c9e504ab1 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -46,7 +46,7 @@ sub set_system { ], }; - $self->{components_path} = 'network::raisecom::mode::components'; + $self->{components_path} = 'network::raisecom::snmp::mode::components'; $self->{components_module} = ['fan', 'psu', 'temperature']; } From 9bd0fc6586c8364c977275505bc1665ef7781cb2 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:37:35 +0100 Subject: [PATCH 30/37] Update psu.pm --- .../raisecom/snmp/mode/components/psu.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm index 90027b02a..cfd940c9a 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm @@ -30,13 +30,13 @@ my %map_status = ( ); my $mapping = { - sysChassisPowerSupplyStatus => { oid => '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1.2', map => \%map_status }, + raisecomAlarmPowerStatus => { oid => '.1.3.6.1.4.1.8886.1.1.4.5.3.6', map => \%map_status }, }; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $mapping->{sysChassisPowerSupplyStatus}->{oid} }; + push @{$self->{request}}, { oid => $mapping->{raisecomAlarmPowerStatus}->{oid} }; } sub check { @@ -46,25 +46,25 @@ sub check { $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}->{$mapping->{sysChassisPowerSupplyStatus}->{oid}}})) { - $oid =~ /^$mapping->{sysChassisPowerSupplyStatus}->{oid}\.(.*)$/; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{raisecomAlarmPowerStatus}->{oid}}})) { + $oid =~ /^$mapping->{raisecomAlarmPowerStatus}->{oid}\.(.*)$/; my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{sysChassisPowerSupplyStatus}->{oid}}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{raisecomAlarmPowerStatus}->{oid}}, instance => $instance); - next if ($result->{sysChassisPowerSupplyStatus} =~ /notPresent/i && + next if ($result->{raisecomAlarmPowerStatus} =~ /notPresent/i && $self->absent_problem(section => 'psu', 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->{sysChassisPowerSupplyStatus}, $instance + $instance, $result->{raisecomAlarmPowerStatus}, $instance )); - my $exit = $self->get_severity(section => 'psu', value => $result->{sysChassisPowerSupplyStatus}); + my $exit = $self->get_severity(section => 'psu', value => $result->{raisecomAlarmPowerStatus}); 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->{sysChassisPowerSupplyStatus})); + $instance, $result->{raisecomAlarmPowerStatus})); } } } From be33cdefe2068ab06d989ba655884cf3de69e6b9 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:49:03 +0100 Subject: [PATCH 31/37] Delete fan.pm --- .../raisecom/snmp/mode/components/fan.pm | 87 ------------------- 1 file changed, 87 deletions(-) delete mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/fan.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm deleted file mode 100644 index e44c318fb..000000000 --- a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm +++ /dev/null @@ -1,87 +0,0 @@ -# -# Copyright 2017 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::raisecom::snmp::mode::components::fan; - -use strict; -use warnings; - -my %map_status = ( - 0 => 'bad', - 1 => 'good', - 2 => 'notPresent', -); - -my $mapping = { - sysChassisFanStatus => { oid => '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1.2', map => \%map_status }, - sysChassisFanSpeed => { oid => '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1.3' }, -}; -my $oid_sysChassisFanEntry = '.1.3.6.1.4.1.3375.2.1.3.2.1.2.1'; - -sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_sysChassisFanEntry }; -} - -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_sysChassisFanEntry}})) { - next if ($oid !~ /^$mapping->{sysChassisFanStatus}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_sysChassisFanEntry}, instance => $instance); - - next if ($result->{sysChassisFanStatus} =~ /notPresent/i && - $self->absent_problem(section => 'fan', instance => $instance)); - next if ($self->check_filter(section => 'fan', instance => $instance)); - - $self->{components}->{fan}->{total}++; - - $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance: %s, speed: %s].", - $instance, $result->{sysChassisFanStatus}, $instance, - defined($result->{sysChassisFanSpeed}) ? $result->{sysChassisFanSpeed} : '-')); - my $exit = $self->get_severity(section => 'fan', value => $result->{sysChassisFanStatus}); - 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'", - $instance, $result->{sysChassisFanStatus})); - } - - if (defined($result->{sysChassisFanSpeed}) && $result->{sysChassisFanSpeed} =~ /[0-9]/) { - my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{sysChassisFanSpeed}); - if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("fan speed '%s' is %s rpm", $instance, $result->{sysChassisFanSpeed})); - } - $self->{output}->perfdata_add(label => "fan_" . $instance, unit => 'rpm', - value => $result->{sysChassisFanSpeed}, - warning => $warn, - critical => $crit, - min => 0); - } - } -} - -1; From 34cab55115917a3c9b635550cff9670ab6e0625e Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:49:11 +0100 Subject: [PATCH 32/37] Delete psu.pm --- .../raisecom/snmp/mode/components/psu.pm | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/psu.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm b/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm deleted file mode 100644 index cfd940c9a..000000000 --- a/centreon-plugins/network/raisecom/snmp/mode/components/psu.pm +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright 2017 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::raisecom::snmp::mode::components::psu; - -use strict; -use warnings; - -my %map_status = ( - 0 => 'bad', - 1 => 'good', - 2 => 'notPresent', -); - -my $mapping = { - raisecomAlarmPowerStatus => { oid => '.1.3.6.1.4.1.8886.1.1.4.5.3.6', map => \%map_status }, -}; - -sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $mapping->{raisecomAlarmPowerStatus}->{oid} }; -} - -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}->{$mapping->{raisecomAlarmPowerStatus}->{oid}}})) { - $oid =~ /^$mapping->{raisecomAlarmPowerStatus}->{oid}\.(.*)$/; - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{raisecomAlarmPowerStatus}->{oid}}, instance => $instance); - - next if ($result->{raisecomAlarmPowerStatus} =~ /notPresent/i && - $self->absent_problem(section => 'psu', 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->{raisecomAlarmPowerStatus}, $instance - )); - my $exit = $self->get_severity(section => 'psu', value => $result->{raisecomAlarmPowerStatus}); - 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->{raisecomAlarmPowerStatus})); - } - } -} - -1; From 1e6135524bf7294a6a958b6047aed97ed31dacfb Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 6 Feb 2017 14:52:01 +0100 Subject: [PATCH 33/37] Update hardware.pm --- centreon-plugins/network/raisecom/snmp/mode/hardware.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm index c9e504ab1..29a30c658 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -47,7 +47,7 @@ sub set_system { }; $self->{components_path} = 'network::raisecom::snmp::mode::components'; - $self->{components_module} = ['fan', 'psu', 'temperature']; + $self->{components_module} = ['temperature']; #['fan', 'psu', 'temperature']; } sub snmp_execute { @@ -76,14 +76,14 @@ __END__ =head1 MODE -Check hardware (fans, temperatures, power supplies). +Check hardware (temperatures). =over 8 =item B<--component> Which component to check (Default: '.*'). -Can be: 'fan', 'psu', 'temperature'. +Can be: 'temperature'. =item B<--filter> From c9bc9e6dd7944a043405f770ea429a5037b5af89 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 8 Feb 2017 13:32:18 +0100 Subject: [PATCH 34/37] Add fan and voltage --- .../network/raisecom/snmp/mode/hardware.pm | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm index 29a30c658..3f82c2737 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -27,32 +27,26 @@ use warnings; sub set_system { my ($self, %options) = @_; - - $self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|psu)$'; - $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; - + + $self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|voltage)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|voltage)$'; + $self->{cb_hook2} = 'snmp_execute'; - + $self->{thresholds} = { fan => [ - ['bad', 'CRITICAL'], - ['good', 'OK'], - ['notPresent', 'OK'], - ], - psu => [ - ['bad', 'CRITICAL'], - ['good', 'OK'], - ['notPresent', 'OK'], + ['abnormal', 'CRITICAL'], + ['normal', 'OK'], ], }; - + $self->{components_path} = 'network::raisecom::snmp::mode::components'; - $self->{components_module} = ['temperature']; #['fan', 'psu', 'temperature']; + $self->{components_module} = ['fan', 'temperature', 'voltage']; } sub snmp_execute { my ($self, %options) = @_; - + $self->{snmp} = $options{snmp}; $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); } @@ -61,7 +55,7 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $self->{version} = '1.0'; $options{options}->add_options(arguments => { @@ -76,7 +70,7 @@ __END__ =head1 MODE -Check hardware (temperatures). +Check hardware (temperatures, fans, voltages). =over 8 @@ -114,4 +108,3 @@ Example: --critical='temperature,.*,40' =back =cut - From 398d253b02e771dabe3afd5cc56f52ebe4a8cf8d Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 8 Feb 2017 13:41:30 +0100 Subject: [PATCH 35/37] Add system thresholds by default --- .../snmp/mode/components/temperature.pm | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm index ae3ac349d..7d84746f6 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm @@ -25,12 +25,15 @@ use warnings; my $mapping = { raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' }, + raisecomTemperatureThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.5' }, + raisecomTemperatureThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.6' }, }; +my $oid_raisecomTemperatureEntry = '.1.3.6.1.4.1.8886.1.1.4.2'; sub load { my ($self) = @_; - - push @{$self->{request}}, { oid => $mapping->{raisecomTemperatureValue}->{oid} }; + + push @{$self->{request}}, { oid => $oid_raisecomTemperatureEntry }; } sub check { @@ -40,29 +43,40 @@ sub check { $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}->{$mapping->{raisecomTemperatureValue}->{oid}}})) { - $oid =~ /^$mapping->{raisecomTemperatureValue}->{oid}\.(.*)$/; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomTemperatureEntry}})) { + next if ($oid !~ /^$mapping->{raisecomTemperatureValue}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{raisecomTemperatureValue}->{oid}}, instance => $instance); - + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomTemperatureEntry}, instance => $instance); + next if ($self->check_filter(section => 'temperature', instance => $instance)); - $self->{components}->{temperature}->{total}++; - $self->{output}->output_add(long_msg => sprintf("temperature '%s' is %.2f C [instance: %s].", + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' is %.2f C [instance: %s].", $instance, $result->{raisecomTemperatureValue}, $instance )); - - if (defined($result->{raisecomTemperatureValue}) && $result->{raisecomTemperatureValue} =~ /[0-9]/) { - my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{sysChassisTempTemperature}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature '%s' is %.2f C", $instance, $result->{raisecomTemperatureValue})); - } - $self->{output}->perfdata_add(label => "temp_" . $instance, unit => 'C', - value => sprintf("%.2f", $result->{raisecomTemperatureValue}), - warning => $warn, - critical => $crit); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{raisecomTemperatureValue}); + if ($checked == 0) { + my $warn_th = ':' . $result->{raisecomTemperatureThresholdLow}; + my $crit_th = ':' . $result->{raisecomTemperatureThresholdHigh}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{raisecomTemperatureValue}, 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 => $exit, + short_msg => sprintf("Temperature '%s' is %.2f C", $instance, $result->{raisecomTemperatureValue})); + } + $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + value => $result->{raisecomTemperatureValue}, + warning => $warn, + critical => $crit, + ); } } From a3fd36e0ca7ab302476b8c0819cea6d858b511fc Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 8 Feb 2017 13:42:56 +0100 Subject: [PATCH 36/37] Create fan.pm --- .../raisecom/snmp/mode/components/fan.pm | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/fan.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm new file mode 100644 index 000000000..f00eebb57 --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm @@ -0,0 +1,78 @@ +# +# Copyright 2017 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::raisecom::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_fan_state = ( + 1 => 'normal', + 2 => 'abnormal', +); + +my $mapping = { + raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.2' }, + raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.3', map => \%map_fan_state }, +}; +my $oid_raisecomFanMonitorStateEntry = '.1.3.6.1.4.1.8886.1.1.5.2.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_raisecomFanMonitorStateEntry }; +} + +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')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomFanMonitorStateEntry}})) { + next if ($oid !~ /^$mapping->{raisecomFanWorkState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomFanMonitorStateEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]", + $instance, $result->{raisecomFanWorkState}, $instance)); + my $exit = $self->get_severity(section => 'fan', value => $result->{raisecomFanWorkState}); + 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'", $instance, $result->{raisecomFanWorkState})); + } + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{raisecomFanSpeedValue}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Fan speed '%s' is %s rpm", $instance, $result->{raisecomFanSpeedValue})); + $self->{output}->perfdata_add(label => 'fan_speed_' . $instance, unit => 'rpm', + value => $result->{raisecomFanSpeedValue}, + warning => $warn, + critical => $crit, + ); + } + } +} + +1; From a8e2bb33fafad6b92d8c574fc4428e2e17feb7fc Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 8 Feb 2017 13:43:51 +0100 Subject: [PATCH 37/37] Create voltage.pm --- .../raisecom/snmp/mode/components/voltage.pm | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm b/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm new file mode 100644 index 000000000..83f50d25a --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm @@ -0,0 +1,83 @@ +# +# Copyright 2017 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::raisecom::snmp::mode::components::voltage; + +use strict; +use warnings; + +my $mapping = { + raisecomVoltValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.3' }, + raisecomVoltThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.7' }, + raisecomVoltThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.8' }, +}; +my $oid_raisecomVoltEntry = '.1.3.6.1.4.1.8886.1.1.4.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_raisecomVoltEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking voltages"); + $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; + return if ($self->check_filter(section => 'voltage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomVoltEntry}})) { + next if ($oid !~ /^$mapping->{raisecomVoltValue}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomVoltEntry}, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("voltage '%s' is %.2f V [instance: %s].", + $instance, $result->{raisecomVoltValue}, $instance + )); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{raisecomVoltValue}); + if ($checked == 0) { + my $warn_th = ':' . $result->{raisecomVoltThresholdLow}; + my $crit_th = ':' . $result->{raisecomVoltThresholdHigh}; + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check(value => $result->{raisecomVoltValue}, threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage '%s' is %.2f V", $instance, $result->{raisecomVoltValue})); + } + $self->{output}->perfdata_add(label => 'volt_' . $instance, unit => 'V', + value => $result->{raisecomVoltValue}, + warning => $warn, + critical => $crit, + ); + } +} + +1;