+ Refactoring of cisco with a standard now
This commit is contained in:
parent
43e8244fdf
commit
26447fb930
|
@ -0,0 +1,137 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_fan_state1 = (
|
||||
1 => 'normal',
|
||||
2 => 'warning',
|
||||
3 => 'critical',
|
||||
4 => 'shutdown',
|
||||
5 => 'not present',
|
||||
6 => 'not functioning',
|
||||
);
|
||||
my %map_fan_state2 = (
|
||||
1 => 'unknown',
|
||||
2 => 'up',
|
||||
3 => 'down',
|
||||
4 => 'warning',
|
||||
);
|
||||
|
||||
my $oid_ciscoEnvMonFanStatusEntry = '.1.3.6.1.4.1.9.9.13.1.4.1'; # CISCO-ENVMON-MIB
|
||||
my $oid_cefcFanTrayOperStatus = '.1.3.6.1.4.1.9.9.117.1.4.1.1.1'; # CISCO-ENTITY-SENSOR-MIB
|
||||
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_ciscoEnvMonFanStatusEntry };
|
||||
push @{$options{request}}, { oid => $oid_cefcFanTrayOperStatus };
|
||||
}
|
||||
|
||||
sub check_fan_envmon {
|
||||
my ($self) = @_;
|
||||
|
||||
my $mapping = {
|
||||
ciscoEnvMonFanStatusDescr => { oid => '.1.3.6.1.4.1.9.9.13.1.4.1.2' },
|
||||
ciscoEnvMonFanState => { oid => '.1.3.6.1.4.1.9.9.13.1.4.1.3', map => \%map_fan_state1 },
|
||||
};
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ciscoEnvMonFanStatusEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{ciscoEnvMonFanStatusDescr}->{oid}\./);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonFanStatusEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_exclude(section => 'fan', instance => $instance));
|
||||
next if ($result->{ciscoEnvMonFanState} =~ /not present/i &&
|
||||
$self->absent_problem(section => 'fan', instance => $instance));
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [instance: %s].",
|
||||
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
|
||||
$instance
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'fan', value => $result->{ciscoEnvMonFanState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("fan '%s' status is %s",
|
||||
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_fan_entity {
|
||||
my ($self) = @_;
|
||||
|
||||
my $mapping = {
|
||||
cefcFanTrayOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.4.1.1.1', map => \%map_fan_state2 },
|
||||
};
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcFanTrayOperStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, instance => $instance);
|
||||
|
||||
next if ($self->check_exclude(section => 'fan', instance => $instance));
|
||||
|
||||
$self->{components}->{fan}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [instance: %s]",
|
||||
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'fan', value => $result->{cefcFanTrayOperStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' status is %s.", $fan_descr, $result->{cefcFanTrayOperStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'fan'));
|
||||
|
||||
check_fan_envmon($self);
|
||||
check_fan_entity($self);
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,110 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::components::module;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_module_state = (
|
||||
1 => 'unknown',
|
||||
2 => 'ok',
|
||||
3 => 'disabled',
|
||||
4 => 'okButDiagFailed',
|
||||
5 => 'boot',
|
||||
6 => 'selfTest',
|
||||
7 => 'failed',
|
||||
8 => 'missing',
|
||||
9 => 'mismatchWithParent',
|
||||
10 => 'mismatchConfig',
|
||||
11 => 'diagFailed',
|
||||
12 => 'dormant',
|
||||
13 => 'outOfServiceAdmin',
|
||||
14 => 'outOfServiceEnvTemp',
|
||||
15 => 'poweredDown',
|
||||
16 => 'poweredUp',
|
||||
17 => 'powerDenied',
|
||||
18 => 'powerCycled',
|
||||
19 => 'okButPowerOverWarning',
|
||||
20 => 'okButPowerOverCritical',
|
||||
21 => 'syncInProgress',
|
||||
22 => 'upgrading',
|
||||
23 => 'okButAuthFailed',
|
||||
24 => 'mdr',
|
||||
25 => 'fwMismatchFound',
|
||||
26 => 'fwDownloadSuccess',
|
||||
27 => 'fwDownloadFailure',
|
||||
);
|
||||
|
||||
# In MIB 'CISCO-ENTITY-SENSOR-MIB'
|
||||
my $mapping = {
|
||||
cefcModuleOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.2.1.1.2', map => \%map_module_state },
|
||||
};
|
||||
my $oid_cefcModuleOperStatus = '.1.3.6.1.4.1.9.9.117.1.2.1.1.2';
|
||||
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_cefcModuleOperStatus };
|
||||
}
|
||||
|
||||
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_exclude(section => 'module'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcModuleOperStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance);
|
||||
my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
|
||||
next if ($self->check_exclude(section => 'module', instance => $instance));
|
||||
|
||||
$self->{components}->{module}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]",
|
||||
$module_descr, $result->{cefcModuleOperStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'module', value => $result->{cefcModuleOperStatus});
|
||||
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", $module_descr, $result->{cefcModuleOperStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,87 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::components::physical;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_physical_state = (
|
||||
1 => 'other',
|
||||
2 => 'supported',
|
||||
3 => 'unsupported',
|
||||
4 => 'incompatible',
|
||||
);
|
||||
|
||||
# In MIB 'CISCO-ENTITY-SENSOR-MIB'
|
||||
my $mapping = {
|
||||
cefcPhysicalStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.5.1.1.1', map => \%map_physical_state },
|
||||
};
|
||||
my $oid_cefcPhysicalStatus = '.1.3.6.1.4.1.9.9.117.1.5.1.1.1';
|
||||
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_cefcPhysicalStatus };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking physicals");
|
||||
$self->{components}->{physical} = {name => 'physical', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'physical'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcPhysicalStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcPhysicalStatus}, instance => $instance);
|
||||
my $physical_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
|
||||
next if ($self->check_exclude(section => 'physical', instance => $instance));
|
||||
|
||||
$self->{components}->{physical}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]",
|
||||
$physical_descr, $result->{cefcPhysicalStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'physical', value => $result->{cefcPhysicalStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Physical '%s' status is %s", $physical_descr, $result->{cefcPhysicalStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,153 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_psu_source = (
|
||||
1 => 'unknown',
|
||||
2 => 'ac',
|
||||
3 => 'dc',
|
||||
4 => 'externalPowerSupply',
|
||||
5 => 'internalRedundant'
|
||||
);
|
||||
my %map_psu_state1 = (
|
||||
1 => 'normal',
|
||||
2 => 'warning',
|
||||
3 => 'critical',
|
||||
4 => 'shutdown',
|
||||
5 => 'not present',
|
||||
6 => 'not functioning',
|
||||
);
|
||||
my %map_psu_state2 = (
|
||||
1 => 'offEnvOther',
|
||||
2 => 'on',
|
||||
3 => 'offAdmin',
|
||||
4 => 'offDenied',
|
||||
5 => 'offEnvPower',
|
||||
6 => 'offEnvTemp',
|
||||
7 => 'offEnvFan',
|
||||
8 => 'failed',
|
||||
9 => 'onButFanFail',
|
||||
10 => 'offCooling',
|
||||
11 => 'offConnectorRating',
|
||||
12 => 'onButInlinePowerFail',
|
||||
);
|
||||
|
||||
my $oid_ciscoEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.9.9.13.1.5.1'; # CISCO-ENVMON-MIB
|
||||
my $oid_cefcFRUPowerOperStatus = '.1.3.6.1.4.1.9.9.117.1.1.2.1.2'; # CISCO-ENTITY-SENSOR-MIB
|
||||
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_ciscoEnvMonSupplyStatusEntry };
|
||||
push @{$options{request}}, { oid => $oid_cefcFRUPowerOperStatus };
|
||||
}
|
||||
|
||||
sub check_psu_envmon {
|
||||
my ($self) = @_;
|
||||
|
||||
my $mapping = {
|
||||
ciscoEnvMonSupplyStatusDescr => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.2' },
|
||||
ciscoEnvMonSupplyState => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.3', map => \%map_psu_state1 },
|
||||
ciscoEnvMonSupplySource => { oid => '.1.3.6.1.4.1.9.9.13.1.5.1.4', map => \%map_psu_source },
|
||||
};
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{ciscoEnvMonSupplyStatusDescr}->{oid}\./);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
next if ($result->{ciscoEnvMonSupplyState} =~ /not present/i &&
|
||||
$self->absent_problem(section => 'psu', instance => $instance));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]",
|
||||
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
|
||||
$instance, $result->{ciscoEnvMonSupplySource}
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'psu', value => $result->{ciscoEnvMonSupplyState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power supply '%s' status is %s",
|
||||
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_psu_entity {
|
||||
my ($self) = @_;
|
||||
|
||||
my $mapping = {
|
||||
cefcFRUPowerOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.1.2.1.2', map => \%map_psu_state2 },
|
||||
};
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcFRUPowerOperStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, instance => $instance);
|
||||
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
|
||||
$self->{components}->{psu}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]",
|
||||
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance));
|
||||
my $exit = $self->get_severity(section => 'psu', value => $result->{cefcFRUPowerOperStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power supply '%s' status is %s.", $psu_descr, $result->{cefcFRUPowerOperStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
|
||||
check_psu_envmon($self);
|
||||
check_psu_entity($self);
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,110 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::components::temperature;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_temperature_state = (
|
||||
1 => 'normal',
|
||||
2 => 'warning',
|
||||
3 => 'critical',
|
||||
4 => 'shutdown',
|
||||
5 => 'not present',
|
||||
6 => 'not functioning',
|
||||
);
|
||||
|
||||
# In MIB 'CISCO-ENVMON-MIB'
|
||||
my $mapping = {
|
||||
ciscoEnvMonTemperatureStatusDescr => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.2' },
|
||||
ciscoEnvMonTemperatureStatusValue => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.3' },
|
||||
ciscoEnvMonTemperatureThreshold => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.4' },
|
||||
ciscoEnvMonTemperatureState => { oid => '.1.3.6.1.4.1.9.9.13.1.3.1.6', map => \%map_temperature_state },
|
||||
};
|
||||
my $oid_ciscoEnvMonTemperatureStatusEntry = '.1.3.6.1.4.1.9.9.13.1.3.1';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_ciscoEnvMonTemperatureStatusEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'temperature'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{ciscoEnvMonTemperatureState}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_exclude(section => 'temperature', instance => $instance));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [instance: %s] [value: %s C]",
|
||||
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState},
|
||||
$instance, $result->{ciscoEnvMonTemperatureStatusValue}));
|
||||
my $exit = $self->get_severity(section => 'temperature', value => $result->{ciscoEnvMonTemperatureState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' status is %s",
|
||||
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}));
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureStatusValue});
|
||||
if ($checked == 0) {
|
||||
my $warn_th = undef;
|
||||
my $crit_th = '~:' . $result->{ciscoEnvMonTemperatureThreshold};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureStatusValue}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => "temp_" . $result->{ciscoEnvMonTemperatureStatusDescr}, unit => 'C',
|
||||
value => $result->{ciscoEnvMonTemperatureStatusValue},
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,111 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::components::voltage;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_voltage_state = (
|
||||
1 => 'normal',
|
||||
2 => 'warning',
|
||||
3 => 'critical',
|
||||
4 => 'shutdown',
|
||||
5 => 'not present',
|
||||
6 => 'not functioning',
|
||||
);
|
||||
|
||||
# In MIB 'CISCO-ENVMON-MIB'
|
||||
my $mapping = {
|
||||
ciscoEnvMonVoltageStatusDescr => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.2' },
|
||||
ciscoEnvMonVoltageStatusValue => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.3' },
|
||||
ciscoEnvMonVoltageThresholdLow => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.4' },
|
||||
ciscoEnvMonVoltageThresholdHigh => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.5' },
|
||||
ciscoEnvMonVoltageState => { oid => '.1.3.6.1.4.1.9.9.13.1.2.1.7', map => \%map_voltage_state },
|
||||
};
|
||||
my $oid_ciscoEnvMonVoltageStatusEntry = '.1.3.6.1.4.1.9.9.13.1.2.1';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_ciscoEnvMonVoltageStatusEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'voltage'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{ciscoEnvMonVoltageState}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_exclude(section => 'voltage', instance => $instance));
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]",
|
||||
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState},
|
||||
$instance, $result->{ciscoEnvMonVoltageStatusValue}));
|
||||
my $exit = $self->get_severity(section => 'voltage', value => $result->{ciscoEnvMonVoltageState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' status is %s",
|
||||
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState}));
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageStatusValue});
|
||||
if ($checked == 0) {
|
||||
my $warn_th = undef;
|
||||
my $crit_th = $result->{ciscoEnvMonVoltageThresholdLow} . ':' . $result->{ciscoEnvMonVoltageThresholdHigh};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th);
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Voltage '%s' is %s V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => "voltage_" . $result->{ciscoEnvMonVoltageStatusDescr}, unit => 'V',
|
||||
value => $result->{ciscoEnvMonVoltageStatusValue},
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::common::mode::cpu;
|
||||
package centreon::common::cisco::standard::snmp::mode::cpu;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -0,0 +1,378 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::environment;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_type_mon = (
|
||||
1 => 'oldAgs',
|
||||
2 => 'ags',
|
||||
3 => 'c7000',
|
||||
4 => 'ci',
|
||||
6 => 'cAccessMon',
|
||||
7 => 'cat6000',
|
||||
8 => 'ubr7200',
|
||||
9 => 'cat4000',
|
||||
10 => 'c10000',
|
||||
11 => 'osr7600',
|
||||
12 => 'c7600',
|
||||
13 => 'c37xx',
|
||||
14 => 'other'
|
||||
);
|
||||
|
||||
my $thresholds = {
|
||||
fan => [
|
||||
['unknown', 'UNKNOWN'],
|
||||
['down', 'CRITICAL'],
|
||||
['up', 'OK'],
|
||||
|
||||
['normal', 'OK'],
|
||||
['warning', 'WARNING'],
|
||||
['critical', 'CRITICAL'],
|
||||
['shutdown', 'CRITICAL'],
|
||||
['not present', 'OK'],
|
||||
['not functioning', 'WARNING'],
|
||||
],
|
||||
psu => [
|
||||
['^off*', 'WARNING'],
|
||||
['failed', 'CRITICAL'],
|
||||
['onButFanFail|onButInlinePowerFail', 'WARNING'],
|
||||
['on', 'OK'],
|
||||
|
||||
['normal', 'OK'],
|
||||
['warning', 'WARNING'],
|
||||
['critical', 'CRITICAL'],
|
||||
['shutdown', 'CRITICAL'],
|
||||
['not present', 'OK'],
|
||||
['not functioning', 'WARNING'],
|
||||
],
|
||||
temperature => [
|
||||
['normal', 'OK'],
|
||||
['warning', 'WARNING'],
|
||||
['critical', 'CRITICAL'],
|
||||
['shutdown', 'CRITICAL'],
|
||||
['not present', 'OK'],
|
||||
['not functioning', 'WARNING'],
|
||||
],
|
||||
voltage => [
|
||||
['normal', 'OK'],
|
||||
['warning', 'WARNING'],
|
||||
['critical', 'CRITICAL'],
|
||||
['shutdown', 'CRITICAL'],
|
||||
['not present', 'OK'],
|
||||
['not functioning', 'WARNING'],
|
||||
],
|
||||
module => [
|
||||
['unknown|mdr', 'UNKNOWN'],
|
||||
['disabled|okButDiagFailed|missing|mismatchWithParent|mismatchConfig|dormant|outOfServiceAdmin|outOfServiceEnvTemp|powerCycled|okButPowerOverWarning|okButAuthFailed|fwMismatchFound|fwDownloadFailure', 'WARNING'],
|
||||
['failed|diagFailed|poweredDown|powerDenied|okButPowerOverCritical', 'CRITICAL'],
|
||||
['boot|selfTest|poweredUp|syncInProgress|upgrading|fwDownloadSuccess|ok', 'OK'],
|
||||
],
|
||||
physical => [
|
||||
['other', 'UNKNOWN'],
|
||||
['incompatible|unsupported', 'CRITICAL'],
|
||||
['supported', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"absent-problem:s" => { name => 'absent' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ($1, $2, $3);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $regexp, $value) = ($1, $2, $3);
|
||||
if ($section !~ /(temperature|voltage)/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature or voltage).");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
|
||||
my $oid_ciscoEnvMonPresent = ".1.3.6.1.4.1.9.9.13.1.1";
|
||||
my $snmp_request = [ { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent } ];
|
||||
|
||||
my @components = ('fan', 'psu', 'temperature', 'voltage', 'module', 'physical');
|
||||
foreach (@components) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = "centreon::common::cisco::standard::snmp::mode::components::$_";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->(request => $snmp_request);
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(@{$snmp_request}) == 2) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Environment type: %s",
|
||||
defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ?
|
||||
$map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} : 'unknown'));
|
||||
|
||||
foreach (@components) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = "centreon::common::cisco::standard::snmp::mode::components::$_";
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self);
|
||||
}
|
||||
}
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub absent_problem {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{absent}) &&
|
||||
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Component '%s' instance '%s' is not present",
|
||||
$options{section}, $options{instance}));
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{regexp}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check environment (Power Supplies, Fans, Temperatures, Voltages, Modules, Physical Entities).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'fan', 'psu', 'temperature', 'voltage', 'module', 'physical'.
|
||||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=fan)
|
||||
Can also exclude specific instance: --exclude=fan#1#,psu#3#
|
||||
|
||||
=item B<--absent-problem>
|
||||
|
||||
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
|
||||
Can be specific or global: --absent-problem=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,status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='fan,CRITICAL,^(?!(up|normal)$)'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for temperatures, voltages (syntax: type,regexp,treshold)
|
||||
Example: --warning='temperature,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for temperatures, voltages (syntax: type,regexp,treshold)
|
||||
Example: --critical='temperature,.*,40'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -32,7 +32,8 @@
|
|||
# Authors : Simon Bomm <sbomm@centreon.com>
|
||||
#
|
||||
####################################################################################
|
||||
package network::cisco::common::mode::hsrp;
|
||||
|
||||
package centreon::common::cisco::standard::snmp::mode::hsrp;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::common::mode::ipsla;
|
||||
package centreon::common::cisco::standard::snmp::mode::ipsla;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::common::mode::memory;
|
||||
package centreon::common::cisco::standard::snmp::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::common::mode::stack;
|
||||
package centreon::common::cisco::standard::snmp::mode::stack;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::2800::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_snmp);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::common::mode::cpu',
|
||||
'environment' => 'network::cisco::common::mode::environment',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::common::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
'hsrp' => 'network::cisco::common::mode::hsrp',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco 2800 series in SNMP.
|
||||
|
||||
=cut
|
|
@ -1,71 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::2900::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_snmp);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::common::mode::cpu',
|
||||
'environment' => 'network::cisco::common::mode::environment',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::common::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
'stack' => 'network::cisco::common::mode::stack',
|
||||
'spanning-tree' => 'snmp_standard::mode::spanningtree',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco 2900 series in SNMP.
|
||||
|
||||
=cut
|
|
@ -1,72 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::3750::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_snmp);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::common::mode::cpu',
|
||||
'environment' => 'network::cisco::common::mode::environment',
|
||||
'ipsla' => 'network::cisco::common::mode::ipsla',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::common::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'spanning-tree' => 'snmp_standard::mode::spanningtree',
|
||||
'stack' => 'network::cisco::common::mode::stack',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco 3750 in SNMP.
|
||||
|
||||
=cut
|
|
@ -1,71 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::3850::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_snmp);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::common::mode::cpu',
|
||||
'environment' => 'network::cisco::common::mode::environment',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::common::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'spanning-tree' => 'snmp_standard::mode::spanningtree',
|
||||
'stack' => 'network::cisco::common::mode::stack',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco 3850 series in SNMP.
|
||||
|
||||
=cut
|
|
@ -47,13 +47,13 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::common::mode::cpu',
|
||||
'failover' => 'network::cisco::asa::mode::failover',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::common::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'sessions' => 'network::cisco::asa::mode::sessions',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
'cpu' => 'centreon::common::cisco::standard::snmp::mode::cpu',
|
||||
'failover' => 'network::cisco::asa::mode::failover',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'centreon::common::cisco::standard::snmp::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'sessions' => 'network::cisco::asa::mode::sessions',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
);
|
||||
|
||||
return $self;
|
||||
|
|
|
@ -1,416 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::common::mode::entity;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $oid_entPhysicalDescr = '.1.3.6.1.2.1.47.1.1.1.1.2';
|
||||
my $oid_cefcFanTrayOperStatus = '.1.3.6.1.4.1.9.9.117.1.4.1.1.1';
|
||||
my $oid_cefcPhysicalStatus = '.1.3.6.1.4.1.9.9.117.1.5.1.1.1';
|
||||
my $oid_cefcFRUPowerOperStatus = '.1.3.6.1.4.1.9.9.117.1.1.2.1.2';
|
||||
my $oid_cefcModuleOperStatus = '.1.3.6.1.4.1.9.9.117.1.2.1.1.2';
|
||||
|
||||
my $thresholds = {
|
||||
fan => [
|
||||
['unknown', 'UNKNOWN'],
|
||||
['down', 'CRITICAL'],
|
||||
['warning', 'WARNING'],
|
||||
['up', 'OK'],
|
||||
],
|
||||
psu => [
|
||||
['^off*', 'WARNING'],
|
||||
['failed', 'CRITICAL'],
|
||||
['onButFanFail|onButInlinePowerFail', 'WARNING'],
|
||||
['on', 'OK'],
|
||||
],
|
||||
module => [
|
||||
['unknown|mdr', 'UNKNOWN'],
|
||||
['disabled|okButDiagFailed|missing|mismatchWithParent|mismatchConfig|dormant|outOfServiceAdmin|outOfServiceEnvTemp|powerCycled|okButPowerOverWarning|okButAuthFailed|fwMismatchFound|fwDownloadFailure', 'WARNING'],
|
||||
['failed|diagFailed|poweredDown|powerDenied|okButPowerOverCritical', 'CRITICAL'],
|
||||
['boot|selfTest|poweredUp|syncInProgress|upgrading|fwDownloadSuccess|ok', 'OK'],
|
||||
],
|
||||
physical => [
|
||||
['other', 'UNKNOWN'],
|
||||
['incompatible|unsupported', 'CRITICAL'],
|
||||
['supported', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
my %map_states_fan = (
|
||||
1 => 'unknown',
|
||||
2 => 'up',
|
||||
3 => 'down',
|
||||
4 => 'warning',
|
||||
);
|
||||
|
||||
my %map_states_psu = (
|
||||
1 => 'offEnvOther',
|
||||
2 => 'on',
|
||||
3 => 'offAdmin',
|
||||
4 => 'offDenied',
|
||||
5 => 'offEnvPower',
|
||||
6 => 'offEnvTemp',
|
||||
7 => 'offEnvFan',
|
||||
8 => 'failed',
|
||||
9 => 'onButFanFail',
|
||||
10 => 'offCooling',
|
||||
11 => 'offConnectorRating',
|
||||
12 => 'onButInlinePowerFail',
|
||||
);
|
||||
|
||||
my %map_states_module = (
|
||||
1 => 'unknown',
|
||||
2 => 'ok',
|
||||
3 => 'disabled',
|
||||
4 => 'okButDiagFailed',
|
||||
5 => 'boot',
|
||||
6 => 'selfTest',
|
||||
7 => 'failed',
|
||||
8 => 'missing',
|
||||
9 => 'mismatchWithParent',
|
||||
10 => 'mismatchConfig',
|
||||
11 => 'diagFailed',
|
||||
12 => 'dormant',
|
||||
13 => 'outOfServiceAdmin',
|
||||
14 => 'outOfServiceEnvTemp',
|
||||
15 => 'poweredDown',
|
||||
16 => 'poweredUp',
|
||||
17 => 'powerDenied',
|
||||
18 => 'powerCycled',
|
||||
19 => 'okButPowerOverWarning',
|
||||
20 => 'okButPowerOverCritical',
|
||||
21 => 'syncInProgress',
|
||||
22 => 'upgrading',
|
||||
23 => 'okButAuthFailed',
|
||||
24 => 'mdr',
|
||||
25 => 'fwMismatchFound',
|
||||
26 => 'fwDownloadSuccess',
|
||||
27 => 'fwDownloadFailure',
|
||||
);
|
||||
|
||||
my %map_states_physical = (
|
||||
1 => 'other',
|
||||
2 => 'supported',
|
||||
3 => 'unsupported',
|
||||
4 => 'incompatible',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"component:s" => { name => 'component', default => 'all' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ($1, $2, $3);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_entPhysicalDescr },
|
||||
{ oid => $oid_cefcFanTrayOperStatus },
|
||||
{ oid => $oid_cefcPhysicalStatus },
|
||||
{ oid => $oid_cefcFRUPowerOperStatus },
|
||||
{ oid => $oid_cefcModuleOperStatus },
|
||||
]);
|
||||
|
||||
if ($self->{option_results}->{component} eq 'all') {
|
||||
$self->check_fan();
|
||||
$self->check_psu();
|
||||
$self->check_physical();
|
||||
$self->check_module();
|
||||
} elsif ($self->{option_results}->{component} eq 'module') {
|
||||
$self->check_module();
|
||||
} elsif ($self->{option_results}->{component} eq 'fan') {
|
||||
$self->check_fan();
|
||||
} elsif ($self->{option_results}->{component} eq 'psu') {
|
||||
$self->check_psu();
|
||||
} elsif ($self->{option_results}->{component} eq 'physical') {
|
||||
$self->check_physical();
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub check_fan {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'fan'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcFanTrayOperStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
my $fan_state = $self->{results}->{$oid_cefcFanTrayOperStatus}->{$oid};
|
||||
|
||||
next if ($self->check_exclude(section => 'fan', instance => $instance));
|
||||
|
||||
$self->{components}->{fan}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' state is %s.",
|
||||
$fan_descr, $map_states_fan{$fan_state}));
|
||||
my $exit = $self->get_severity(section => 'fan', value => $map_states_fan{$fan_state});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' state is %s.", $fan_descr, $map_states_fan{$fan_state}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_psu {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcFRUPowerOperStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
my $psu_state = $self->{results}->{$oid_cefcFRUPowerOperStatus}->{$oid};
|
||||
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
|
||||
$self->{components}->{psu}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' state is %s.",
|
||||
$psu_descr, $map_states_psu{$psu_state}));
|
||||
my $exit = $self->get_severity(section => 'psu', value => $map_states_psu{$psu_state});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power Supply '%s' state is %s.", $psu_descr, $map_states_psu{$psu_state}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_module {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking modules");
|
||||
$self->{components}->{module} = {name => 'modules', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'module'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcModuleOperStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
my $module_state = $self->{results}->{$oid_cefcModuleOperStatus}->{$oid};
|
||||
|
||||
next if ($self->check_exclude(section => 'module', instance => $instance));
|
||||
|
||||
$self->{components}->{module}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Module '%s' state is %s.",
|
||||
$module_descr, $map_states_module{$module_state}));
|
||||
my $exit = $self->get_severity(section => 'module', value => $map_states_module{$module_state});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Module '%s' state is %s.", $module_descr, $map_states_module{$module_state}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_physical {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking physicals");
|
||||
$self->{components}->{physical} = {name => 'physical', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'physical'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcPhysicalStatus}})) {
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $physical_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
|
||||
my $physical_state = $self->{results}->{$oid_cefcPhysicalStatus}->{$oid};
|
||||
|
||||
next if ($self->check_exclude(section => 'physical', instance => $instance));
|
||||
|
||||
$self->{components}->{physical}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Physical '%s' state is %s.",
|
||||
$physical_descr, $map_states_physical{$physical_state}));
|
||||
my $exit = $self->get_severity(section => 'physical', value => $map_states_physical{$physical_state});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Physical '%s' state is %s.", $physical_descr, $map_states_physical{$physical_state}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Environment monitor (CISCO-ENTITY-SENSOR-MIB) (Fans, Power Supplies, Modules, Physical Entities).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: 'all').
|
||||
Can be: 'module', 'physical', 'fan', 'psu'.
|
||||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=psu)
|
||||
Can also exclude specific instance: --exclude='psu#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,status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='psu,CRITICAL,^(?!(on)$)'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -1,299 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation ; either version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
||||
#
|
||||
# Linking this program statically or dynamically with other modules is making a
|
||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# permission to link this program with independent modules to produce an executable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::common::mode::environment;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_type_mon = (
|
||||
1 => 'oldAgs',
|
||||
2 => 'ags',
|
||||
3 => 'c7000',
|
||||
4 => 'ci',
|
||||
6 => 'cAccessMon',
|
||||
7 => 'cat6000',
|
||||
8 => 'ubr7200',
|
||||
9 => 'cat4000',
|
||||
10 => 'c10000',
|
||||
11 => 'osr7600',
|
||||
12 => 'c7600',
|
||||
13 => 'c37xx',
|
||||
14 => 'other'
|
||||
);
|
||||
my %states = (
|
||||
1 => ['normal', 'OK'],
|
||||
2 => ['warning', 'WARNING'],
|
||||
3 => ['critical', 'CRITICAL'],
|
||||
4 => ['shutdown', 'CRITICAL'],
|
||||
5 => ['not present', 'OK'],
|
||||
6 => ['not functioning', 'WARNING'],
|
||||
);
|
||||
my %map_psu_source = (
|
||||
1 => 'unknown',
|
||||
2 => 'ac',
|
||||
3 => 'dc',
|
||||
4 => 'externalPowerSupply',
|
||||
5 => 'internalRedundant'
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->{components_fans} = 0;
|
||||
$self->{components_psus} = 0;
|
||||
$self->{components_temperatures} = 0;
|
||||
$self->{components_voltages} = 0;
|
||||
|
||||
$self->get_type();
|
||||
$self->check_fans();
|
||||
$self->check_psus();
|
||||
$self->check_temperatures();
|
||||
$self->check_voltages();
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d components [%d fans, %d power supplies, %d temperatures, %d voltages] are ok, Environment type: %s",
|
||||
($self->{components_fans} + $self->{components_psus} + $self->{components_temperatures} + $self->{components_voltages}),
|
||||
$self->{components_fans}, $self->{components_psus}, $self->{components_temperatures}, $self->{components_voltages}, $self->{env_type}));
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub get_type {
|
||||
my ($self) = @_;
|
||||
|
||||
my $oid_ciscoEnvMonPresent = ".1.3.6.1.4.1.9.9.13.1.1.0";
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_ciscoEnvMonPresent]);
|
||||
|
||||
$self->{env_type} = defined($result->{$oid_ciscoEnvMonPresent}) ? $map_type_mon{$result->{$oid_ciscoEnvMonPresent}} : 'unknown';
|
||||
}
|
||||
|
||||
sub check_fans {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
return if ($self->check_exclude('fans'));
|
||||
|
||||
my $oid_ciscoEnvMonFanStatusEntry = '.1.3.6.1.4.1.9.9.13.1.4.1';
|
||||
my $oid_ciscoEnvMonFanStatusDescr = '.1.3.6.1.4.1.9.9.13.1.4.1.2';
|
||||
my $oid_ciscoEnvMonFanState = '.1.3.6.1.4.1.9.9.13.1.4.1.3';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_ciscoEnvMonFanStatusEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $oid (keys %$result) {
|
||||
next if ($oid !~ /^$oid_ciscoEnvMonFanStatusDescr/);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $fan_descr = $result->{$oid};
|
||||
my $fan_state = $result->{$oid_ciscoEnvMonFanState . '.' . $instance};
|
||||
|
||||
$self->{components_fans}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' state is %s.",
|
||||
$fan_descr, ${$states{$fan_state}}[0]));
|
||||
if (${$states{$fan_state}}[1] ne 'OK') {
|
||||
$self->{output}->output_add(severity => ${$states{$fan_state}}[1],
|
||||
short_msg => sprintf("Fan '%s' state is %s.", $fan_descr, ${$states{$fan_state}}[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_psus {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
return if ($self->check_exclude('psu'));
|
||||
|
||||
my $oid_ciscoEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.9.9.13.1.5.1';
|
||||
my $oid_ciscoEnvMonSupplyStatusDescr = '.1.3.6.1.4.1.9.9.13.1.5.1.2';
|
||||
my $oid_ciscoEnvMonSupplyState = '.1.3.6.1.4.1.9.9.13.1.5.1.3';
|
||||
my $oid_ciscoEnvMonSupplySource = '.1.3.6.1.4.1.9.9.13.1.5.1.4';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_ciscoEnvMonSupplyStatusEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $oid (keys %$result) {
|
||||
next if ($oid !~ /^$oid_ciscoEnvMonSupplyStatusDescr/);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $psu_descr = $result->{$oid};
|
||||
my $psu_state = $result->{$oid_ciscoEnvMonSupplyState . '.' . $instance};
|
||||
my $psu_source = $result->{$oid_ciscoEnvMonSupplySource . '.' . $instance};
|
||||
|
||||
$self->{components_psus}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' [type: %s] state is %s.",
|
||||
$psu_descr, $map_psu_source{$psu_source}, ${$states{$psu_state}}[0]));
|
||||
if (${$states{$psu_state}}[1] ne 'OK') {
|
||||
$self->{output}->output_add(severity => ${$states{$psu_state}}[1],
|
||||
short_msg => sprintf("Power Supply '%s' state is %s.", $psu_descr, ${$states{$psu_state}}[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_voltages {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
return if ($self->check_exclude('voltages'));
|
||||
|
||||
my $oid_ciscoEnvMonVoltageStatusEntry = '.1.3.6.1.4.1.9.9.13.1.2.1';
|
||||
my $oid_ciscoEnvMonVoltageStatusDescr = '.1.3.6.1.4.1.9.9.13.1.2.1.2';
|
||||
my $oid_ciscoEnvMonVoltageStatusValue = '.1.3.6.1.4.1.9.9.13.1.2.1.3';
|
||||
my $oid_ciscoEnvMonVoltageThresholdLow = '.1.3.6.1.4.1.9.9.13.1.2.1.4';
|
||||
my $oid_ciscoEnvMonVoltageThresholdHigh = '.1.3.6.1.4.1.9.9.13.1.2.1.5';
|
||||
my $oid_ciscoEnvMonVoltageState = '.1.3.6.1.4.1.9.9.13.1.2.1.7';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_ciscoEnvMonVoltageStatusEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $oid (keys %$result) {
|
||||
next if ($oid !~ /^$oid_ciscoEnvMonVoltageStatusDescr/);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $voltage_descr = $result->{$oid};
|
||||
my $voltage_state = $result->{$oid_ciscoEnvMonVoltageState . '.' . $instance};
|
||||
my $voltage_value = $result->{$oid_ciscoEnvMonVoltageStatusValue . '.' . $instance};
|
||||
my $voltage_low = $result->{$oid_ciscoEnvMonVoltageThresholdLow . '.' . $instance};
|
||||
my $voltage_high = $result->{$oid_ciscoEnvMonVoltageThresholdHigh . '.' . $instance};
|
||||
|
||||
$self->{components_voltages}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' state is %s.",
|
||||
$voltage_descr, ${$states{$voltage_state}}[0]));
|
||||
if (${$states{$voltage_state}}[1] ne 'OK') {
|
||||
$self->{output}->output_add(severity => ${$states{$voltage_state}}[1],
|
||||
short_msg => sprintf("Power Supply '%s' state is %s.", $voltage_descr, ${$states{$voltage_state}}[0]));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'voltage_' . $voltage_descr, unit => 'V',
|
||||
value => $voltage_value,
|
||||
critical => $voltage_low . ":" . $voltage_high);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_temperatures {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
return if ($self->check_exclude('temperatures'));
|
||||
|
||||
my $oid_ciscoEnvMonTemperatureStatusEntry = '.1.3.6.1.4.1.9.9.13.1.3.1';
|
||||
my $oid_ciscoEnvMonTemperatureStatusDescr = '.1.3.6.1.4.1.9.9.13.1.3.1.2';
|
||||
my $oid_ciscoEnvMonTemperatureStatusValue = '.1.3.6.1.4.1.9.9.13.1.3.1.3';
|
||||
my $oid_ciscoEnvMonTemperatureThreshold = '.1.3.6.1.4.1.9.9.13.1.3.1.4';
|
||||
my $oid_ciscoEnvMonTemperatureState = '.1.3.6.1.4.1.9.9.13.1.3.1.6';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_ciscoEnvMonTemperatureStatusEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $oid (keys %$result) {
|
||||
next if ($oid !~ /^$oid_ciscoEnvMonTemperatureStatusDescr/);
|
||||
$oid =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
|
||||
my $temp_descr = $result->{$oid};
|
||||
my $temp_state = $result->{$oid_ciscoEnvMonTemperatureState . '.' . $instance};
|
||||
my $temp_value = $result->{$oid_ciscoEnvMonTemperatureStatusValue . '.' . $instance};
|
||||
my $temp_threshold = $result->{$oid_ciscoEnvMonTemperatureThreshold . '.' . $instance};
|
||||
|
||||
$self->{components_temperatures}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' state is %s.",
|
||||
$temp_descr, ${$states{$temp_state}}[0]));
|
||||
if (${$states{$temp_state}}[1] ne 'OK') {
|
||||
$self->{output}->output_add(severity => ${$states{$temp_state}}[1],
|
||||
short_msg => sprintf("Temperature '%s' state is %s.", $temp_descr, ${$states{$temp_state}}[0]));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'temp_' . $temp_descr, unit => 'C',
|
||||
value => $temp_value,
|
||||
critical => "~:" . $temp_threshold);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, $section) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Environment monitor (CISCO-ENVMON-MIB) (Fans, Power Supplies, Temperatures, Voltages).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=temperatures,psu).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::cisco::nexus::5000::plugin;
|
||||
package network::cisco::standard::snmp::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -47,12 +47,15 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::common::mode::cpu',
|
||||
'environment' => 'network::cisco::common::mode::entity',
|
||||
'anycast' => 'snmp_standard::mode::anycast',
|
||||
'cpu' => 'centreon::common::cisco::standard::snmp::mode::cpu',
|
||||
'environment' => 'centreon::common::cisco::standard::snmp::mode::environment',
|
||||
'ipsla' => 'centreon::common::cisco::standard::snmp::mode::ipsla',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::common::mode::memory',
|
||||
'memory' => 'centreon::common::cisco::standard::snmp::mode::memory',
|
||||
'packet-errors' => 'snmp_standard::mode::packeterrors',
|
||||
'spanning-tree' => 'snmp_standard::mode::spanningtree',
|
||||
'stack' => 'centreon::common::cisco::standard::snmp::mode::stack',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
);
|
||||
|
||||
|
@ -65,6 +68,6 @@ __END__
|
|||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco Nexus 5000 in SNMP.
|
||||
Check Cisco equipments (2800, 2900, 3750, Nexus,...) in SNMP.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue