Merge pull request #4 from centreon/master

Merge from master
This commit is contained in:
Sims24 2016-01-20 15:03:42 +01:00
commit 2132ae9e3f
25 changed files with 2127 additions and 141 deletions

View File

@ -79,29 +79,27 @@ sub run {
my ($self, %options) = @_;
# Global variables
my ($cert, $client);
eval { $client = IO::Socket::SSL->new(
my $client = IO::Socket::SSL->new(
PeerHost => $self->{option_results}->{hostname},
PeerPort => $self->{option_results}->{port},
$self->{option_results}->{servername} ? ( SSL_hostname => $self->{option_results}->{servername} ):(),
) };
if ($@) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf ("%s", $!));
$self->{output}->display();
$self->{output}->exit()
);
if (!defined($client)) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "failed to accept or ssl handshake: $!,$SSL_ERROR");
$self->{output}->display();
$self->{output}->exit()
}
#Retrieve Certificat
my $cert;
eval { $cert = $client->peer_certificate() };
if ($@) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s", $!));
$self->{output}->display();
$self->{output}->exit()
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s", $@));
$self->{output}->display();
$self->{output}->exit()
}
#Expiration Date

View File

@ -35,8 +35,11 @@ sub new {
{
"esx-hostname:s" => { name => 'esx_hostname' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"scope-datacenter:s" => { name => 'scope_datacenter' },
"scope-cluster:s" => { name => 'scope_cluster' },
"warning-time:s" => { name => 'warning_time' },
"critical-time:s" => { name => 'critical_time' },
});
return $self;
}
@ -44,6 +47,19 @@ sub new {
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach my $label (('warning_time', 'critical_time')) {
if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) {
my ($label_opt) = $label;
$label_opt =~ tr/_/-/;
$self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'.");
$self->{output}->option_exit();
}
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
@ -83,6 +99,17 @@ Search in following datacenter(s) (can be a regexp).
Search in following cluster(s) (can be a regexp).
=item B<--disconnect-status>
Status if VM disconnected (default: 'unknown').
=item B<--warning-time>
Threshold warning in seconds.
=item B<--critical-time>
Threshold critical in seconds.
=back

View File

@ -0,0 +1,75 @@
#
# 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 centreon::common::adic::tape::snmp::mode::components::global;
use strict;
use warnings;
my %map_status = (
1 => 'good',
2 => 'failed',
3 => 'degraded',
4 => 'warning',
5 => 'informational',
6 => 'unknown',
7 => 'invalid',
);
# In MIB 'ADIC-TAPE-LIBRARY-MIB'
my $mapping = {
libraryGlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{libraryGlobalStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking global");
$self->{components}->{global} = {name => 'global', total => 0, skip => 0};
return if ($self->check_filter(section => 'global'));
my $instance = '0';
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{libraryGlobalStatus}->{oid}}, instance => $instance);
if (!defined($result->{libraryGlobalStatus})) {
$self->{output}->output_add(long_msg => "skipping global status: no value.");
return ;
}
return if ($self->check_filter(section => 'global', instance => $instance));
$self->{components}->{global}->{total}++;
$self->{output}->output_add(long_msg => sprintf("library global status is %s [instance: %s].",
$result->{libraryGlobalStatus}, $instance
));
my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{libraryGlobalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Library global status is %s",
$result->{libraryGlobalStatus}));
}
}
1;

View File

@ -0,0 +1,80 @@
#
# 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 centreon::common::adic::tape::snmp::mode::components::physicaldrive;
use strict;
use warnings;
use centreon::plugins::misc;
my %map_status = (
1 => 'good',
2 => 'failed',
3 => 'degraded',
4 => 'warning',
5 => 'informational',
6 => 'unknown',
7 => 'invalid',
);
# In MIB 'ADIC-TAPE-LIBRARY-MIB'
my $mapping = {
phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' },
phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' },
phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status },
};
my $oid_physicalDriveEntry = '.1.3.6.1.4.1.3764.1.10.10.11.3.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_physicalDriveEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking physical drives");
$self->{components}->{physicaldrive} = {name => 'physical drives', total => 0, skip => 0};
return if ($self->check_filter(section => 'physicaldrive'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_physicalDriveEntry}})) {
next if ($oid !~ /^$mapping->{phDriveRasStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_physicalDriveEntry}, instance => $instance);
next if ($self->check_filter(section => 'physicaldrive', instance => $instance));
$self->{components}->{physicaldrive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].",
$instance, $result->{phDriveRasStatus},
$instance, centreon::plugins::misc::trim($result->{phDriveModel}),
centreon::plugins::misc::trim($result->{phDriveSerialNumber})
));
my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', value => $result->{phDriveRasStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical drive '%s' status is %s",
$instance, $result->{phDriveRasStatus}));
}
}
}
1;

