This commit is contained in:
Quentin Garnier 2014-08-07 16:52:03 +02:00
parent c28b5af080
commit 24899ba786
12 changed files with 844 additions and 168 deletions

View File

@ -0,0 +1,72 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::disk;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking disks");
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
return if ($self->check_exclude(section => 'disk'));
if ($self->{stdout} =~ /^System Disks.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Disk Status Service OK2RM
#--------------------------------------------
#HDD0 OK OFF OFF
#HDD1 NOT PRESENT OFF OFF
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $disk_status = defined($2) ? $2 : 'unknown';
my $disk_name = defined($1) ? $1 : 'unknown';
next if ($self->check_exclude(section => 'disk', instance => $disk_name));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(long_msg => "Disk Status '" . $disk_name . "' is " . $disk_status);
my $exit = $self->get_severity(section => 'disk', value => $disk_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "Disk Status '" . $disk_name . "' is " . $disk_status);
}
}
}
}
1;

View File

@ -0,0 +1,72 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::fan;
use strict;
use warnings;
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'));
if ($self->{stdout} =~ /^Fans.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status Speed Warn Low
#----------------------------------------------------------
#F0.RS OK 14062 -- 1000
#F1.RS OK 14062 -- 1000
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $fan_status = defined($2) ? $2 : 'unknown';
my $fan_name = defined($1) ? $1 : 'unknown';
next if ($self->check_exclude(section => 'fan', instance => $fan_name));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => "Fan Sensor Status '" . $fan_name . "' is " . $fan_status);
my $exit = $self->get_severity(section => 'fan', value => $fan_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "Fan Sensor Status '" . $fan_name . "' is " . $fan_status);
}
}
}
}
1;

View File

@ -0,0 +1,71 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::psu;
use strict;
use warnings;
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'));
if ($self->{stdout} =~ /^Power Supplies.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Supply Status Underspeed Overtemp Overvolt Undervolt Overcurrent
#------------------------------------------------------------------------------
#PS0 OK OFF OFF OFF OFF OFF
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)(\s{2}|$)/);
my $ps_status = defined($2) ? $2 : 'unknown';
my $ps_name = defined($1) ? $1 : 'unknown';
next if ($self->check_exclude(section => 'psu', instance => $ps_name));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => "Power Supplies Sensor Status '" . $ps_name . "' is " . $ps_status);
my $exit = $self->get_severity(section => 'psu', value => $ps_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "Power Supplies Sensor Status '" . $ps_name . "' is " . $ps_status);
}
}
}
}
1;

View File

@ -0,0 +1,78 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <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 hardware::server::sun::mgmt_cards::components::showenvironment::resources;
use strict;
use warnings;
use Exporter;
our $thresholds;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($thresholds);
$thresholds = {
temperature => [
['^(?!(OK)$)', 'CRITICAL'],
['^OK$', 'OK'],
],
si => [
['^(?!(OFF)$)', 'CRITICAL'],
['^OFF$', 'OK'],
],
disk => [
['^(?!(OK|NOT PRESENT)$)', 'CRITICAL'],
['^OK|NOT PRESENT$', 'OK'],
],
fan => [
['^(?!(OK)$)', 'CRITICAL'],
['^OK$', 'OK'],
],
voltage => [
['^(?!(OK)$)', 'CRITICAL'],
['^OK$', 'OK'],
],
psu => [
['^(?!(OK)$)', 'CRITICAL'],
['^OK$', 'OK'],
],
sensors => [
['^(?!(OK)$)', 'CRITICAL'],
['^OK$', 'OK'],
],
};
1;

View File

@ -0,0 +1,71 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::sensors;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking sensors");
$self->{components}->{sensors} = {name => 'sensors', total => 0, skip => 0};
return if ($self->check_exclude(section => 'sensors'));
if ($self->{stdout} =~ /^Current sensors.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status
#----------------------
#MB.FF_SCSI OK
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)(\s{2}|$)/);
my $sensor_status = defined($2) ? $2 : 'unknown';
my $sensor_name = defined($1) ? $1 : 'unknown';
next if ($self->check_exclude(section => 'sensors', instance => $sensor_name));
$self->{components}->{sensors}->{total}++;
$self->{output}->output_add(long_msg => "Current Sensor status '" . $sensor_name . "' is " . $sensor_status);
my $exit = $self->get_severity(section => 'sensors', value => $sensor_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "Current Sensor status '" . $sensor_name . "' is " . $sensor_status);
}
}
}
}
1;

View File

@ -0,0 +1,69 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::si;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking system indicator");
$self->{components}->{si} = {name => 'system indicator', total => 0, skip => 0};
return if ($self->check_exclude(section => 'si'));
if ($self->{stdout} =~ /^System Indicator Status.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#MB.LOCATE MB.SERVICE MB.ACT
#--------------------------------------------------------
#OFF OFF ON
if ($1 =~ /^([^\s]+)\s+([^\s].*?)\s{2}/) {
my $mbservice_status = defined($2) ? $2 : 'unknown';
next if ($self->check_exclude(section => 'si', instance => 'MB.SERVICE'));
$self->{components}->{si}->{total}++;
$self->{output}->output_add(long_msg => "System Indicator Status 'MB.SERVICE' is " . $mbservice_status);
my $exit = $self->get_severity(section => 'si', value => $mbservice_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "System Indicator Status 'MB.SERVICE' is " . $mbservice_status);
}
}
}
}
1;

View File

@ -0,0 +1,71 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::temperature;
use strict;
use warnings;
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'));
if ($self->{stdout} =~ /^System Temperatures.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status Temp LowHard LowSoft LowWarn HighWarn HighSoft HighHard
#--------------------------------------------------------------------------------
#MB.P0.T_CORE OK 62 -- -- -- 88 93 100
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $sensor_status = defined($2) ? $2 : 'unknown';
my $sensor_name = defined($1) ? $1 : 'unknown';
next if ($self->check_exclude(section => 'temperature', instance => $sensor_name));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => "System Temperature Sensor '" . $sensor_name . "' is " . $sensor_status);
my $exit = $self->get_severity(section => 'temperature', value => $sensor_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "System Temperature Sensor '" . $sensor_name . "' is " . $sensor_status);
}
}
}
}
1;

View File

@ -0,0 +1,72 @@
################################################################################
# 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 hardware::server::sun::mgmt_cards::components::showenvironment::voltage;
use strict;
use warnings;
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'));
if ($self->{stdout} =~ /^Voltage sensors.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status Voltage LowSoft LowWarn HighWarn HighSoft
#--------------------------------------------------------------------------------
#MB.P0.V_CORE OK 1.47 -- 1.26 1.54 --
#MB.P1.V_CORE OK 1.47 -- 1.26 1.54 --
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $voltage_status = defined($2) ? $2 : 'unknown';
my $voltage_name = defined($1) ? $1 : 'unknown';
next if ($self->check_exclude(section => 'voltage', instance => $voltage_name));
$self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => "Voltage Sensor status '" . $voltage_name . "' is " . $voltage_status);
my $exit = $self->get_severity(section => 'voltage', value => $voltage_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "Voltage Sensor status '" . $voltage_name . "' is " . $voltage_status);
}
}
}
}
1;

View File

@ -40,6 +40,15 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use hardware::server::sun::mgmt_cards::components::showenvironment::resources qw($thresholds);
use hardware::server::sun::mgmt_cards::components::showenvironment::psu;
use hardware::server::sun::mgmt_cards::components::showenvironment::fan;
use hardware::server::sun::mgmt_cards::components::showenvironment::temperature;
use hardware::server::sun::mgmt_cards::components::showenvironment::sensors;
use hardware::server::sun::mgmt_cards::components::showenvironment::voltage;
use hardware::server::sun::mgmt_cards::components::showenvironment::si;
use hardware::server::sun::mgmt_cards::components::showenvironment::disk;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -54,8 +63,14 @@ sub new {
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => 30 },
"command-plink:s" => { name => 'command_plink', default => 'plink' },
"ssh" => { name => 'ssh' },
"ssh" => { name => 'ssh' },
"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;
}
@ -79,6 +94,29 @@ sub check_options {
if (!defined($self->{option_results}->{ssh})) {
require hardware::server::sun::mgmt_cards::lib::telnet;
}
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 ssh_command {
@ -117,12 +155,46 @@ sub ssh_command {
return $stdout;
}
sub global {
my ($self, %options) = @_;
hardware::server::sun::mgmt_cards::components::showenvironment::psu::check($self);
hardware::server::sun::mgmt_cards::components::showenvironment::fan::check($self);
hardware::server::sun::mgmt_cards::components::showenvironment::temperature::check($self);
hardware::server::sun::mgmt_cards::components::showenvironment::sensors::check($self);
hardware::server::sun::mgmt_cards::components::showenvironment::voltage::check($self);
hardware::server::sun::mgmt_cards::components::showenvironment::si::check($self);
hardware::server::sun::mgmt_cards::components::showenvironment::disk::check($self);
}
sub component {
my ($self, %options) = @_;
if ($self->{option_results}->{component} eq 'si') {
hardware::server::sun::mgmt_cards::components::showenvironment::si::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::sun::mgmt_cards::components::showenvironment::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::sun::mgmt_cards::components::showenvironment::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::sun::mgmt_cards::components::showenvironment::temperature::check($self);
} elsif ($self->{option_results}->{component} eq 'sensors') {
hardware::server::sun::mgmt_cards::components::showenvironment::sensors::check($self);
} elsif ($self->{option_results}->{component} eq 'voltage') {
hardware::server::sun::mgmt_cards::components::showenvironment::voltage::check($self);
} elsif ($self->{option_results}->{component} eq 'disk') {
hardware::server::sun::mgmt_cards::components::showenvironment::disk::check($self);
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $output;
if (defined($self->{option_results}->{ssh})) {
$output = $self->ssh_command();
$self->{stdout} = $self->ssh_command();
} else {
my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect(
username => $self->{option_results}->{username},
@ -132,144 +204,81 @@ sub run {
timeout => $self->{option_results}->{timeout},
output => $self->{output});
my @lines = $telnet_handle->cmd("showenvironment");
$output = join("", @lines);
$self->{stdout} = join("", @lines);
}
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems detected.");
$self->{stdout} =~ s/\r//msg;
$output =~ s/\r//g;
my $long_msg = $output;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
if ($output =~ /^System Temperatures.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status Temp LowHard LowSoft LowWarn HighWarn HighSoft HighHard
#--------------------------------------------------------------------------------
#MB.P0.T_CORE OK 62 -- -- -- 88 93 100
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $sensor_status = defined($2) ? $2 : undef;
my $sensor_name = defined($1) ? $1 : undef;
if (defined($sensor_status) && $sensor_status !~ /^(OK)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "System Temperator Sensor '" . $sensor_name . "' is " . $sensor_status);
}
}
if ($self->{option_results}->{component} eq 'all') {
$self->global();
} else {
$self->component();
}
if ($output =~ /^System Indicator Status.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#MB.LOCATE MB.SERVICE MB.ACT
#--------------------------------------------------------
#OFF OFF ON
if ($1 =~ /^([^\s]+)\s+([^\s].*?)\s{2}/) {
my $mbservice_status = defined($2) ? $2 : undef;
if (defined($mbservice_status) && $mbservice_status !~ /^(OFF)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "System Indicator Status 'MB.SERVICE' is " . $mbservice_status);
}
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
# Not a problem. Only a protection.
#if ($output =~ /^Front Status Panel.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
# Keyswitch position: NORMAL
# if ($1 !~ /normal/i) {
# $self->{output}->output_add(severity => 'CRITICAL',
# short_msg => "Front Statut Panel is '" . $1 . "'");
# }
#}
if ($output =~ /^System Disks.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Disk Status Service OK2RM
#--------------------------------------------
#HDD0 OK OFF OFF
#HDD1 NOT PRESENT OFF OFF
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $disk_status = defined($2) ? $2 : undef;
my $disk_name = defined($1) ? $1 : undef;
if (defined($disk_status) && $disk_status !~ /^(OK|NOT PRESENT)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Disk Status '" . $disk_name . "' is " . $disk_status);
}
}
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components [%s] are ok.",
$total_components,
$display_by_component)
);
if ($output =~ /^Fans.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status Speed Warn Low
#----------------------------------------------------------
#F0.RS OK 14062 -- 1000
#F1.RS OK 14062 -- 1000
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $fan_status = defined($2) ? $2 : undef;
my $fan_name = defined($1) ? $1 : undef;
if (defined($fan_status) && $fan_status !~ /^(OK)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Fan Sensor Status '" . $fan_name . "' is " . $fan_status);
}
}
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
if ($output =~ /^Voltage sensors.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status Voltage LowSoft LowWarn HighWarn HighSoft
#--------------------------------------------------------------------------------
#MB.P0.V_CORE OK 1.47 -- 1.26 1.54 --
#MB.P1.V_CORE OK 1.47 -- 1.26 1.54 --
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)\s{2}/);
my $voltage_status = defined($2) ? $2 : undef;
my $voltage_name = defined($1) ? $1 : undef;
if (defined($voltage_status) && $voltage_status !~ /^(OK)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Voltage Sensor status '" . $voltage_name . "' is " . $voltage_status);
}
}
}
if ($output =~ /^Power Supplies.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Supply Status Underspeed Overtemp Overvolt Undervolt Overcurrent
#------------------------------------------------------------------------------
#PS0 OK OFF OFF OFF OFF OFF
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)(\s{2}|$)/);
my $ps_status = defined($2) ? $2 : undef;
my $ps_name = defined($1) ? $1 : undef;
if (defined($ps_status) && $ps_status !~ /^(OK)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Power Supplies Sensor Status '" . $ps_name . "' is " . $ps_status);
}
}
}
if ($output =~ /^Current sensors.*?\n.*?\n.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
#Sensor Status
#----------------------
#MB.FF_SCSI OK
foreach (split(/\n/, $1)) {
next if (! /^([^\s]+)\s+([^\s].*?)(\s{2}|$)/);
my $sensor_status = defined($2) ? $2 : undef;
my $sensor_name = defined($1) ? $1 : undef;
if (defined($sensor_status) && $sensor_status !~ /^(OK)$/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Current Sensor status '" . $sensor_name . "' is " . $sensor_status);
}
}
}
$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;
}
1;
__END__
@ -308,6 +317,27 @@ Plink command (default: plink). Use to set a path.
Use ssh (with plink) instead of telnet.
=item B<--component>
Which component to check (Default: 'all').
Can be: 'temperature', 'si', 'disk', 'fan', 'voltage', 'psu', 'sensors'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=fan)
Can also exclude specific instance: --exclude=fan#F1.RS#
=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,^(?!(OK|NOT PRESENT)$)'
=back
=cut

