From 87628d7ba26f34685454dcf87c81af1ee890c749 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 19 Jan 2016 11:20:05 +0100 Subject: [PATCH] + add plugin hp vc (Fix #229) --- network/hp/vc/snmp/mode/components/domain.pm | 68 +++++++++++ .../hp/vc/snmp/mode/components/enclosure.pm | 68 +++++++++++ network/hp/vc/snmp/mode/components/enet.pm | 68 +++++++++++ network/hp/vc/snmp/mode/components/fc.pm | 68 +++++++++++ network/hp/vc/snmp/mode/components/module.pm | 68 +++++++++++ .../vc/snmp/mode/components/physicalserver.pm | 67 +++++++++++ network/hp/vc/snmp/mode/components/port.pm | 65 +++++++++++ network/hp/vc/snmp/mode/components/profile.pm | 68 +++++++++++ .../hp/vc/snmp/mode/components/resources.pm | 106 ++++++++++++++++++ network/hp/vc/snmp/mode/hardware.pm | 105 +++++++++++++++++ network/hp/vc/snmp/plugin.pm | 50 +++++++++ 11 files changed, 801 insertions(+) create mode 100644 network/hp/vc/snmp/mode/components/domain.pm create mode 100644 network/hp/vc/snmp/mode/components/enclosure.pm create mode 100644 network/hp/vc/snmp/mode/components/enet.pm create mode 100644 network/hp/vc/snmp/mode/components/fc.pm create mode 100644 network/hp/vc/snmp/mode/components/module.pm create mode 100644 network/hp/vc/snmp/mode/components/physicalserver.pm create mode 100644 network/hp/vc/snmp/mode/components/port.pm create mode 100644 network/hp/vc/snmp/mode/components/profile.pm create mode 100644 network/hp/vc/snmp/mode/components/resources.pm create mode 100644 network/hp/vc/snmp/mode/hardware.pm create mode 100644 network/hp/vc/snmp/plugin.pm diff --git a/network/hp/vc/snmp/mode/components/domain.pm b/network/hp/vc/snmp/mode/components/domain.pm new file mode 100644 index 000000000..4a20275a9 --- /dev/null +++ b/network/hp/vc/snmp/mode/components/domain.pm @@ -0,0 +1,68 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::domain; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcDomainName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.1.1' }, + vcDomainManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.1.2', map => $map_managed_status }, + vcDomainReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.1.10', map => $map_reason_code }, +}; +my $oid_vcDomain = '.1.3.6.1.4.1.11.5.7.5.2.1.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcDomain }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking domains"); + $self->{components}->{domain} = { name => 'domains', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'domain')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcDomain}})) { + next if ($oid !~ /^$mapping->{vcDomainManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcDomain}, instance => $instance); + + next if ($self->check_filter(section => 'domain', instance => $instance)); + $self->{components}->{domain}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("domain '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcDomainName}, $result->{vcDomainManagedStatus}, + $instance, $result->{vcDomainReasonCode} + )); + my $exit = $self->get_severity(section => 'domain', label => 'default', value => $result->{vcDomainManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Domain '%s' status is '%s'", + $result->{vcDomainName}, $result->{vcDomainManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/enclosure.pm b/network/hp/vc/snmp/mode/components/enclosure.pm new file mode 100644 index 000000000..d78508fc1 --- /dev/null +++ b/network/hp/vc/snmp/mode/components/enclosure.pm @@ -0,0 +1,68 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::enclosure; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcEnclosureName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1.2' }, + vcEnclosureManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1.3', map => $map_managed_status }, + vcEnclosureReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1.9', map => $map_reason_code }, +}; +my $oid_vcEnclosureEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.2.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcEnclosureEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking enclosures"); + $self->{components}->{enclosure} = { name => 'enclosures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'enclosure')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcEnclosureEntry}})) { + next if ($oid !~ /^$mapping->{vcEnclosureManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcEnclosureEntry}, instance => $instance); + + next if ($self->check_filter(section => 'enclosure', instance => $instance)); + $self->{components}->{enclosure}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("enclosure '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcEnclosureName}, $result->{vcEnclosureManagedStatus}, + $instance, $result->{vcEnclosureReasonCode} + )); + my $exit = $self->get_severity(section => 'enclosure', label => 'default', value => $result->{vcEnclosureManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Enclosure '%s' status is '%s'", + $result->{vcEnclosureName}, $result->{vcEnclosureManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/enet.pm b/network/hp/vc/snmp/mode/components/enet.pm new file mode 100644 index 000000000..c2646072e --- /dev/null +++ b/network/hp/vc/snmp/mode/components/enet.pm @@ -0,0 +1,68 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::enet; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcEnetNetworkName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1.2' }, + vcEnetNetworkManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1.3', map => $map_managed_status }, + vcEnetNetworkReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1.7', map => $map_reason_code }, +}; +my $oid_vcEnetNetworkEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.6.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcEnetNetworkEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking ethernet network"); + $self->{components}->{enet} = { name => 'enet', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'enet')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcEnetNetworkEntry}})) { + next if ($oid !~ /^$mapping->{vcEnetNetworkManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcEnetNetworkEntry}, instance => $instance); + + next if ($self->check_filter(section => 'enet', instance => $instance)); + $self->{components}->{enet}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("ethernet network '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcEnetNetworkName}, $result->{vcEnetNetworkManagedStatus}, + $instance, $result->{vcEnetNetworkReasonCode} + )); + my $exit = $self->get_severity(section => 'enet', label => 'default', value => $result->{vcEnetNetworkManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Ethernet network '%s' status is '%s'", + $result->{vcEnetNetworkName}, $result->{vcEnetNetworkManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/fc.pm b/network/hp/vc/snmp/mode/components/fc.pm new file mode 100644 index 000000000..990d13996 --- /dev/null +++ b/network/hp/vc/snmp/mode/components/fc.pm @@ -0,0 +1,68 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::fc; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcFcFabricName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1.2' }, + vcFcFabricManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1.3', map => $map_managed_status }, + vcFcFabricReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1.6', map => $map_reason_code }, +}; +my $oid_vcFcFabricEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.7.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcFcFabricEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fc"); + $self->{components}->{fc} = { name => 'fc', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fc')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcFcFabricEntry}})) { + next if ($oid !~ /^$mapping->{vcFcFabricManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcFcFabricEntry}, instance => $instance); + + next if ($self->check_filter(section => 'fc', instance => $instance)); + $self->{components}->{fc}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fc '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcFcFabricName}, $result->{vcFcFabricManagedStatus}, + $instance, $result->{vcFcFabricReasonCode} + )); + my $exit = $self->get_severity(section => 'fc', label => 'default', value => $result->{vcFcFabricManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fc '%s' status is '%s'", + $result->{vcFcFabricName}, $result->{vcFcFabricManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/module.pm b/network/hp/vc/snmp/mode/components/module.pm new file mode 100644 index 000000000..89654a38e --- /dev/null +++ b/network/hp/vc/snmp/mode/components/module.pm @@ -0,0 +1,68 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::module; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcModuleProductName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1.6' }, + vcModuleManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1.3', map => $map_managed_status }, + vcModuleReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1.15', map => $map_reason_code }, +}; +my $oid_vcModuleEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.3.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcModuleEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking modules"); + $self->{components}->{module} = { name => 'modules', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'module')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcModuleEntry}})) { + next if ($oid !~ /^$mapping->{vcModuleManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcModuleEntry}, instance => $instance); + + next if ($self->check_filter(section => 'module', instance => $instance)); + $self->{components}->{module}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("module '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcModuleProductName}, $result->{vcModuleManagedStatus}, + $instance, $result->{vcModuleReasonCode} + )); + my $exit = $self->get_severity(section => 'module', label => 'default', value => $result->{vcModuleManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Module '%s' status is '%s'", + $result->{vcModuleProductName}, $result->{vcModuleManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/physicalserver.pm b/network/hp/vc/snmp/mode/components/physicalserver.pm new file mode 100644 index 000000000..04912d30a --- /dev/null +++ b/network/hp/vc/snmp/mode/components/physicalserver.pm @@ -0,0 +1,67 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::physicalserver; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcPhysicalServerManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.5.1.1.3', map => $map_managed_status }, + vcPhysicalServerReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.5.1.1.10', map => $map_reason_code }, +}; +my $oid_vcPhysicalServerEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.5.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcPhysicalServerEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking physical servers"); + $self->{components}->{physicalserver} = { name => 'physical servers', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'physicalserver')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcPhysicalServerEntry}})) { + next if ($oid !~ /^$mapping->{vcPhysicalServerManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcPhysicalServerEntry}, instance => $instance); + + next if ($self->check_filter(section => 'physicalserver', instance => $instance)); + $self->{components}->{physicalserver}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("physical server '%s' status is '%s' [instance: %s, reason: %s].", + $instance, $result->{vcPhysicalServerManagedStatus}, + $instance, $result->{vcPhysicalServerReasonCode} + )); + my $exit = $self->get_severity(section => 'physicalserver', label => 'default', value => $result->{vcPhysicalServerManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Physical server '%s' status is '%s'", + $result->{vcModuleProductName}, $result->{vcPhysicalServerManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/port.pm b/network/hp/vc/snmp/mode/components/port.pm new file mode 100644 index 000000000..47a886e7b --- /dev/null +++ b/network/hp/vc/snmp/mode/components/port.pm @@ -0,0 +1,65 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::port; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcPortManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.4.1.1.3', map => $map_managed_status }, +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{vcPortManagedStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking ports"); + $self->{components}->{port} = { name => 'ports', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'port')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{vcPortManagedStatus}->{oid}}})) { + $oid =~ /^$mapping->{vcPortManagedStatus}->{oid}\.(.*)$/; + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{vcPortManagedStatus}->{oid}}, instance => $instance); + + next if ($self->check_filter(section => 'port', instance => $instance)); + $self->{components}->{port}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("port '%s' status is '%s' [instance: %s].", + $instance, $result->{vcPortManagedStatus}, + $instance + )); + my $exit = $self->get_severity(section => 'port', label => 'default', value => $result->{vcPortManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Port '%s' status is '%s'", + $instance, $result->{vcPortManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/profile.pm b/network/hp/vc/snmp/mode/components/profile.pm new file mode 100644 index 000000000..8322f2af5 --- /dev/null +++ b/network/hp/vc/snmp/mode/components/profile.pm @@ -0,0 +1,68 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::profile; + +use strict; +use warnings; +use network::hp::vc::snmp::mode::components::resources qw($map_managed_status $map_reason_code); + +my $mapping = { + vcProfileName => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1.2' }, + vcProfileManagedStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1.3', map => $map_managed_status }, + vcProfileReasonCode => { oid => '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1.8', map => $map_reason_code }, +}; +my $oid_vcProfileEntry = '.1.3.6.1.4.1.11.5.7.5.2.1.1.8.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_vcProfileEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking profiles"); + $self->{components}->{profile} = { name => 'profiles', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'profile')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcProfileEntry}})) { + next if ($oid !~ /^$mapping->{vcProfileManagedStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcProfileEntry}, instance => $instance); + + next if ($self->check_filter(section => 'profile', instance => $instance)); + $self->{components}->{profile}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("profile '%s' status is '%s' [instance: %s, reason: %s].", + $result->{vcProfileName}, $result->{vcProfileManagedStatus}, + $instance, $result->{vcProfileReasonCode} + )); + my $exit = $self->get_severity(section => 'profile', label => 'default', value => $result->{vcProfileManagedStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Profile '%s' status is '%s'", + $result->{vcProfileName}, $result->{vcProfileManagedStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/components/resources.pm b/network/hp/vc/snmp/mode/components/resources.pm new file mode 100644 index 000000000..5e54fb0ac --- /dev/null +++ b/network/hp/vc/snmp/mode/components/resources.pm @@ -0,0 +1,106 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_managed_status; +our $map_reason_code; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_managed_status $map_reason_code); + +$map_managed_status = { + 1 => 'unknown', + 2 => 'normal', + 3 => 'warning', + 4 => 'minor', + 5 => 'major', + 6 => 'critical', + 7 => 'disabled', + 8 => 'info', +}; + +$map_reason_code = { + 100 => 'vcNetworkOk', + 101 => 'vcNetworkUnknown', + 102 => 'vcNetworkDisabled', + 104 => 'vcNetworkAbnormal', + 105 => 'vcNetworkFailed', + 106 => 'vcNetworkDegraded', + 109 => 'vcNetworkNoPortsAssignedToPrivateNetwork', + 200 => 'vcFabricOk', + 202 => 'vcFabricNoPortsConfigured', + 203 => 'vcFabricSomePortsAbnormal', + 204 => 'vcFabricAllPortsAbnormal', + 205 => 'vcFabricWwnMismatch', + 206 => 'vcFabricUnknown', + 300 => 'vcProfileOk', + 301 => 'vcProfileServerAbnormal', + 304 => 'vcProfileAllConnectionsFailed', + 309 => 'vcProfileSomeConnectionsUnmapped', + 310 => 'vcProfileAllConnectionsAbnormal', + 311 => 'vcProfileSomeConnectionsAbnormal', + 312 => 'vcProfileUEFIBootmodeIncompatibleWithServer', + 313 => 'vcProfileUnknown', + 400 => 'vcEnetmoduleOk', + 401 => 'vcEnetmoduleEnclosureDown', + 402 => 'vcEnetmoduleModuleMissing', + 404 => 'vcEnetmodulePortprotect', + 405 => 'vcEnetmoduleIncompatible', + 406 => 'vcEnetmoduleHwDegraded', + 407 => 'vcEnetmoduleUnknown', + 408 => 'vcFcmoduleOk', + 409 => 'vcFcmoduleEnclosureDown', + 410 => 'vcFcmoduleModuleMissing', + 412 => 'vcFcmoduleHwDegraded', + 413 => 'vcFcmoduleIncompatible', + 414 => 'vcFcmoduleUnknown', + 500 => 'vcPhysicalServerOk', + 501 => 'vcPhysicalServerEnclosureDown', + 502 => 'vcPhysicalServerFailed', + 503 => 'vcPhysicalServerDegraded', + 504 => 'vcPhysicalServerUnknown', + 600 => 'vcEnclosureOk', + 601 => 'vcEnclosureAllEnetModulesFailed', + 602 => 'vcEnclosureSomeEnetModulesAbnormal', + 603 => 'vcEnclosureSomeModulesOrServersIncompatible', + 604 => 'vcEnclosureSomeFcModulesAbnormal', + 605 => 'vcEnclosureSomeServersAbnormal', + 606 => 'vcEnclosureUnknown', + 700 => 'vcDomainOk', + 701 => 'vcDomainAbnormalEnclosuresAndProfiles', + 702 => 'vcDomainSomeEnclosuresAbnormal', + 703 => 'vcDomainUnmappedProfileConnections', + 706 => 'vcDomainStackingFailed', + 707 => 'vcDomainStackingNotRedundant', + 709 => 'vcDomainSomeProfilesAbnormal', + 712 => 'vcDomainUnknown', + 713 => 'vcDomainOverProvisioned', + 801 => 'vcDomainSflowIndirectlyDisabled', + 802 => 'vcDomainSflowFailed', + 803 => 'vcDomainSflowDegraded', + 901 => 'vcDomainPortMonitorIndirectlyDisabled', +}; + +1; \ No newline at end of file diff --git a/network/hp/vc/snmp/mode/hardware.pm b/network/hp/vc/snmp/mode/hardware.pm new file mode 100644 index 000000000..8519b9375 --- /dev/null +++ b/network/hp/vc/snmp/mode/hardware.pm @@ -0,0 +1,105 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(domain|enclosure|module|port|physicalserver|enet|fc|profile)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['minor', 'WARNING'], + ['major', 'CRITICAL'], + ['critical', 'CRITICAL'], + ['disabled', 'OK'], + ['info', 'OK'], + ], + }; + + $self->{components_path} = 'network::hp::vc::snmp::mode::components'; + $self->{components_module} = ['domain', 'enclosure', 'module', 'port', 'physicalserver', 'enet', 'fc', 'profile']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'domain', 'enclosure', 'module', 'port', 'physicalserver', 'enet', 'fc', 'profile'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' + +=back + +=cut \ No newline at end of file diff --git a/network/hp/vc/snmp/plugin.pm b/network/hp/vc/snmp/plugin.pm new file mode 100644 index 000000000..cc0253480 --- /dev/null +++ b/network/hp/vc/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::hp::vc::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'hardware' => 'network::hp::vc::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check HP Virtual Connect in SNMP. + +=cut