diff --git a/network/aruba/7200/plugin.pm b/network/aruba/7200/plugin.pm new file mode 100644 index 000000000..a485d5fb1 --- /dev/null +++ b/network/aruba/7200/plugin.pm @@ -0,0 +1,70 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::7200::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; + # $options->{options} = options object + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'network::aruba::common::mode::cpu', + 'hardware' => 'network::aruba::common::mode::hardware', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'packet-errors' => 'snmp_standard::mode::packeterrors', + 'traffic' => 'snmp_standard::mode::traffic', + 'memory' => 'network::aruba::common::mode::memory', + 'storage' => 'network::aruba::common::mode::storage', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Aruba 7200 series in SNMP. + +=cut diff --git a/network/aruba/common/mode/components/fan.pm b/network/aruba/common/mode/components/fan.pm new file mode 100644 index 000000000..e3dabce0b --- /dev/null +++ b/network/aruba/common/mode/components/fan.pm @@ -0,0 +1,78 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::components::fan; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'active', + 2 => 'inactive' +); + +sub check { + my ($self) = @_; + + $self->{components}->{fans} = {name => 'fans', total => 0}; + $self->{output}->output_add(long_msg => "Checking fans"); + return if ($self->check_exclude(section => 'fans')); + + my $oid_wlsxSysExtFanEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.17.1'; + my $oid_sysExtFanStatus = '.1.3.6.1.4.1.14823.2.2.1.2.1.17.1.2'; + + my $result = $self->{snmp}->get_table(oid => $oid_wlsxSysExtFanEntry); + return if (scalar(keys %$result) <= 0); + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($key !~ /^$oid_sysExtFanStatus\.(\d+)$/); + my $instance = $1; + + next if ($self->check_exclude(section => 'fans', instance => $instance)); + + my $status = $result->{$oid_sysExtFanStatus . '.' . $instance}; + + $self->{components}->{fans}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s.", + $instance, $map_status{$status})); + if ($status != 1) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Fan '%s' status is %s", + $instance, $map_status{$status})); + } + } +} + +1; \ No newline at end of file diff --git a/network/aruba/common/mode/components/module.pm b/network/aruba/common/mode/components/module.pm new file mode 100644 index 000000000..b5138d097 --- /dev/null +++ b/network/aruba/common/mode/components/module.pm @@ -0,0 +1,100 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::components::module; + +use strict; +use warnings; + +my %map_card_type = ( + 1 => 'lc1', + 2 => 'lc2', + 3 => 'sc1', + 4 => 'sc2', + 5 => 'sw2400', + 6 => 'sw800', + 7 => 'sw200', + 8 => 'm3mk1', + 9 => 'sw3200', + 10 => 'sw3400', + 11 => 'sw3600', + 12 => 'sw650', + 13 => 'sw651', + 14 => 'reserved1', + 15 => 'reserved2', + 16 => 'sw620', + 17 => 'sw3500' +); + +my %map_status = ( + 1 => 'active', + 2 => 'inactive' +); + +sub check { + my ($self) = @_; + + $self->{components}->{modules} = {name => 'modules', total => 0}; + $self->{output}->output_add(long_msg => "Checking modules"); + return if ($self->check_exclude(section => 'modules')); + + my $oid_wlsxSysExtCardEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1'; + my $oid_sysExtCardType = '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1.2'; + my $oid_sysExtCardStatus = '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1.12'; + + my $result = $self->{snmp}->get_table(oid => $oid_wlsxSysExtCardEntry); + return if (scalar(keys %$result) <= 0); + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($key !~ /^$oid_sysExtCardStatus\.(\d+)$/); + my $instance = $1; + + next if ($self->check_exclude(section => 'modules', instance => $instance)); + + my $type = $result->{$oid_sysExtCardType . '.' . $instance}; + my $status = $result->{$oid_sysExtCardStatus . '.' . $instance}; + + $self->{components}->{modules}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s].", + $map_card_type{$type}, $map_status{$status}, $instance)); + if ($status != 1) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Module '%s' status is %s", + $map_card_type{$type}, $map_status{$status})); + } + } +} + +1; \ No newline at end of file diff --git a/network/aruba/common/mode/components/psu.pm b/network/aruba/common/mode/components/psu.pm new file mode 100644 index 000000000..ffee3ec13 --- /dev/null +++ b/network/aruba/common/mode/components/psu.pm @@ -0,0 +1,78 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::components::psu; + +use strict; +use warnings; + +my %map_status = ( + 1 => 'active', + 2 => 'inactive' +); + +sub check { + my ($self) = @_; + + $self->{components}->{psus} = {name => 'psus', total => 0}; + $self->{output}->output_add(long_msg => "Checking power supplies"); + return if ($self->check_exclude(section => 'psus')); + + my $oid_wlsxSysExtPowerSupplyEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.18.1'; + my $oid_sysExtPowerSupplyStatus = '.1.3.6.1.4.1.14823.2.2.1.2.1.18.1.2'; + + my $result = $self->{snmp}->get_table(oid => $oid_wlsxSysExtPowerSupplyEntry); + return if (scalar(keys %$result) <= 0); + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($key !~ /^$oid_sysExtPowerSupplyStatus\.(\d+)$/); + my $instance = $1; + + next if ($self->check_exclude(section => 'psus', instance => $instance)); + + my $status = $result->{$oid_sysExtPowerSupplyStatus . '.' . $instance}; + + $self->{components}->{psus}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s.", + $instance, $map_status{$status})); + if ($status != 1) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Power Supply '%s' status is %s", + $instance, $map_status{$status})); + } + } +} + +1; \ No newline at end of file diff --git a/network/aruba/common/mode/cpu.pm b/network/aruba/common/mode/cpu.pm new file mode 100644 index 000000000..f17f5275c --- /dev/null +++ b/network/aruba/common/mode/cpu.pm @@ -0,0 +1,135 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::cpu; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $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) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_wlsxSysExtProcessorEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.13.1'; + my $oid_sysExtProcessorDescr = '.1.3.6.1.4.1.14823.2.2.1.2.1.13.1.2'; + my $oid_sysExtProcessorLoad = '.1.3.6.1.4.1.14823.2.2.1.2.1.13.1.3'; + my $result = $self->{snmp}->get_table(oid => $oid_wlsxSysExtProcessorEntry, nothing_quit => 1); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All CPUs are ok.'); + + foreach my $oid (keys %$result) { + next if ($oid !~ /^$oid_sysExtProcessorLoad/); + $oid =~ /\.([0-9]+)$/; + my $instance = $1; + my $load = $result->{$oid}; + my $descr = $result->{$oid_sysExtProcessorDescr . '.' . $instance}; + + my $exit = $self->{perfdata}->threshold_check(value => $load, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + $self->{output}->output_add(long_msg => sprintf("CPU '%s': %.2f%% (1min)", $descr, + $load)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU '%s': %.2f%% (1min)", $descr, + $load)); + } + + $self->{output}->perfdata_add(label => "cpu_" . $instance, unit => '%', + value => $load, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check cpu usage (over the last minute) (aruba-systemext). + +=over 8 + +=item B<--warning> + +Threshold warning in percent. + +=item B<--critical> + +Threshold critical in percent. + +=back + +=cut + \ No newline at end of file diff --git a/network/aruba/common/mode/hardware.pm b/network/aruba/common/mode/hardware.pm new file mode 100644 index 000000000..41db0befb --- /dev/null +++ b/network/aruba/common/mode/hardware.pm @@ -0,0 +1,153 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::hardware; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +use network::aruba::common::mode::components::fan; +use network::aruba::common::mode::components::module; +use network::aruba::common::mode::components::psu; + +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 => + { + "exclude:s" => { name => 'exclude' }, + "component:s" => { name => 'component', default => 'all' }, + }); + $self->{components} = {}; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub global { + my ($self, %options) = @_; + + network::aruba::common::mode::components::fan::check($self); + network::aruba::common::mode::components::module::check($self); + network::aruba::common::mode::components::psu::check($self); +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + if ($self->{option_results}->{component} eq 'all') { + $self->global(); + } elsif ($self->{option_results}->{component} eq 'fan') { + network::aruba::common::mode::components::fan::check($self); + } elsif ($self->{option_results}->{component} eq 'module') { + network::aruba::common::mode::components::module::check($self); + } elsif ($self->{option_results}->{component} eq 'psu') { + network::aruba::common::mode::components::psu::check($self); + } else { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } + + my $total_components = 0; + my $display_by_component = ''; + my $display_by_component_append = ''; + foreach my $comp (sort(keys %{$self->{components}})) { + # Skipping short msg when no components + next if ($self->{components}->{$comp}->{total} == 0); + $total_components += $self->{components}->{$comp}->{total}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name}; + $display_by_component_append = ', '; + } + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All %s components [%s] are ok.", + $total_components, + $display_by_component + ) + ); + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub check_exclude { + my ($self, %options) = @_; + + if (defined($options{instance})) { + if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#$options{instance}#/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } + return 0; +} + +1; + +__END__ + +=head1 MODE + +Check hardware (modules, fans, power supplies). + +=over 8 + +=item B<--component> + +Which component to check (Default: 'all'). +Can be: 'fan', 'psu', 'module'. + +=item B<--exclude> + +Exclude some parts (comma seperated list) (Example: --exclude=fans,modules) +Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus + +=back + +=cut + \ No newline at end of file diff --git a/network/aruba/common/mode/memory.pm b/network/aruba/common/mode/memory.pm new file mode 100644 index 000000000..1a52f7c22 --- /dev/null +++ b/network/aruba/common/mode/memory.pm @@ -0,0 +1,159 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::memory; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $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) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_wlsxSysExtMemoryEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.15.1'; + my $oid_sysExtMemoryUsed = '.1.3.6.1.4.1.14823.2.2.1.2.1.15.1.3'; # in KB + my $oid_sysExtMemoryFree = '.1.3.6.1.4.1.14823.2.2.1.2.1.15.1.4'; # in KB + my $result = $self->{snmp}->get_table(oid => $oid_wlsxSysExtMemoryEntry, nothing_quit => 1); + my $mode = 0; + + if (scalar(keys %$result) > 3) { + # Not Only Control Processor memory + $mode = 1; + $self->{output}->output_add(severity => 'OK', + short_msg => 'All pool memories are ok.'); + } + + foreach my $oid (keys %$result) { + next if ($oid !~ /^$oid_sysExtMemoryFree/); + $oid =~ /\.([0-9]+)$/; + + my $memory_name = ($mode == 1) ? $1 : 'Control Processor'; + my $memory_used = $result->{$oid_sysExtMemoryUsed . '.' . $1} * 1024; + my $memory_free =$result->{$oid_sysExtMemoryFree . '.' . $1} * 1024; + + my $total_size = $memory_used + $memory_free; + my $prct_used = $memory_used * 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 => $memory_used); + my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); + + $self->{output}->output_add(long_msg => sprintf("Memory '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $memory_name, + $total_value . " " . $total_unit, + $used_value . " " . $used_unit, $prct_used, + $free_value . " " . $free_unit, $prct_free)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1) || $mode == 0) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $memory_name, + $total_value . " " . $total_unit, + $used_value . " " . $used_unit, $prct_used, + $free_value . " " . $free_unit, $prct_free)); + } + + if ($mode == 1) { + $self->{output}->perfdata_add(label => "used_" . $memory_name, + value => $memory_used, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), + min => 0, max => $total_size); + } else { + $self->{output}->perfdata_add(label => "used", + value => $memory_used, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size), + min => 0, max => $total_size); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check memory usage (aruba-systemext). + +=over 8 + +=item B<--warning> + +Threshold warning in percent. + +=item B<--critical> + +Threshold critical in percent. + +=back + +=cut + \ No newline at end of file diff --git a/network/aruba/common/mode/storage.pm b/network/aruba/common/mode/storage.pm new file mode 100644 index 000000000..2900a93c6 --- /dev/null +++ b/network/aruba/common/mode/storage.pm @@ -0,0 +1,183 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::aruba::common::mode::storage; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my %map_storage_type = ( + 1 => 'ram', + 2 => 'flashMemory' +); + +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 => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "filter-name:s" => { name => 'filter_name' }, + "filter-type:s" => { name => 'filter_type' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $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) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_wlsxSysExtStorageEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1'; + my $oid_sysExtStorageType = '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.2'; + my $oid_sysExtStorageName = '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.5'; + my $oid_sysExtStorageSize = '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.3'; # MB + my $oid_sysExtStorageUsed = '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.4'; # MB + + my $storage_num = 0; + my $result = $self->{snmp}->get_table(oid => $oid_wlsxSysExtStorageEntry, nothing_quit => 1); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'All storages are ok.'); + + foreach my $oid (keys %$result) { + next if ($oid !~ /^$oid_sysExtStorageSize/); + $oid =~ /\.([0-9]+)$/; + + my $name = $result->{$oid_sysExtStorageName . '.' . $1}; + my $type = $result->{$oid_sysExtStorageType . '.' . $1};; + my $total_used = $result->{$oid_sysExtStorageUsed . '.' . $1} * 1024 * 1024; + my $total_size = $result->{$oid_sysExtStorageSize . '.' . $1} * 1024 * 1024; + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $name)); + next; + } + if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && + $map_storage_type{$type} !~ /$self->{option_results}->{filter_type}/i) { + $self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $name)); + next; + } + + $storage_num++; + my $total_free = $total_size - $total_used; + my $prct_used = $total_used * 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_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $total_size); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $total_used); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $total_free); + + $self->{output}->output_add(long_msg => sprintf("Storage '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $name, + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $prct_used, + $total_free_value . " " . $total_free_unit, $prct_free)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Storage '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $name, + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $prct_used, + $total_free_value . " " . $total_free_unit, $prct_free)); + } + + $self->{output}->perfdata_add(label => 'used_' . $name, unit => 'B', + value => $total_used, + 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); + } + + if ($storage_num == 0) { + $self->{output}->add_option_msg(short_msg => "No storage information found (maybe your filters)"); + $self->{output}->option_exit(); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check storage device usage (aruba-systemext). + +=over 8 + +=item B<--warning> + +Threshold warning in percent. + +=item B<--critical> + +Threshold critical in percent. + +=item B<--filter-name> + +Filter storage device name (regexp can be used). + +=item B<--filter-type> + +Filter storage device type (regexp can be used). +Can use: 'ram', 'flashMemory' + +=back + +=cut diff --git a/snmp_standard/mode/traffic.pm b/snmp_standard/mode/traffic.pm index fe16f51e4..68d3d145b 100644 --- a/snmp_standard/mode/traffic.pm +++ b/snmp_standard/mode/traffic.pm @@ -66,6 +66,7 @@ sub new { "interface:s" => { name => 'interface' }, "speed:s" => { name => 'speed' }, "skip" => { name => 'skip' }, + "skip-speed0" => { name => 'skip_speed0' }, "regexp" => { name => 'use_regexp' }, "regexp-isensitive" => { name => 'use_regexpi' }, "oid-filter:s" => { name => 'oid_filter', default => 'ifname'}, @@ -175,8 +176,12 @@ sub run { } $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' ? ($result->{$oid_speed64 . "." . $_} * 1000000) : ($result->{$oid_speed32 . "." . $_})); if ($interface_speed == 0) { - $self->{output}->output_add(severity => 'UNKNOWN', - short_msg => "Interface '" . $display_value . "' Speed is 0. You should force the value with --speed option"); + if (!defined($self->{option_results}->{skip_speed0})) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => "Interface '" . $display_value . "' Speed is 0. You should force the value with --speed option"); + } else { + $self->{output}->output_add(long_msg => "Skip interface '" . $display_value . "' (speed is 0)."); + } next; } } @@ -431,6 +436,10 @@ Set interface speed (in Mb). Skip errors on interface status. +=item B<--skip-speed0> + +Skip errors on interface with speed 0. + =item B<--reload-cache-time> Time in seconds before reloading cache file (default: 180).