View File

@ -41,6 +41,12 @@ use strict;
use warnings;
use centreon::plugins::misc;
my $thresholds = [
['access denied', 'UNKNOWN'],
['(?!(No failures))', 'CRITICAL'],
['No failures', 'OK'],
];
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -54,6 +60,7 @@ sub new {
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => 30 },
"command-plink:s" => { name => 'command_plink', default => 'plink' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
return $self;
}
@ -74,6 +81,40 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
$self->{output}->option_exit();
}
$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 ($status, $filter) = ($1, $2);
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();
}
push @{$self->{overload_th}}, {filter => $filter, status => $status};
}
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'unknown'; # default
foreach (@{$self->{overload_th}}) {
if ($options{value} =~ /$_->{filter}/msi) {
$status = $_->{status};
return $status;
}
}
foreach (@{$thresholds}) {
if ($options{value} =~ /$$_[0]/msi) {
$status = $$_[1];
return $status;
}
}
return $status;
}
sub run {
@ -119,20 +160,17 @@ sub run {
short_msg => "Command '$stdout' problems (see additional info).");
$self->{output}->display();
$self->{output}->exit();
}
}
$self->{output}->output_add(long_msg => $long_msg);
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on system.");
# OK:
#No failures found in System Initialization.
if ($stdout !~ /No failures/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Some errors on system (see additional info).");
my $exit = $self->get_severity(value => $stdout);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => "Some errors on system (see additional info).");
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on system.");
}
$self->{output}->display();
$self->{output}->exit();
@ -168,6 +206,12 @@ Plink command (default: plink). Use to set a path.
Timeout in seconds for the command (Default: 30).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='UNKNOWN,access denied'
=back
=cut

View File