View File

@ -0,0 +1,84 @@
#
# 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 centreon::common::adic::tape::snmp::mode::components::subsystem;
use strict;
use warnings;
my %map_status = (
1 => 'good',
2 => 'failed',
3 => 'degraded',
4 => 'warning',
5 => 'informational',
6 => 'unknown',
7 => 'invalid',
);
# In MIB 'ADIC-TAPE-LIBRARY-MIB'
my $mapping = {
powerStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.1', map => \%map_status, label => 'power', instance => 1 },
coolingStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.2', map => \%map_status, label => 'cooling', instance => 2 },
controlStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.3', map => \%map_status, label => 'control', instance => 3 },
connectivityStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.4', map => \%map_status, label => 'connectivity', instance => 4 },
roboticsStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.5', map => \%map_status, label => 'robotics', instance => 5 },
mediaStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.6', map => \%map_status, label => 'media', instance => 6 },
driveStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.12.6', map => \%map_status, label => 'drive', instance => 7 },
};
my $oid_rasSubSystem = '.1.3.6.1.4.1.3764.1.10.10.12';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_rasSubSystem };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking subsystems");
$self->{components}->{subsystem} = {name => 'subsystems', total => 0, skip => 0};
return if ($self->check_filter(section => 'subsystem'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rasSubSystem}, instance => '0');
foreach my $name (keys %$mapping) {
if (!defined($result->{$name})) {
$self->{output}->output_add(long_msg => sprintf("skipping %s status: no value.", $mapping->{$name}->{label}));
next;
}
next if ($self->check_filter(section => 'subsystem', instance => $mapping->{$name}->{instance}));
$self->{components}->{subsystem}->{total}++;
$self->{output}->output_add(long_msg => sprintf("%s status is %s [instance: %s].",
$mapping->{$name}->{label}, $result->{$name},
$mapping->{$name}->{instance}
));
my $exit = $self->get_severity(section => 'subsystem', label => 'default', value => $result->{$name});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s status is %s",
ucfirst($mapping->{$name}->{label}), $result->{$name}));
}
}
}
1;

View File

@ -0,0 +1,104 @@
#
# 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 centreon::common::adic::tape::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} = '^(global|physicaldrive|subsystem)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['good', 'OK'],
['failed', 'CRITICAL'],
['degraded', 'WARNING'],
['warning', 'WARNING'],
['informational', 'OK'],
['unknown', 'UNKNOWN'],
['invalid', 'CRITICAL'],
],
};
$self->{components_path} = 'centreon::common::adic::tape::snmp::mode::components';
$self->{components_module} = ['global', 'physicaldrive', 'subsystem'];
}
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: 'global', 'physicaldrive', 'subsystem'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=subsystem)
Can also exclude specific instance: --filter=physicaldrive,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='physicaldrive,OK,invalid'
=back
=cut

View File

