diff --git a/centreon-plugins/network/alcatel/common/mode/components/backplane.pm b/centreon-plugins/network/alcatel/common/mode/components/backplane.pm new file mode 100644 index 000000000..c03e57758 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/backplane.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::backplane; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking backplane"); + $self->{components}->{backplane} = {name => 'backplanes', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'backplane')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 4) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'backplane', instance => $instance)); + $self->{components}->{backplane}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("backplane '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("backplane '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("backplane '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/chassis.pm b/centreon-plugins/network/alcatel/common/mode/components/chassis.pm new file mode 100644 index 000000000..b45f6c333 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/chassis.pm @@ -0,0 +1,155 @@ +################################################################################ +# 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::alcatel::common::mode::components::chassis; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking chassis"); + $self->{components}->{chassis} = {name => 'chassis', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'chassis')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 3) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + return if (scalar(@instances) == 0); + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'chassis', instance => $instance)); + $self->{components}->{chassis}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("chassis '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("chassis '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("chassis '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } + + # Check board temp + $self->{snmp}->load(oids => [$oids{chasHardwareBoardTemp}, $oids{chasTempThreshold}, $oids{chasDangerTempThreshold}], + instances => [@instances]); + my $result = $self->{snmp}->get_leef(); + foreach my $instance (@instances) { + my $value = defined($result->{$oids{chasHardwareBoardTemp} . '.' . $instance}) ? + $result->{$oids{chasHardwareBoardTemp} . '.' . $instance} : undef; + my $warn = defined($result->{$oids{chasTempThreshold} . '.' . $instance}) ? + $result->{$oids{chasTempThreshold} . '.' . $instance} : undef; + my $crit = defined($result->{$oids{chasDangerTempThreshold} . '.' . $instance}) ? + $result->{$oids{chasDangerTempThreshold} . '.' . $instance} : undef; + + next if (!defined($value)); + + $self->{perfdata}->threshold_validate(label => 'warning_' . $instance, value => $warn); + $self->{perfdata}->threshold_validate(label => 'critical_' . $instance, value => $crit); + + my $exit = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical_' . $instance, 'exit_litteral' => 'critical' }, { label => 'warning_' . $instance, exit_litteral => 'warning' } ]); + $self->{output}->output_add(long_msg => sprintf("Temperature board '%s' value is %s C.", + $instance, $value)); + if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature board '%s' value is %s C", $instance, $value)); + } + + $self->{output}->perfdata_add(label => 'temp_board_' . $instance, unit => 'C', + value => $value, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_' . $instance), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_' . $instance), + ); + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/container.pm b/centreon-plugins/network/alcatel/common/mode/components/container.pm new file mode 100644 index 000000000..9a334c250 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/container.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::container; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking container"); + $self->{components}->{container} = {name => 'containers', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'container')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 5) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'container', instance => $instance)); + $self->{components}->{container}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("container '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("container '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("container '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/fan.pm b/centreon-plugins/network/alcatel/common/mode/components/fan.pm new file mode 100644 index 000000000..125f3e706 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/fan.pm @@ -0,0 +1,161 @@ +################################################################################ +# 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::alcatel::common::mode::components::fan; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +my @fan_conditions = ( + ['^noStatus$', 'UNKNOWN'], + ['^notRunning$', 'CRITICAL'], + ['^(?!(running)$)', 'UNKNOWN'], +); + +my %fan_status = ( + 0 => 'noStatus', + 1 => 'notRunning', + 2 => 'running', +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fan"); + $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'fan')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 7) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'fan', instance => $instance)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fan '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("fan '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("fan '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } + + foreach my $key (keys %{$self->{results}->{$oids{alaChasEntPhysFanStatus}}}) { + next if ($key !~ /^$oids{alaChasEntPhysFanStatus}\.(.*?)\.(.*?)$/); + my ($phys_index, $loc_index) = ($1, $2); + my $status = $self->{results}->{$oids{alaChasEntPhysFanStatus}}->{$key}; + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $phys_index}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $phys_index} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $phys_index}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $phys_index} : 'unknown'; + + next if ($self->check_exclude(section => 'fan', instance => $phys_index . '.' . $loc_index)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fan '%s/%s' [instance: %s] status is %s.", + $name, $descr, $loc_index, + $fan_status{$status}) + ); + foreach (@fan_conditions) { + if ($fan_status{$status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("fan '%s/%s/%s' status is %s.", + $name, $descr, $loc_index, + $fan_status{$status}) + ); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/module.pm b/centreon-plugins/network/alcatel/common/mode/components/module.pm new file mode 100644 index 000000000..9a9a5ec25 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/module.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::module; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking module"); + $self->{components}->{module} = {name => 'modules', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'module')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 9) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'module', instance => $instance)); + $self->{components}->{module}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("module '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("module '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("module '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/other.pm b/centreon-plugins/network/alcatel/common/mode/components/other.pm new file mode 100644 index 000000000..e8d55543f --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/other.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::other; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking other"); + $self->{components}->{other} = {name => 'others', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'other')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 1) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'other', instance => $instance)); + $self->{components}->{other}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("other '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("other '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("other '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/port.pm b/centreon-plugins/network/alcatel/common/mode/components/port.pm new file mode 100644 index 000000000..80759f1f4 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/port.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::port; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking port"); + $self->{components}->{port} = {name => 'ports', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'port')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 10) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'port', instance => $instance)); + $self->{components}->{port}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("port '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("port '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("port '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm b/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm new file mode 100644 index 000000000..906822db9 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/powersupply.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::powersupply; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking psu"); + $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'psu')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 6) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power supply '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("power supply '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("power supply '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/resources.pm b/centreon-plugins/network/alcatel/common/mode/components/resources.pm new file mode 100644 index 000000000..86c9a1d2f --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/resources.pm @@ -0,0 +1,104 @@ +################################################################################ +# 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::alcatel::common::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our %physical_class; +our %phys_oper_status; +our %phys_admin_status; +our %oids; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +%physical_class = ( + 1 => 'other', + 2 => 'unknown', + 3 => 'chassis', + 4 => 'backplane', + 5 => 'container', + 6 => 'powerSupply', + 7 => 'fan', + 8 => 'sensor', + 9 => 'module', + 10 => 'port', + 11 => 'stack', +); + +%phys_oper_status = ( + 1 => 'up', + 2 => 'down', + 3 => 'testing', + 4 => 'unknown', + 5 => 'secondary', + 6 => 'not present', + 7 => 'unpowered', + 8 => 'master', + 9 => 'idle', + 10 => 'unpoweredLicMismatch', +); + +%phys_admin_status = ( + 1 => 'unknown', + 2 => 'powerOff', + 3 => 'powerOn', + 4 => 'reset', + 5 => 'takeover', + 6 => 'resetAll', + 7 => 'standby', + 8 => 'resetWithFabric', + 9 => 'takeoverWithFabrc', +); + +%oids = ( + entPhysicalDescr => '.1.3.6.1.2.1.47.1.1.1.1.2', + entPhysicalClass => '.1.3.6.1.2.1.47.1.1.1.1.5', + entPhysicalName => '.1.3.6.1.2.1.47.1.1.1.1.7', + chasEntPhysAdminStatus => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1.1', + chasEntPhysOperStatus => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1.2', + chasEntPhysPower => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1.4', + + chasHardwareBoardTemp => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.4', + chasTempThreshold => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.7', + chasDangerTempThreshold => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.8', + + alaChasEntPhysFanStatus => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.11.1.2', +); + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/sensor.pm b/centreon-plugins/network/alcatel/common/mode/components/sensor.pm new file mode 100644 index 000000000..a028cbaa8 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/sensor.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::sensor; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking sensor"); + $self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'sensor')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 8) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'sensor', instance => $instance)); + $self->{components}->{sensor}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("sensor '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("sensor '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("sensor '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/stack.pm b/centreon-plugins/network/alcatel/common/mode/components/stack.pm new file mode 100644 index 000000000..ac6aecac4 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/stack.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::stack; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking stack"); + $self->{components}->{stack} = {name => 'stacks', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'stack')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 11) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'stack', instance => $instance)); + $self->{components}->{stack}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("stack '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("stack '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("stack '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/components/unknown.pm b/centreon-plugins/network/alcatel/common/mode/components/unknown.pm new file mode 100644 index 000000000..493b85453 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/components/unknown.pm @@ -0,0 +1,121 @@ +################################################################################ +# 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::alcatel::common::mode::components::unknown; + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%physical_class %phys_oper_status %phys_admin_status %oids); + +my @admin_conditions = ( + ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], + ['^(powerOff)$', 'CRITICAL'], + ['^(?!(powerOn|standby)$)', 'UNKNOWN'], +); + +my @oper_conditions = ( + ['^(testing)$', 'WARNING'], + ['^(unpowered|down|notpresent)$', 'CRITICAL'], + ['^(?!(up|secondary|master|idle)$)', 'UNKNOWN'], +); + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking unknown"); + $self->{components}->{unknown} = {name => 'unknowns', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'unknown')); + + my @instances = (); + foreach my $key (keys %{$self->{results}->{$oids{entPhysicalClass}}}) { + if ($self->{results}->{$oids{entPhysicalClass}}->{$key} == 2) { + next if ($key !~ /^$oids{entPhysicalClass}\.(.*)$/); + push @instances, $1; + } + } + + foreach my $instance (@instances) { + next if (!defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance})); + + my $descr = defined($self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalDescr}}->{$oids{entPhysicalDescr} . '.' . $instance} : 'unknown'; + my $name = defined($self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance}) ? + $self->{results}->{$oids{entPhysicalName}}->{$oids{entPhysicalName} . '.' . $instance} : 'unknown'; + my $admin_status = defined($self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysAdminStatus}}->{$oids{chasEntPhysAdminStatus} . '.' . $instance} : 1; + my $oper_status = defined($self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysOperStatus}}->{$oids{chasEntPhysOperStatus} . '.' . $instance} : 4; + my $power = defined($self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance}) ? + $self->{results}->{$oids{chasEntPhysPower}}->{$oids{chasEntPhysPower} . '.' . $instance} : -1; + + next if ($self->check_exclude(section => 'unknown', instance => $instance)); + $self->{components}->{unknown}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("unknown '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", + $name, $descr, $instance, + $phys_admin_status{$admin_status}, $phys_oper_status{$oper_status}) + ); + + my $go_forward = 1; + foreach (@admin_conditions) { + if ($phys_admin_status{$admin_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("unknown '%s/%s/%s' admin status is %s", + $name, $descr, $instance, $phys_admin_status{$admin_status})); + $go_forward = 0; + last; + } + } + + if ($power > 0) { + $self->{output}->perfdata_add(label => "power_" . $instance, unit => 'W', + value => $power, + min => 0); + } + + next if ($go_forward == 0); + + foreach (@oper_conditions) { + if ($phys_oper_status{$oper_status} =~ /$$_[0]/i) { + $self->{output}->output_add(severity => $$_[1], + short_msg => sprintf("unknown '%s/%s/%s' oeprationnal status is %s", + $name, $descr, $instance, $phys_oper_status{$oper_status})); + last; + } + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/cpu.pm b/centreon-plugins/network/alcatel/common/mode/cpu.pm new file mode 100644 index 000000000..3afed8334 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/cpu.pm @@ -0,0 +1,149 @@ +################################################################################ +# 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 +# Stephande Duret +# Simon Bomm +# +#################################################################################### + +package network::alcatel::omniswitch::6850::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', default => '80,90' }, + "critical:s" => { name => 'critical', default => '80,90' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + ($self->{warn1m}, $self->{warn1h}) = split /,/, $self->{option_results}->{warning}; + ($self->{crit1m}, $self->{crit1h}) = split /,/, $self->{option_results}->{critical}; + + if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warn1h', value => $self->{warn1h})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (1hour) threshold '" . $self->{warn1h} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit5h', value => $self->{crit5})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (1hout) threshold '" . $self->{crit1h} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_CpuAvg1m = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.14.0'; + my $oid_CpuAvg1h = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.15.0'; + my $result = $self->{snmp}->get_table(oid => [$oid_CpuAvg1m, $oid_CpuAvg1h], nothing_quit => 1); + + my $cpu1min = $result->{$oid_CpuAvg1m}; + my $cpu1hour = $result->{$oid_CpuAvg1h}; + + my $exit1 = $self->{perfdata}->threshold_check(value => $cpu1min, threshold => [ { label => 'crit1m', 'exit_litteral' => 'critical' }, + { label => 'warn1m', exit_litteral => 'warning' }, + ]); + + my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1hour, threshold => [ { label => 'crit1h', exit_litteral => 'critical' }, + { label => 'warn1h', exit_litteral => 'warning' }, + ]); + + my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); + + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("CPU '%s': %.2f%% (1min), %.2f%% (1hour))", $cpu1min, $cpu1hour)); + + $self->{output}->perfdata_add(label => "cpu1m", unit => '%', + value => $cpu1min, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), + min => 0, max => 100); + $self->{output}->perfdata_add(label => "cpu1h", unit => '%', + value => $cpu1hour, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1h'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1h'), + min => 0, max => 100); + + + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check cpu usage (ALCATEL-IND1-HEALTH-MIB (v2)) + +=over 8 + +=item B<--warning> + +Threshold warning in percent (1m,1h). + +=item B<--critical> + +Threshold critical in percent (1m,1h). + +=back + +=cut + diff --git a/centreon-plugins/network/alcatel/common/mode/hardware.pm b/centreon-plugins/network/alcatel/common/mode/hardware.pm new file mode 100644 index 000000000..a82f112d3 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/hardware.pm @@ -0,0 +1,217 @@ +################################################################################ +# 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::alcatel::common::mode::hardware; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use network::alcatel::common::mode::components::resources qw(%oids); +use network::alcatel::common::mode::components::backplane; +use network::alcatel::common::mode::components::chassis; +use network::alcatel::common::mode::components::container; +use network::alcatel::common::mode::components::fan; +use network::alcatel::common::mode::components::module; +use network::alcatel::common::mode::components::other; +use network::alcatel::common::mode::components::port; +use network::alcatel::common::mode::components::powersupply; +use network::alcatel::common::mode::components::sensor; +use network::alcatel::common::mode::components::stack; +use network::alcatel::common::mode::components::unknown; + +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' }, + "no-component:s" => { name => 'no_component' }, + }); + + $self->{components} = {}; + $self->{no_components} = undef; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (defined($self->{option_results}->{no_component})) { + if ($self->{option_results}->{no_component} ne '') { + $self->{no_components} = $self->{option_results}->{no_component}; + } else { + $self->{no_components} = 'critical'; + } + } +} + +sub component { + my ($self, %options) = @_; + + if ($self->{option_results}->{component} eq 'all') { + network::alcatel::common::mode::components::backplane::check($self); + network::alcatel::common::mode::components::chassis::check($self); + network::alcatel::common::mode::components::container::check($self); + network::alcatel::common::mode::components::fan::check($self); + network::alcatel::common::mode::components::module::check($self); + network::alcatel::common::mode::components::other::check($self); + network::alcatel::common::mode::components::port::check($self); + network::alcatel::common::mode::components::powersupply::check($self); + network::alcatel::common::mode::components::sensor::check($self); + network::alcatel::common::mode::components::stack::check($self); + network::alcatel::common::mode::components::unknown::check($self); + } elsif ($self->{option_results}->{component} eq 'backplane') { + network::alcatel::common::mode::components::backplane::check($self); + } elsif ($self->{option_results}->{component} eq 'chassis') { + network::alcatel::common::mode::components::chassis::check($self); + } elsif ($self->{option_results}->{component} eq 'container') { + network::alcatel::common::mode::components::container::check($self); + } elsif ($self->{option_results}->{component} eq 'fan') { + network::alcatel::common::mode::components::fan::check($self); + } elsif ($self->{option_results}->{component} eq 'module') { + network::alcatel::common::mode::components::module::check($self); + } elsif ($self->{option_results}->{component} eq 'other') { + network::alcatel::common::mode::components::other::check($self); + } elsif ($self->{option_results}->{component} eq 'port') { + network::alcatel::common::mode::components::port::check($self); + } elsif ($self->{option_results}->{component} eq 'psu') { + network::alcatel::common::mode::components::powersupply::check($self); + } elsif ($self->{option_results}->{component} eq 'sensor') { + network::alcatel::common::mode::components::sensor::check($self); + } elsif ($self->{option_results}->{component} eq 'stack') { + network::alcatel::common::mode::components::stack::check($self); + } elsif ($self->{option_results}->{component} eq 'unknown') { + network::alcatel::common::mode::components::unknown::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 && $self->{components}->{$comp}->{skip} == 0); + $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $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) + ); + + if (defined($self->{option_results}->{no_component}) && $total_components == 0) { + $self->{output}->output_add(severity => $self->{no_components}, + short_msg => 'No components are checked.'); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oids{entPhysicalDescr} }, + { oid => $oids{entPhysicalClass} }, + { oid => $oids{entPhysicalName} }, + { oid => $oids{chasEntPhysAdminStatus} }, + { oid => $oids{chasEntPhysOperStatus} }, + { oid => $oids{chasEntPhysPower} }, + { oid => $oids{alaChasEntPhysFanStatus} }, + ]); + $self->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}}[^,]*#\Q$options{instance}\E#/) { + $self->{components}->{$options{section}}->{skip}++; + $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 status of alcatel hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: 'all'). +Can be: 'other', 'unknown', 'chassis', 'backplane', 'container', 'psu', 'fan', +'sensor', 'module', 'port, 'stack'. +Some not exists ;) + +=item B<--exclude> + +Exclude some parts (comma seperated list) (Example: --exclude=fan) +Can also exclude specific instance: --exclude=fan#1.2#,module + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/network/alcatel/common/mode/memory.pm b/centreon-plugins/network/alcatel/common/mode/memory.pm new file mode 100644 index 000000000..c6c2aca48 --- /dev/null +++ b/centreon-plugins/network/alcatel/common/mode/memory.pm @@ -0,0 +1,149 @@ +################################################################################ +# 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 +# Stephande Duret +# Simon Bomm +# +#################################################################################### + +package network::alcatel::omniswitch::6850::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', default => '80,90' }, + "critical:s" => { name => 'critical', default => '80,90' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + ($self->{warn1m}, $self->{warn1h}) = split /,/, $self->{option_results}->{warning}; + ($self->{crit1m}, $self->{crit1h}) = split /,/, $self->{option_results}->{critical}; + + if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warn1h', value => $self->{warn1h})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (1hour) threshold '" . $self->{warn1h} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'crit5h', value => $self->{crit5})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (1hout) threshold '" . $self->{crit1h} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_healthDeviceMemory1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.10.0'; + my $oid_healthDeviceMemory1HrAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.11.0'; + my $result = $self->{snmp}->get_table(oid => [$oid_healthDeviceMemory1MinAvg, $oid_healthDeviceMemory1HrAvg], nothing_quit => 1); + + my $mem1min = $result->{$oid_healthDeviceMemory1MinAvg}; + my $mem1hour = $result->{$oid_healthDeviceMemory1HrAvg}; + + my $exit1 = $self->{perfdata}->threshold_check(value => $mem1min, threshold => [ { label => 'crit1m', 'exit_litteral' => 'critical' }, + { label => 'warn1m', exit_litteral => 'warning' }, + ]); + + my $exit2 = $self->{perfdata}->threshold_check(value => $mem1hour, threshold => [ { label => 'crit1h', exit_litteral => 'critical' }, + { label => 'warn1h', exit_litteral => 'warning' }, + ]); + + my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); + + + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory '%s': %.2f%% (1min), %.2f%% (1hour))", $mem1min, $mem1hour) + ); + + $self->{output}->perfdata_add(label => "memory1m", unit => '%', + value => $mem1min, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), + min => 0, max => 100); + $self->{output}->perfdata_add(label => "memory1h", unit => '%', + value => $mem1hour, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1h'), + min => 0, max => 100); + + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check cpu usage (ALCATEL-IND1-HEALTH-MIB (v2)) + +=over 8 + +=item B<--warning> + +Threshold warning in percent (1m,1h). + +=item B<--critical> + +Threshold critical in percent (1m,1h). + +=back + +=cut + diff --git a/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm b/centreon-plugins/network/alcatel/omniswitch/6850/plugin.pm new file mode 100644 index 000000000..5319b2161 --- /dev/null +++ b/centreon-plugins/network/alcatel/omniswitch/6850/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::alcatel::omniswitch::6850::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} = '0.5'; + %{$self->{modes}} = ( + 'cpu' => 'network::alcatel::common::mode::cpu', + 'hardware' => 'network::alcatel::common::mode::hardware', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::alcatel::common::mode::memory', + 'packet-errors' => 'snmp_standard::mode::packeterrors', + 'spanning-tree' => 'snmp_standard::mode::spanningtree', + 'traffic' => 'snmp_standard::mode::traffic', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Alcatel Omniswitch 6850 in SNMP. + +=cut