@ -146,6 +146,7 @@ sub new {
$options{options}->add_options(arguments =>
{
"with-sensors" => { name => 'with_sensors' },
"exclude:s@" => { name => 'exclude' },
});
return $self;
@ -156,6 +157,18 @@ sub check_options {
$self->SUPER::init(%options);
}
sub check_exclude {
my ($self, %options) = @_;
foreach (@{$self->{option_results}->{exclude}}) {
if ($options{value} =~ /$_/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{value}"));
return 1;
}
}
return 0;
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
@ -180,6 +193,8 @@ sub run {
# with '--'. there is 0x00 at the end str
my $component_part = centreon::plugins::misc::trim($oids_components_part_number->{$oid_scfComponentPartNumber . '.' . $board_type . '.' . $oid_end});
next if ($self->check_exclude(value => $components_board_types{$board_type} . '.' . $component_part));
if ($component_status != 1) {
$self->{output}->output_add(severity => ${$error_status{$component_status}}[1],
short_msg => sprintf(${$error_status{$component_status}}[0], $components_board_types{$board_type} . " (" . $component_part . ")"));
@ -221,6 +236,13 @@ Check Mseries hardware components.
Get sensors perfdatas.
=item B<--exclude>
Exclude some parts (multiple values) (Example: --exclude=TYPE.PART)
TYPE = board type ('cpum', 'mem', ...)
PART = name
(a regexp can be used)
=back
=cut

View File

@ -64,6 +64,7 @@ sub new {
"retention:s" => { name => 'retention' },
"timezone:s" => { name => 'timezone' },
"description" => { name => 'description' },
"filter-resource:s" => { name => 'filter_resource' },
});
$self->{result} = {};
return $self;
@ -84,7 +85,7 @@ sub manage_selection {
if (defined($self->{option_results}->{error_class})){
$extra_options .= ' -d '.$self->{option_results}->{error_class};
}
if (defined($self->{option_results}->{retention})){
if (defined($self->{option_results}->{retention}) && $self->{option_results}->{retention} ne ''){
my $retention = time() - $self->{option_results}->{retention};
if (defined($self->{option_results}->{timezone})){
$ENV{TZ} = $self->{option_results}->{timezone};
@ -128,49 +129,46 @@ sub manage_selection {
my ($identifier, $timestamp, $resource_name, $description) = ($1, $2, $5, $6);
$self->{result}->{$timestamp.'~'.$identifier.'~'.$resource_name} = {description => $description};
}
if (scalar(keys %{$self->{result}}) <= 0) {
if (defined($self->{option_results}->{retention})) {
$self->{output}->output_add(long_msg => sprintf("No error found with these options since %s seconds.", $self->{option_results}->{retention}));
$self->{output}->output_add(short_msg => sprintf("No error found since %s seconds.", $self->{option_results}->{retention}));
} else {
$self->{output}->output_add(long_msg => "No error found with these options.");
$self->{output}->output_add(short_msg => "No error found.");
}
$self->{output}->display();
$self->{output}->exit();
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection();
$self->{output}->output_add(severity => 'OK',
short_msg => 'No error found.');
$self->manage_selection();
if (defined($self->{option_results}->{retention})) {
$self->{output}->output_add(long_msg => sprintf("No error found with these options since %s seconds.", $self->{option_results}->{retention}));
$self->{output}->output_add(short_msg => sprintf("No error found since %s seconds.", $self->{option_results}->{retention}));
} else {
$self->{output}->output_add(long_msg => "No error found with these options.");
$self->{output}->output_add(short_msg => "No error found.");
}
my $total_error = 0;
foreach my $errpt_error (sort(keys %{$self->{result}})) {
my @split_error = split ('~',$errpt_error);
my $timestamp = $split_error[0];
my $identifier = $split_error[1];
my $resource_name = $split_error[2];
my $description = $self->{result}->{$errpt_error}->{description};
my $exit;
my $description = $self->{result}->{$errpt_error}->{description};
next if (defined($self->{option_results}->{filter_resource}) && $self->{option_results}->{filter_resource} ne '' &&
$resource_name !~ /$self->{option_results}->{filter_resource}/);
$total_error++;
if (defined($self->{option_results}->{description})) {
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier,
$timestamp, $resource_name, $description));
$self->{output}->output_add(severity => 'critical',
short_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier,
$timestamp, $resource_name, $description));
$timestamp, $resource_name, $description));
} else {
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s", $identifier,
$timestamp, $resource_name));
$self->{output}->output_add(severity => 'critical',
short_msg => sprintf("Error '%s' Date: %s ResourceName: %s", $identifier,
$timestamp, $resource_name));
}
}
if ($total_error != 0) {
$self->{output}->output_add(severity => 'critical',
short_msg => sprintf("%s error(s) found(s)", $total_error));
}
$self->{output}->display();
$self->{output}->exit();
}
@ -181,7 +179,7 @@ __END__
=head1 MODE
Check storage usages.
Check errpt messages.
=over 8
@ -234,10 +232,16 @@ Filter error class ('H' for hardware, 'S' for software, '0' for errlogger, 'U' f
Retention time of errors in seconds.
=item B<--retention>
=item B<--description>
Print error description in output.
=item B<--filter-resource>
Filter resource (can use a regexp).
Set
=back
=cut