@ -7,8 +7,16 @@ This document introduces the best practices in the development of "centreon-plug
As all plugins are written in Perl, “there is more than one way to do it”.
But to avoid reinventing the wheel, you should first take a look at the “example” directory, you will get an overview of how to build your own plugin and associated modes.
There are 3 chapters:
* :ref:`Quick Start <quick-start>`: Howto create file structure.
* :ref:`Libraries Reference <libraries_reference>`: API description.
* :ref:`Model Classes Usage <model_classes_usage>`: description of classes you should use for your plugin.
The lastest version is available on following git repository: http://git.centreon.com/centreon-plugins.git
.. _quick-start:
***********
Quick Start
***********
@ -218,7 +226,7 @@ For example, Warning and Critical thresholds must be validate in **check_options
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
@ -295,6 +303,8 @@ Once plugin and modes are developed, you can commit (commit messages in english)
git commit -m "Add new plugin for XXXX refs #<ticked_id>"
git push
.. _libraries_reference:
*******************
Libraries reference
*******************
@ -1468,40 +1478,25 @@ Then, edit **plugin.pm** and add the following lines:
.. code-block:: perl
################################################################################
# Copyright 2005-2015 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.
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# 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.
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
# 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
#
# 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.
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# 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.
#
# For more information : contact@centreon.com
# Authors : your name <your@mail>
#
####################################################################################
# Path to the plugin
package apps::pfsense::snmp::plugin;
@ -1573,40 +1568,25 @@ Edit **memorydroppedpackets.pm** and add the following lines:
.. code-block:: perl
################################################################################
# Copyright 2005-2015 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.
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# 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.
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
# 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
#
# 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.
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# 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.
#
# For more information : contact@centreon.com
# Authors : your name <your@mail>
#
####################################################################################
# Path to the plugin
package apps::pfsense::snmp::mode::memorydroppedpackets;
@ -1796,5 +1776,366 @@ Output may display:
OK: Dropped packets due to memory limitations : 0.00 /s | dropped_packets_Per_Sec=0.00;0;;1;2
.. _model_classes_usage:
*******************
Model Classes Usage
*******************
------------
Introduction
------------
With the experience of plugin development, we have created two classes:
* centreon::plugins::templates::counter
* centreon::plugins::templates::hardware
It was developed to have a more consistent code and less redundant code. According to context, you should use one of two classes for modes.
Following classes can be used for whatever plugin type (SNMP, Custom, DBI,...).
-------------
Class counter
-------------
When to use it ?
----------------
If you have some counters (CPU Usage, Memory, Session...), you should use that class.
If you have only one global counter to check, it's maybe not useful to use it (but only for these case).
Class methods
-------------
List of methods:
* **new**: class constructor. Overload if you need to add some specific options or to use a statefile.
* **check_options**: overload if you need to check your specific options.
* **manage_selection**: overload if *mandatory*. Method to get informations for the equipment.
* **set_counters**: overload if **mandatory**. Method to configure counters.
Examples
--------
Example 1
^^^^^^^^^
We want to develop the following SNMP plugin:
* measure the current sessions and current SSL sessions usages.
.. code-block:: perl
package my::module::name;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{global} = [
{ label => 'sessions', set => {
key_values => [ { name => 'sessions' } ],
output_template => 'Current sessions : %s',
perfdatas => [
{ label => 'sessions', value => 'sessions_absolute', template => '%s',
min => 0 },
],
}
},
{ label => 'sessions-ssl', set => {
key_values => [ { name => 'sessions_ssl' } ],
output_template => 'Current ssl sessions : %s',
perfdatas => [
{ label => 'sessions_ssl', value => 'sessions_ssl_absolute', template => '%s',
min => 0 },
],
}
},
];
}
sub manage_selection {
my ($self, %options) = @_;
# OIDs are fake. Only for the example.
my ($oid_sessions, $oid_sessions_ssl) = ('.1.2.3.4.0', '.1.2.3.5.0');
my $result = $options{snmp}->get_leef(oids => [ $oid_sessions, $oid_sessions_ssl ],
nothing_quit => 1);
$self->{global} = { sessions => $result->{$oid_sessions},
sessions_ssl => $result->{$oid_sessions_ssl}
};
}
Output may display:
::
OK: Current sessions : 24 - Current ssl sessions : 150 | sessions=24;;;0; sessions_ssl=150;;;0;
As you can see, we create two arrays of hash tables in **set_counters** method. We use arrays to order the output.
* **maps_counters_type**: global configuration. Attributes list:
* *name*: the name is really important. It will be used in hash **map_counters** and also in **manage_selection** as you can see.
* *type*: 0 or 1. With 0 value, the output will be written in the short output. With the value 1, it depends if we have one or multiple instances.
* *message_multiple*: only useful with *type* 1 value. The message will be displayed in short ouput if we have multiple instances selected.
* *message_separator*: the string displayed between counters (Default: ', ').
* *cb_prefix_output*, *cb_suffix_output*: name of a method (in a string) to callback. Methods will return a string to be displayed before or after **all** counters.
* *cb_init*: name of a method (in a string) to callback. Method will return 0 or 1. With 1 value, counters are not checked.
* **maps_counters**: complex structure to configure counters. Attributes list:
* *label*: name used for threshold options.
* *threshold*: if we set the value to 0. There is no threshold check options (can be used if you want to set and check option yourself).
* *set*: hash table:
* *keys_values*: array of hashes. Set values used for the counter. Order is important (by default, the first value is used to check).
* *name*: attribute name. Need to match with attributes in **manage_selection** method!
* *diff*: if we set the value to 1, we'll have the difference between two checks (need a statefile!).
* *output_template*: string to display. '%s' will be replaced by the first value of *keys_values*.
* *output_use*: which value to be used in *output_template* (If not set, we use the first value of *keys_values*).
* *per_second*: if we set the value to 1, the *diff* values will be calculated per seconds.
* *output_change_bytes*: if we set the value to 1 or 2, we can use a second '%s' in *output_template* to display the unit. 1 = divide by 1024 (Bytes), 2 = divide by 1000 (bits).
* *perfdata*: array of hashes. To configure perfdatas
* *label*: name displayed.
* *value*: value to used. It's the name from *keys_values* with a **suffix**: '_absolute' or '_per_second' (depends of other options).
* *template*: value format (could be for example: '%.3f').
* *unit*: unit displayed.
* *min*, *max*: min and max displayed. You can use a value from *keys_values*.
* *label_extra_instance*: if we set the value to 1, perhaps we'll have a suffix concat with *label*.
* *instance_use*: which value from *keys_values* to be used. To be used if *label_extra_instance* is 1.
Example 2
^^^^^^^^^
We want to add the current number of sessions by virtual servers.
.. code-block:: perl
package my::module::name;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'vs', type => 1, cb_prefix_output => 'prefix_vs_output', message_multiple => 'All Virtual servers are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total-sessions', set => {
key_values => [ { name => 'sessions' } ],
output_template => 'current sessions : %s',
perfdatas => [
{ label => 'total_sessions', value => 'sessions_absolute', template => '%s',
min => 0 },
],
}
},
{ label => 'total-sessions-ssl', set => {
key_values => [ { name => 'sessions_ssl' } ],
output_template => 'current ssl sessions : %s',
perfdatas => [
{ label => 'total_sessions_ssl', value => 'sessions_ssl_absolute', template => '%s',
min => 0 },
],
}
},
];
$self->{maps_counters}->{vs} = [
{ label => 'sessions', set => {
key_values => [ { name => 'sessions' }, { name => 'display' } ],
output_template => 'current sessions : %s',
perfdatas => [
{ label => 'sessions', value => 'sessions_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'sessions-ssl', set => {
key_values => [ { name => 'sessions_ssl' }, { name => 'display' } ],
output_template => 'current ssl sessions : %s',
perfdatas => [
{ label => 'sessions_ssl', value => 'sessions_ssl_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_vs_output {
my ($self, %options) = @_;
return "Virtual server '" . $options{instance_value}->{display} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Total ";
}
sub manage_selection {
my ($self, %options) = @_;
# OIDs are fake. Only for the example.
my ($oid_sessions, $oid_sessions_ssl) = ('.1.2.3.4.0', '.1.2.3.5.0');
my $result = $options{snmp}->get_leef(oids => [ $oid_sessions, $oid_sessions_ssl ],
nothing_quit => 1);
$self->{global} = { sessions => $result->{$oid_sessions},
sessions_ssl => $result->{$oid_sessions_ssl}
};
my $oid_table_vs = '.1.2.3.10';
my $mapping = {
vsName => { oid => '.1.2.3.10.1' },
vsSessions => { oid => '.1.2.3.10.2' },
vsSessionsSsl => { oid => '.1.2.3.10.3' },
};
$self->{vs} = {};
$result = $options{snmp}->get_table(oid => $oid_table_vs,
nothing_quit => 1);
foreach my $oid (keys %{$result->{ $oid_table_vs }}) {
next if ($oid !~ /^$mapping->{vsName}->{oid}\.(.*)$/;
my $instance = $1;
my $data = $options{snmp}->map_instance(mapping => $mapping, results => $result->{$oid_table_vs}, instance => $instance);
$self->{vs}->{$instance} = { display => $data->{vsName},
sessions => $data->{vsSessions}, sessions_ssl => $data->{vsSessionsSsl}};
}
}
If we have at least 2 virtual servers:
::
OK: Total current sessions : 24, current ssl sessions : 150 - All Virtual servers are ok | total_sessions=24;;;0; total_sessions_ssl=150;;;0; sessions_foo1=11;;;0; sessions_ssl_foo1=70;;;0; sessions_foo2=13;;;0; sessions_ssl_foo2=80;;;0;
Virtual server 'foo1' current sessions : 11, current ssl sessions : 70
Virtual server 'foo2' current sessions : 13, current ssl sessions : 80
Example 3
^^^^^^^^^
The model can also be used to check strings (not only counters). So we want to check the status of a virtualserver.
.. code-block:: perl
package my::module::name;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'vs', type => 1, cb_prefix_output => 'prefix_vs_output', message_multiple => 'All Virtual server status are ok' }
];
$self->{maps_counters}->{vs} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'),
}
},
];
}
sub custom_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
if ($self->{result_values}->{status} =~ /problem/) {
$status = 'critical';
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("status is '%s'", $self->{result_values}->{status});
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub prefix_vs_output {
my ($self, %options) = @_;
return "Virtual server '" . $options{instance_value}->{display} . "' ";
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
# Sometimes, you'll need to have access of the current object in the callback
$instance_mode = $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_table_vs = '.1.2.3.10';
my $mapping = {
vsName => { oid => '.1.2.3.10.1' },
vsStatus => { oid => '.1.2.3.10.4' },
};
$self->{vs} = {};
my $result = $options{snmp}->get_table(oid => $oid_table_vs,
nothing_quit => 1);
foreach my $oid (keys %{$result->{ $oid_table_vs }}) {
next if ($oid !~ /^$mapping->{vsName}->{oid}\.(.*)$/;
my $instance = $1;
my $data = $options{snmp}->map_instance(mapping => $mapping, results => $result->{$oid_table_vs}, instance => $instance);
$self->{vs}->{$instance} = { display => $data->{vsName},
status => $data->{vsStatus} };
}
}
The following example show 4 new attributes:
* *closure_custom_calc*: should be used to have a simple name (without '_absolute' or '_per_second'). Or to do some more complex calculation.
* *closure_custom_output*: should be used to have a more complex output (An example: want to display the total, free and used value at the same time).
* *closure_custom_perfdata*: should be used to manage yourself the perfdata.
* *closure_custom_threshold_check*: should be used to manage yourself the threshold check.
--------------
Class hardware
--------------
TODO

View File

@ -1468,40 +1468,25 @@ Ensuite, éditer le fichier **plugin.pm** et ajouter les lignes suivantes :
.. code-block:: perl
################################################################################
# Copyright 2005-2015 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.
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# 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.
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
# 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
#
# 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.
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# 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.
#
# For more information : contact@centreon.com
# Authors : your name <your@mail>
#
####################################################################################
# Chemin vers le plugin
package apps::pfsense::snmp::plugin;
@ -1573,40 +1558,25 @@ Editer le fichier **memorydroppedpackets.pm** et ajouter les lignes suivantes :
.. code-block:: perl
################################################################################
# Copyright 2005-2015 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.
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# 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.
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
# 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
#
# 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.
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# 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.
#
# For more information : contact@centreon.com
# Authors : your name <your@mail>
#
####################################################################################
# Chemin vers le mode
package apps::pfsense::snmp::mode::memorydroppedpackets;

View File

@ -0,0 +1,257 @@
#
# 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 hardware::ups::apc::snmp::mode::batterystatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
} elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' &&
eval "$instance_mode->{option_results}->{unknown_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("Battery status is '%s' [battery needs replace: %s]", $self->{result_values}->{status}, $self->{result_values}->{replace});
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_upsBasicBatteryStatus'};
$self->{result_values}->{replace} = $options{new_datas}->{$self->{instance} . '_upsAdvBatteryReplaceIndicator'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
];
$self->{maps_counters}->{global} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'upsBasicBatteryStatus' }, { name => 'upsAdvBatteryReplaceIndicator' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'),
}
},
{ label => 'load', set => {
key_values => [ { name => 'upsAdvBatteryCapacity' } ],
output_template => 'Remaining capacity : %s %%',
perfdatas => [
{ label => 'load', value => 'upsAdvBatteryCapacity_absolute', template => '%s',
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'time', set => {
key_values => [ { name => 'upsAdvBatteryRunTimeRemaining' } ],
output_template => 'Remaining time : %s minutes',
perfdatas => [
{ label => 'load_time', value => 'upsAdvBatteryRunTimeRemaining_absolute', template => '%s',
min => 0, unit => 'm' },
],
}
},
{ label => 'current', set => {
key_values => [ { name => 'upsAdvBatteryCurrent' } ],
output_template => 'Current : %s A',
perfdatas => [
{ label => 'current', value => 'upsAdvBatteryCurrent_absolute', template => '%s',
min => 0, unit => 'A' },
],
}
},
{ label => 'voltage', set => {
key_values => [ { name => 'upsAdvBatteryActualVoltage' } ],
output_template => 'Voltage : %s V',
perfdatas => [
{ label => 'voltage', value => 'upsAdvBatteryActualVoltage_absolute', template => '%s',
unit => 'V' },
],
}
},
{ label => 'temperature', set => {
key_values => [ { name => 'upsAdvBatteryTemperature' } ],
output_template => 'Temperature : %s C',
perfdatas => [
{ label => 'temperature', value => 'upsAdvBatteryTemperature_absolute', template => '%s',
unit => 'C'},
],
}
},
];
}
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 =>
{
"unknown-status:s" => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /batteryLow/i' },
"critical-status:s" => { name => 'critical_status', default => '%{replace} =~ /yes/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status', 'unknown_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_battery_status = (
1 => 'unknown',
2 => 'batteryNormal',
3 => 'batteryLow',
);
my %map_replace_status = (
1 => 'no',
2 => 'yes',
);
my $mapping = {
upsBasicBatteryStatus => { oid => '.1.3.6.1.4.1.318.1.1.1.2.1.1', map => \%map_battery_status },
upsBasicBatteryTimeOnBattery => { oid => '.1.3.6.1.4.1.318.1.1.1.2.1.2' },
};
my $mapping2 = {
upsAdvBatteryCapacity => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.1' },
upsAdvBatteryTemperature => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.2' },
upsAdvBatteryRunTimeRemaining => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.3' },
upsAdvBatteryReplaceIndicator => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.4', map => \%map_replace_status },
upsAdvBatteryActualVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.8' },
upsAdvBatteryCurrent => { oid => '.1.3.6.1.4.1.318.1.1.1.2.2.9' },
};
my $oid_upsBasicBattery = '.1.3.6.1.4.1.318.1.1.1.2.1';
my $oid_upsAdvBattery = '.1.3.6.1.4.1.318.1.1.1.2.2';
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = {};
$self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_upsBasicBattery },
{ oid => $oid_upsAdvBattery },
],
nothing_quit => 1);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_upsBasicBattery}, instance => '0');
my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_upsAdvBattery}, instance => '0');
foreach my $name (keys %{$mapping}) {
$self->{global}->{$name} = $result->{$name};
}
foreach my $name (keys %{$mapping2}) {
$self->{global}->{$name} = $result2->{$name};
}
}
1;
__END__
=head1 MODE
Check Battery Status and battery charge remaining.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^status|load$'
=item B<--unknown-status>
Set warning threshold for status (Default: '%{status} =~ /unknown/i').
Can used special variables like: %{status}, %{replace}
=item B<--warning-status>
Set warning threshold for status (Default: '%{status} =~ /batteryLow/i').
Can used special variables like: %{status}, %{replace}
=item B<--critical-status>
Set critical threshold for status (Default: '%{replace} =~ /yes/i').
Can used special variables like: %{status}, %{replace}
=item B<--warning-*>
Threshold warning.
Can be: 'load', 'voltage', 'current', 'temperature', 'time'.
=item B<--critical-*>
Threshold critical.
Can be: 'load', 'voltage', 'current', 'temperature', 'time'.
=back
=cut

View File

@ -1,6 +1,4 @@
#
# 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.
@ -18,7 +16,7 @@
# limitations under the License.
#
package hardware::pdu::apc::plugin;
package hardware::ups::apc::snmp::plugin;
use strict;
use warnings;
@ -32,11 +30,7 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'load' => 'hardware::pdu::apc::mode::load',
'psu' => 'hardware::pdu::apc::mode::psu',
'outlet' => 'hardware::pdu::apc::mode::outlet',
'temperature' => 'hardware::pdu::apc::mode::temperature',
'humidity' => 'hardware::pdu::apc::mode::humidity',
'battery-status' => 'hardware::ups::apc::snmp::mode::batterystatus',
);
return $self;
@ -48,6 +42,6 @@ __END__
=head1 PLUGIN DESCRIPTION
Check APC PDU in SNMP (PowerNet-MIB).
Check UPS APC through SNMP (POWERNET-MIB)
=cut

View File

@ -0,0 +1,98 @@
#
# 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::extreme::snmp::mode::components::poe;
use strict;
use warnings;
my %map_poe_status = (
1 => 'initializing',
2 => 'operational',
3 => 'downloadFail',
4 => 'calibrationRequired',
5 => 'invalidFirmware',
6 => 'mismatchVersion',
7 => 'updating',
8 => 'invalidDevice',
9 => 'notOperational',
10 => 'other',
);
my $mapping = {
extremePethSlotPoeStatus => { oid => '.1.3.6.1.4.1.1916.1.27.1.2.1.8', map => \%map_poe_status },
};
my $mapping2 = {
extremePethSlotMeasuredPower => { oid => '.1.3.6.1.4.1.1916.1.27.1.2.1.14' },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{extremePethSlotPoeStatus}->{oid} },
{ oid => $mapping2->{extremePethSlotMeasuredPower}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking poes");
$self->{components}->{poe} = {name => 'poes', total => 0, skip => 0};
return if ($self->check_filter(section => 'poe'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{extremePethSlotPoeStatus}->{oid}}})) {
$oid =~ /^$mapping->{extremePethSlotPoeStatus}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{extremePethSlotPoeStatus}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{extremePethSlotMeasuredPower}->{oid}}, instance => $instance);
next if ($self->check_filter(section => 'poe', instance => $instance));
$result2->{extremePethSlotMeasuredPower} = defined($result2->{extremePethSlotMeasuredPower}) && $result2->{extremePethSlotMeasuredPower} =~ /\d+/ ?
sprintf("%.3f", $result2->{extremePethSlotMeasuredPower} / 1000) : 'unknown';
$self->{components}->{poe}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Poe '%s' status is '%s' [instance = %s, power = %s]",
$instance, $result->{extremePethSlotPoeStatus},
$instance, $result2->{extremePethSlotMeasuredPower}));
$exit = $self->get_severity(section => 'poe', value => $result->{extremePethSlotPoeStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Poe '%s' status is '%s'", $instance, $result->{extremePethSlotPoeStatus}));
next;
}
next if ($result2->{extremePethSlotMeasuredPower} !~ /\d+/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'poe', instance => $instance, value => $result2->{extremePethSlotMeasuredPower});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Poe '%s' is '%s' W", $instance, $result2->{extremePethSlotMeasuredPower}));
}
$self->{output}->perfdata_add(label => 'poe_power_' . $instance, unit => 'W',
value => $result2->{extremePethSlotMeasuredPower},
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -28,8 +28,8 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|slot)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|psu\.power|psu\.fan)$';
$self->{regexp_threshold_overload_check_section_option} = '^(fan|psu|slot|poe)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan|poe|psu\.power|psu\.fan)$';
$self->{cb_hook2} = 'snmp_execute';
@ -61,10 +61,22 @@ sub set_system {
['initializing', 'OK'],
['invalid', 'CRITICAL'],
],
poe => [
['initializing', 'OK'],
['operational', 'OK'],
['downloadFail', 'CRITICAL'],
['calibrationRequired', 'CRITICAL'],
['invalidFirmware', 'CRITICAL'],
['mismatchVersion', 'CRITICAL'],
['updating', 'OK'],
['invalidDevice', 'CRITICAL'],
['notOperational', 'CRITICAL'],
['other', 'CRITICAL'],
],
};
$self->{components_path} = 'network::extreme::snmp::mode::components';
$self->{components_module} = ['fan', 'psu', 'slot', 'temperature'];
$self->{components_module} = ['fan', 'psu', 'slot', 'temperature', 'poe'];
}
sub snmp_execute {
@ -93,14 +105,14 @@ __END__
=head1 MODE
Check Hardware (Fans, Power Supplies, Slot, Temperature).
Check Hardware (Fans, Power Supplies, Slot, Temperature, POEs).
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'fan', 'psu', 'slot', 'temperature'.
Can be: 'fan', 'psu', 'slot', 'temperature', 'poe'.
=item B<--filter>

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,74 @@
#
# 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::moduleport;
use strict;
use warnings;
use network::hp::vc::snmp::mode::components::resources qw($map_moduleport_loop_status $map_moduleport_protection_status);
my $mapping = {
vcModulePortBpduLoopStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.3.1.1.6.1.3', map => $map_moduleport_loop_status },
vcModulePortProtectionStatus => { oid => '.1.3.6.1.4.1.11.5.7.5.2.3.1.1.6.1.4', map => $map_moduleport_protection_status },
};
my $oid_vcModulePortEntry = '.1.3.6.1.4.1.11.5.7.5.2.3.1.1.6.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_vcModulePortEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking module ports");
$self->{components}->{moduleport} = { name => 'module ports', total => 0, skip => 0 };
return if ($self->check_filter(section => 'moduleport'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vcModulePortEntry}})) {
next if ($oid !~ /^$mapping->{vcModulePortBpduLoopStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vcModulePortEntry}, instance => $instance);
next if ($self->check_filter(section => 'moduleport', instance => $instance));
$self->{components}->{moduleport}->{total}++;
$self->{output}->output_add(long_msg => sprintf("module port '%s' loop status is '%s' [instance: %s, protection status: %s].",
$instance, $result->{vcModulePortBpduLoopStatus},
$instance, $result->{vcModulePortProtectionStatus}
));
my $exit = $self->get_severity(section => 'moduleport.loop', value => $result->{vcModulePortBpduLoopStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module port '%s' loop status is '%s'",
$instance, $result->{vcModulePortBpduLoopStatus}));
}
$exit = $self->get_severity(section => 'moduleport.protection', value => $result->{vcModulePortProtectionStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module port '%s' protection status is '%s'",
$instance, $result->{vcModulePortProtectionStatus}));
}
}
}
1;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,119 @@
#
# 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 $map_moduleport_loop_status;
our $map_moduleport_protection_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($map_managed_status $map_reason_code $map_moduleport_loop_status $map_moduleport_protection_status);
$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',
};
$map_moduleport_protection_status = {
1 => 'ok',
2 => 'pause-flood-detected',
3 => 'in-pause-condition',
};
$map_moduleport_loop_status = {
1 => 'ok',
2 => 'loop-dectected',
};
1;

View File

@ -0,0 +1,114 @@
#
# 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|moduleport|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'],
],
'moduleport.loop' => [
['ok', 'OK'],
['loop-detected', 'CRITICAL'],
],
'moduleport.protection' => [
['ok', 'OK'],
['pause-flood-detected', 'CRITICAL'],
['in-pause-condition', 'WARNING'],
],
};
$self->{components_path} = 'network::hp::vc::snmp::mode::components';
$self->{components_module} = ['domain', 'enclosure', 'module', 'moduleport', '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', 'moduleport', 'port', 'physicalserver', 'enet', 'fc', 'profile'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=enet --filter=fc)
Can also exclude specific instance: --filter=fc,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='module,CRITICAL,^(?!(normal)$)'
=back
=cut

View File

@ -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

View File

@ -0,0 +1,49 @@
#
# 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 storage::dell::ml6000::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;
# $options->{options} = options object
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'centreon::common::adic::tape::snmp::mode::hardware',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Dell ML6000 in SNMP.
=cut