mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-24 06:05:17 +02:00
+ Add plugin for sun hardware through management cards
This commit is contained in:
parent
0fde14cdae
commit
63bc9f85cb
116
hardware/server/sun/mgmtcards/lib/telnet.pm
Normal file
116
hardware/server/sun/mgmtcards/lib/telnet.pm
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::lib::telnet;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Net::Telnet;
|
||||||
|
|
||||||
|
sub telnet_error {
|
||||||
|
my ($output, $msg) = @_;
|
||||||
|
|
||||||
|
$output->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => $msg);
|
||||||
|
$output->display();
|
||||||
|
$output->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub connect {
|
||||||
|
my (%options) = @_;
|
||||||
|
my $telnet_connection = new Net::Telnet(Timeout => $options{timeout});
|
||||||
|
|
||||||
|
$telnet_connection->open(Host => $options{hostname},
|
||||||
|
Port => $options{port},
|
||||||
|
Errmode => 'return') or telnet_error($options{output}, $telnet_connection->errmsg);
|
||||||
|
|
||||||
|
if (defined($options{closure})) {
|
||||||
|
&{$options{closure}}($telnet_connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (defined($options{username}) && $options{username} ne "") {
|
||||||
|
$telnet_connection->waitfor(Match => '/login: $/i', Errmode => "return") or telnet_error($options{output}, $telnet_connection->errmsg);
|
||||||
|
$telnet_connection->print($options{username});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($options{password}) && $options{password} ne "") {
|
||||||
|
$telnet_connection->waitfor(Match => '/password: $/i', Errmode => "return") or telnet_error($options{output}, $telnet_connection->errmsg);
|
||||||
|
$telnet_connection->print($options{password});
|
||||||
|
|
||||||
|
# Check if successful
|
||||||
|
my ($prematch, $match);
|
||||||
|
|
||||||
|
if (defined($options{special_wait})) {
|
||||||
|
($prematch, $match) = $telnet_connection->waitfor(Match => '/login[: ]*$/i',
|
||||||
|
Match => '/username[: ]*$/i',
|
||||||
|
Match => '/password[: ]*$/i',
|
||||||
|
Match => '/' . $options{special_wait} . '/i',
|
||||||
|
Match => $telnet_connection->prompt,
|
||||||
|
Errmode => "return") or
|
||||||
|
telnet_error($options{output}, $telnet_connection->errmsg);
|
||||||
|
} else {
|
||||||
|
($prematch, $match) = $telnet_connection->waitfor(Match => '/login[: ]*$/i',
|
||||||
|
Match => '/username[: ]*$/i',
|
||||||
|
Match => '/password[: ]*$/i',
|
||||||
|
Match => $telnet_connection->prompt,
|
||||||
|
Errmode => "return") or
|
||||||
|
telnet_error($options{output}, $telnet_connection->errmsg);
|
||||||
|
}
|
||||||
|
if ($match =~ /login[: ]*$/i or $match =~ /username[: ]*$/i or $match =~ /password[: ]*$/i) {
|
||||||
|
$options{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => 'Login failed: bad name or password');
|
||||||
|
$options{output}->display();
|
||||||
|
$options{output}->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sometimes need special characters
|
||||||
|
if (defined($options{noprompt})) {
|
||||||
|
return $telnet_connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(defined($options{password}) && $options{password} ne "")) {
|
||||||
|
$telnet_connection->waitfor(Match => $telnet_connection->prompt,
|
||||||
|
Errmode => "return") or telnet_error($options{output}, $telnet_connection->errmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $telnet_connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
207
hardware/server/sun/mgmtcards/mode/environmentsf2xx.pm
Normal file
207
hardware/server/sun/mgmtcards/mode/environmentsf2xx.pm
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::environmentsf2xx;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use hardware::server::sun::mgmtcards::lib::telnet;
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', default => 23 },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect(
|
||||||
|
username => $self->{option_results}->{username},
|
||||||
|
password => $self->{option_results}->{password},
|
||||||
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
port => $self->{option_results}->{port},
|
||||||
|
output => $self->{output});
|
||||||
|
my @lines = $telnet_handle->cmd("showenvironment");
|
||||||
|
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No problems detected.");
|
||||||
|
|
||||||
|
my ($output) = join("", @lines);
|
||||||
|
$output =~ s/\r//g;
|
||||||
|
my $long_msg = $output;
|
||||||
|
$long_msg =~ s/\|/~/mg;
|
||||||
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
|
||||||
|
if ($output =~ /^System LED Status:[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) {
|
||||||
|
#System LED Status: GENERAL ERROR POWER
|
||||||
|
# [OFF] [ ON]
|
||||||
|
|
||||||
|
my $genfault_status = $1;
|
||||||
|
$genfault_status = centreon::plugins::misc::trim($genfault_status);
|
||||||
|
if (defined($genfault_status) && $genfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Gen Fault status is '" . $genfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Disk LED Status:(.*?)=======/ims) {
|
||||||
|
#Disk LED Status: OK = GREEN ERROR = YELLOW
|
||||||
|
# DISK 1: [EMPTY]
|
||||||
|
# DISK 0: [OK]
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /DISK\s+([0-9]+)\s*:\s+\[([^\]]+?)\]/imsg)) {
|
||||||
|
my $disknum = $1;
|
||||||
|
my $disk_status = $2;
|
||||||
|
$disk_status = centreon::plugins::misc::trim($disk_status);
|
||||||
|
|
||||||
|
if (defined($disk_status) && $disk_status !~ /^(OK|EMPTY)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Disk $disknum status is '" . $disk_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Fan Bank :(.*?)=======/ims) {
|
||||||
|
#Fan Bank :
|
||||||
|
#----------
|
||||||
|
#
|
||||||
|
#Bank Speed Status
|
||||||
|
# (0-255)
|
||||||
|
#---- ----- ------
|
||||||
|
# SYS 255 OK
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /\n\s+([^\n]*?)(\s+[0-9]+\s+)(.*?)\n/imsg)) {
|
||||||
|
my $fan_name = $1;
|
||||||
|
my $fan_status = $3;
|
||||||
|
$fan_name = centreon::plugins::misc::trim($fan_name);
|
||||||
|
$fan_status = centreon::plugins::misc::trim($fan_status);
|
||||||
|
|
||||||
|
if (defined($fan_status) && $fan_status !~ /^(OK)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Fan Bank '" . $fan_name . "' status is '" . $fan_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Power Supplies(.*?)=======/ims) {
|
||||||
|
#Power Supplies:
|
||||||
|
#---------------
|
||||||
|
#
|
||||||
|
#Supply Status
|
||||||
|
#------ ------
|
||||||
|
# 1 OK: 560w
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /^\s*?([0-9]+)\s+(.*?)(\n|\s{2}|:)/imsg)) {
|
||||||
|
my $supplynum = $1;
|
||||||
|
my $supply_status = $2;
|
||||||
|
$supply_status = centreon::plugins::misc::trim($supply_status);
|
||||||
|
|
||||||
|
if (defined($supply_status) && $supply_status !~ /^(OK)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Supply '" . $supplynum . "' status is '" . $supply_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun 'sf280' Hardware (through RSC card).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
telnet port (Default: 23).
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
telnet username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
telnet password.
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
216
hardware/server/sun/mgmtcards/mode/environmentv4xx.pm
Normal file
216
hardware/server/sun/mgmtcards/mode/environmentv4xx.pm
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::environmentv4xx;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use hardware::server::sun::mgmtcards::lib::telnet;
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', default => 23 },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect(
|
||||||
|
username => $self->{option_results}->{username},
|
||||||
|
password => $self->{option_results}->{password},
|
||||||
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
port => $self->{option_results}->{port},
|
||||||
|
output => $self->{output});
|
||||||
|
my @lines = $telnet_handle->cmd("showenvironment");
|
||||||
|
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No problems detected.");
|
||||||
|
|
||||||
|
my ($output) = join("", @lines);
|
||||||
|
$output =~ s/\r//g;
|
||||||
|
my $long_msg = $output;
|
||||||
|
$long_msg =~ s/\|/~/mg;
|
||||||
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
|
||||||
|
if ($output =~ /^System LED Status:[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) {
|
||||||
|
#System LED Status: LOCATOR FAULT POWER
|
||||||
|
# [OFF] [OFF] [ ON]
|
||||||
|
|
||||||
|
my $genfault_status = $2;
|
||||||
|
$genfault_status = centreon::plugins::misc::trim($genfault_status);
|
||||||
|
|
||||||
|
if (defined($genfault_status) && $genfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Gen Fault status is '" . $genfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Disk LED Status:(.*?)=======/ims) {
|
||||||
|
#Disk LED Status: OK = GREEN ERROR = YELLOW
|
||||||
|
# DISK 1: [EMPTY]
|
||||||
|
# DISK 0: [OK]
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /DISK\s+([0-9]+)\s*:\s+\[([^\]]+?)\]/imsg)) {
|
||||||
|
my $disknum = $1;
|
||||||
|
my $disk_status = $2;
|
||||||
|
$disk_status = centreon::plugins::misc::trim($disk_status);
|
||||||
|
|
||||||
|
if (defined($disk_status) && $disk_status !~ /^(OK|EMPTY)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Disk $disknum status is '" . $disk_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Fan Tray :(.*?)=======/ims) {
|
||||||
|
#Fan Tray :
|
||||||
|
#----------
|
||||||
|
#
|
||||||
|
#Tray Speed Status
|
||||||
|
#---- ----- ------
|
||||||
|
#FAN TRAY0 CPU FAN0 5555 [OK]
|
||||||
|
#FAN TRAY0 CPU FAN1 4000 [OK]
|
||||||
|
#FAN TRAY0 CPU FAN2 3846 [OK]
|
||||||
|
#FAN TRAY1 IO FAN0 4000 [OK]
|
||||||
|
#FAN TRAY1 IO FAN1 4166 [OK]
|
||||||
|
#FAN TRAY1 IO FAN2 0 [UNKNOWN]
|
||||||
|
#
|
||||||
|
# Can be [FAILED], [OK], [UNKNOWN]
|
||||||
|
# If system is poweroff, nothing displayed.
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /\n([^\n]*?)(\s+[0-9]+\s+|\s+)\[(.*?)\]$/imsg)) {
|
||||||
|
my $fan_name = $1;
|
||||||
|
my $fan_status = $3;
|
||||||
|
$fan_name = centreon::plugins::misc::trim($fan_name);
|
||||||
|
$fan_status = centreon::plugins::misc::trim($fan_status);
|
||||||
|
|
||||||
|
if (defined($fan_status) && $fan_status !~ /^(OK)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Fan '" . $fan_name . "' status is '" . $fan_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Power Supplies(.*?)=======/ims) {
|
||||||
|
# Power Supplies:
|
||||||
|
#---------------
|
||||||
|
#
|
||||||
|
#Supply Status PS Fault Fan Fault Temp Fault
|
||||||
|
#------ ------------ -------- --------- ----------
|
||||||
|
# 0 OK OFF OFF OFF
|
||||||
|
# 1 OK OFF OFF OFF
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /^\s*?([0-9]+)\s+(.*?)(\n|\s{2})/imsg)) {
|
||||||
|
my $supplynum = $1;
|
||||||
|
my $supply_status = $2;
|
||||||
|
$supply_status = centreon::plugins::misc::trim($supply_status);
|
||||||
|
|
||||||
|
if (defined($supply_status) && $supply_status !~ /^(OK)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Supply '" . $supplynum . "' status is '" . $supply_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun 'v480' and 'v490' Hardware (through RSC card).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
telnet port (Default: 23).
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
telnet username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
telnet password.
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
252
hardware/server/sun/mgmtcards/mode/environmentv8xx.pm
Normal file
252
hardware/server/sun/mgmtcards/mode/environmentv8xx.pm
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::environmentv8xx;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use hardware::server::sun::mgmtcards::lib::telnet;
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', default => 23 },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect(
|
||||||
|
username => $self->{option_results}->{username},
|
||||||
|
password => $self->{option_results}->{password},
|
||||||
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
port => $self->{option_results}->{port},
|
||||||
|
output => $self->{output});
|
||||||
|
my @lines = $telnet_handle->cmd("showenvironment");
|
||||||
|
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No problems detected.");
|
||||||
|
|
||||||
|
my ($output) = join("", @lines);
|
||||||
|
$output =~ s/\r//g;
|
||||||
|
my $long_msg = $output;
|
||||||
|
$long_msg =~ s/\|/~/mg;
|
||||||
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
|
||||||
|
if ($output =~ /^\s+POWER\s+GEN FAULT[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) {
|
||||||
|
# POWER GEN FAULT
|
||||||
|
# [ ON] [OFF]
|
||||||
|
|
||||||
|
my $power_status = $1;
|
||||||
|
my $genfault_status = $2;
|
||||||
|
$genfault_status = centreon::plugins::misc::trim($genfault_status);
|
||||||
|
|
||||||
|
if (defined($genfault_status) && $genfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Gen Fault status is '" . $genfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^\s+REMOVE\s+DISK FAULT[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) {
|
||||||
|
# REMOVE DISK FAULT
|
||||||
|
# [OFF] [OFF]
|
||||||
|
|
||||||
|
my $remove_status = $1;
|
||||||
|
my $diskfault_status = $2;
|
||||||
|
$diskfault_status = centreon::plugins::misc::trim($diskfault_status);
|
||||||
|
|
||||||
|
if (defined($diskfault_status) && $diskfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Disk Fault status is '" . $diskfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^\s+POWER FAULT\s+LEFT THERMAL FAULT[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) {
|
||||||
|
# POWER FAULT LEFT THERMAL FAULT
|
||||||
|
# [OFF] [OFF]
|
||||||
|
|
||||||
|
my $powerfault_status = $1;
|
||||||
|
my $leftthermalfault_status = $2;
|
||||||
|
$powerfault_status = centreon::plugins::misc::trim($powerfault_status);
|
||||||
|
$leftthermalfault_status = centreon::plugins::misc::trim($leftthermalfault_status);
|
||||||
|
|
||||||
|
if (defined($powerfault_status) && $powerfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Power Fault status is '" . $powerfault_status . "'");
|
||||||
|
}
|
||||||
|
if (defined($leftthermalfault_status) && $leftthermalfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Left Thermal Fault status is '" . $leftthermalfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^\s+RIGHT THERMAL FAULT\s+LEFT DOOR[^\[]+?\[([^\]]+?)][^\[]+?\[([^\]]+?)]/ims && defined($1)) {
|
||||||
|
# RIGHT THERMAL FAULT LEFT DOOR
|
||||||
|
# [OFF] [OFF]
|
||||||
|
|
||||||
|
my $rightthermalfault_status = $1;
|
||||||
|
$rightthermalfault_status = centreon::plugins::misc::trim($rightthermalfault_status);
|
||||||
|
|
||||||
|
if (defined($rightthermalfault_status) && $rightthermalfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Right Thermal Fault status is '" . $rightthermalfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (($output =~ /^DISK\s+([0-9]+):\s+\[PRESENT\]\s+\[([^\]]+)\]/imsg)) {
|
||||||
|
# Presence Fault LED
|
||||||
|
# -------- ---------
|
||||||
|
#DISK 0: [PRESENT] [OFF]
|
||||||
|
#DISK 1: [EMPTY]
|
||||||
|
|
||||||
|
my $disknum = $1;
|
||||||
|
my $diskfault_status = $2;
|
||||||
|
$diskfault_status = centreon::plugins::misc::trim($diskfault_status);
|
||||||
|
|
||||||
|
if (defined($diskfault_status) && $diskfault_status !~ /^(OFF)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Disk $disknum status is '" . $diskfault_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Fan Bank(.*?)=======/ims) {
|
||||||
|
#Bank Presence ON State Status
|
||||||
|
#---- -------- -------- ------
|
||||||
|
#CPU0_PRIM_FAN [PRESENT] [ON] [OK]
|
||||||
|
#CPU1_PRIM_FAN [PRESENT] [ON] [OK]
|
||||||
|
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /^([^\s]+)\s+\[PRESENT\]\s+\[([^\]]+)\]\s+\[([^\]]+)\]/imsg)) {
|
||||||
|
my $fanbank_name = $1;
|
||||||
|
my $fanbank_status = $3;
|
||||||
|
$fanbank_status = centreon::plugins::misc::trim($fanbank_status);
|
||||||
|
|
||||||
|
if (defined($fanbank_status) && $fanbank_status !~ /^(OK)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Fan Bank '" . $fanbank_name . "' status is '" . $fanbank_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Power Supplies(.*?)=======/ims) {
|
||||||
|
#Power Supplies:
|
||||||
|
#---------------
|
||||||
|
#
|
||||||
|
#Supply Status Fan Fail Temp Fail CS Fail
|
||||||
|
#------ ------------ -------- --------- -------
|
||||||
|
#1 NO AC POWER
|
||||||
|
#2 OK
|
||||||
|
my $content = $1;
|
||||||
|
while (($content =~ /^\s*?([0-9]+)\s+(.*?)(\n|\s{2})/imsg)) {
|
||||||
|
my $supplynum = $1;
|
||||||
|
my $supply_status = $2;
|
||||||
|
$supply_status = centreon::plugins::misc::trim($supply_status);
|
||||||
|
|
||||||
|
if (defined($supply_status) && $supply_status !~ /^(OK)$/i) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Supply '" . $supplynum . "' status is '" . $supply_status . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun v890 and v880 Hardware (through RSC card).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
telnet port (Default: 23).
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
telnet username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
telnet password.
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
200
hardware/server/sun/mgmtcards/mode/showboards.pm
Normal file
200
hardware/server/sun/mgmtcards/mode/showboards.pm
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::showboards;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use hardware::server::sun::mgmtcards::lib::telnet;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', default => 23 },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"memory" => { name => 'memory' },
|
||||||
|
});
|
||||||
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub telnet_shell_plateform {
|
||||||
|
my ($telnet_handle) = @_;
|
||||||
|
|
||||||
|
# There are:
|
||||||
|
#System Controller 'sf6800':
|
||||||
|
# Type 0 for Platform Shell
|
||||||
|
# Type 1 for domain A console
|
||||||
|
# Type 2 for domain B console
|
||||||
|
# Type 3 for domain C console
|
||||||
|
# Type 4 for domain D console
|
||||||
|
# Input:
|
||||||
|
|
||||||
|
$telnet_handle->waitfor(Match => '/Input:/i', Errmode => "return") or telnet_error($telnet_handle->errmsg);
|
||||||
|
$telnet_handle->print("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect(
|
||||||
|
username => $self->{option_results}->{username},
|
||||||
|
password => $self->{option_results}->{password},
|
||||||
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
port => $self->{option_results}->{port},
|
||||||
|
output => $self->{output},
|
||||||
|
closure => \&telnet_shell_plateform);
|
||||||
|
my @lines = $telnet_handle->cmd("showboards");
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{statefile_cache}->read(statefile => 'cache_sun_mgmtcards_' . $self->{option_results}->{hostname} . '_' . $self->{mode});
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No new problems on system.");
|
||||||
|
} else {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No problems on system.");
|
||||||
|
}
|
||||||
|
|
||||||
|
my $datas = {};
|
||||||
|
foreach (@lines) {
|
||||||
|
chomp;
|
||||||
|
my $long_msg = $_;
|
||||||
|
$long_msg =~ s/\|/~/mg;
|
||||||
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
my $id;
|
||||||
|
if (/([^\s]+?)\s+/) {
|
||||||
|
$id = $1;
|
||||||
|
}
|
||||||
|
my $status;
|
||||||
|
if (/\s+(Degraded|Failed|Not tested|Passed|OK|Under Test)\s+/i) {
|
||||||
|
$status = $1;
|
||||||
|
}
|
||||||
|
if (!defined($status) || $status eq '') {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($status =~ /^(Degraded|Failed)$/i) {
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
my $old_status = $self->{statefile_cache}->get(name => "slot_$id");
|
||||||
|
if (!defined($old_status) || $old_status ne $status) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Slot '$id' status is '$status'");
|
||||||
|
}
|
||||||
|
$datas->{"slot_$id"} = $status;
|
||||||
|
} else {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Slot '$id' status is '$status'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{statefile_cache}->write(data => $datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun SFxxxx (sf6900, sf6800, sf3800,...) Hardware (through ScApp).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
telnet port (Default: 23).
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
telnet username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
telnet password.
|
||||||
|
|
||||||
|
=item B<--memory>
|
||||||
|
|
||||||
|
Returns new errors (retention file is used by the following option).
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
258
hardware/server/sun/mgmtcards/mode/showenvironment.pm
Normal file
258
hardware/server/sun/mgmtcards/mode/showenvironment.pm
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::showenvironment;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use hardware::server::sun::mgmtcards::lib::telnet;
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', default => 23 },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect(
|
||||||
|
username => $self->{option_results}->{username},
|
||||||
|
password => $self->{option_results}->{password},
|
||||||
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
port => $self->{option_results}->{port},
|
||||||
|
output => $self->{output});
|
||||||
|
my @lines = $telnet_handle->cmd("showenvironment");
|
||||||
|
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No problems detected.");
|
||||||
|
|
||||||
|
my ($output) = join("", @lines);
|
||||||
|
$output =~ s/\r//g;
|
||||||
|
my $long_msg = $output;
|
||||||
|
$long_msg =~ s/\|/~/mg;
|
||||||
|
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 ($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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($output =~ /^Front Status Panel.*?\n.*?\n(.*?)\n\n/ims && defined($1)) {
|
||||||
|
# Keyswitch position: NORMAL
|
||||||
|
$1 =~ /^[^:]+:\s+([^\s]+)$/;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ($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();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun vXXX (v240, v440, v245,...) Hardware (through ALOM).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
telnet port (Default: 23).
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
telnet username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
telnet password.
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
165
hardware/server/sun/mgmtcards/mode/showfaults.pm
Normal file
165
hardware/server/sun/mgmtcards/mode/showfaults.pm
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::showfaults;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"command-plink:s" => { name => 'command_plink', default => 'plink' },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
######
|
||||||
|
# Command execution
|
||||||
|
######
|
||||||
|
my $cmd = "echo 'showfaults' | " . $self->{option_results}->{command_plink} . " -T -l '" . $self->{option_results}->{username} . "' -batch -pw '" . $self->{option_results}->{password} . "' " . $self->{option_results}->{password} . " 2>&1";
|
||||||
|
my ($lerror, $stdout, $exit_code) = centreon::plugins::misc::backtick(
|
||||||
|
command => $cmd,
|
||||||
|
timeout => $self->{option_results}->{timeout},
|
||||||
|
wait_exit => 1
|
||||||
|
);
|
||||||
|
$stdout =~ s/\r//g;
|
||||||
|
if ($exit_code <= -1000) {
|
||||||
|
if ($exit_code == -1000) {
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => $stdout);
|
||||||
|
}
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
if ($exit_code != 0) {
|
||||||
|
$stdout =~ s/\n/ - /g;
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => "Command error: $stdout");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
######
|
||||||
|
# Command treatment
|
||||||
|
######
|
||||||
|
my ($otp1, $otp2) = split(/showfaults\n/, $stdout);
|
||||||
|
$self->{output}->output_add(long_msg => $otp2);
|
||||||
|
if ($otp2 !~ /ID.*?FRU.*?Fault/mi) {
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => "Command 'showfaults' problems (see additional info).");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No Problems on system.");
|
||||||
|
# Check showfaults
|
||||||
|
# Format:
|
||||||
|
# ID FRU Fault
|
||||||
|
# 1 /SYS SP detected fault: Input power unavailable for PSU at PS1
|
||||||
|
while ($otp2 =~ m/^\s+([0-9]+?)\s+([^\s]+?)\s+(.*)$/mg) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "[$1][$2] $3.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun 'T1xxx', 'T2xxx' ans 'T5xxx' Hardware (through ALOM4v).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
ssh username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
ssh password.
|
||||||
|
|
||||||
|
=item B<--command-plink>
|
||||||
|
|
||||||
|
Plink command (default: plink). Use to set a path.
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
226
hardware/server/sun/mgmtcards/mode/showfaulty.pm
Normal file
226
hardware/server/sun/mgmtcards/mode/showfaulty.pm
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::mode::showfaulty;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use centreon::plugins::statefile;
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"username:s" => { name => 'username' },
|
||||||
|
"password:s" => { name => 'password' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
|
"memory" => { name => 'memory' },
|
||||||
|
"command-plink:s" => { name => 'command_plink', default => 'plink' },
|
||||||
|
});
|
||||||
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{hostname})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{username})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a username.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (!defined($self->{option_results}->{password})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
######
|
||||||
|
# Command execution
|
||||||
|
######
|
||||||
|
my $cmd_in = 'show -o table -level all /SP/faultmgmt';
|
||||||
|
my $cmd = "echo '$cmd_in' | " . $self->{option_results}->{command_plink} . " -T -l '" . $self->{option_results}->{username} . "' -batch -pw '" . $self->{option_results}->{password} . "' " . $self->{option_results}->{hostname} . " 2>&1";
|
||||||
|
my ($lerror, $stdout, $exit_code) = centreon::plugins::misc::backtick(
|
||||||
|
command => $cmd,
|
||||||
|
timeout => $self->{option_results}->{timeout},
|
||||||
|
wait_exit => 1
|
||||||
|
);
|
||||||
|
$stdout =~ s/\r//g;
|
||||||
|
if ($exit_code <= -1000) {
|
||||||
|
if ($exit_code == -1000) {
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => $stdout);
|
||||||
|
}
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
if ($exit_code != 0) {
|
||||||
|
$stdout =~ s/\n/ - /g;
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => "Command error: $stdout");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
######
|
||||||
|
# Command treatment
|
||||||
|
######
|
||||||
|
my ($otp1, $otp2) = split(/\Q$cmd_in\E\n/, $stdout);
|
||||||
|
my $long_msg = $otp2;
|
||||||
|
$long_msg =~ s/\|/~/mg;
|
||||||
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
if ($otp2 !~ /Target.*?Property.*?Value/mi) {
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => "Command '$cmd_in' problems (see additional info).");
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{statefile_cache}->read(statefile => 'cache_sun_mgmtcards_' . $self->{option_results}->{hostname} . '_' . $self->{mode});
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No new problems on system.");
|
||||||
|
} else {
|
||||||
|
$self->{output}->output_add(severity => 'OK',
|
||||||
|
short_msg => "No problems on system.");
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check showfaults
|
||||||
|
# Format:
|
||||||
|
# Target | Property | Value
|
||||||
|
#--------------------+------------------------+---------------------------------
|
||||||
|
#/SP/faultmgmt/0 | fru | /SYS
|
||||||
|
#/SP/faultmgmt/0/ | timestamp | Sep 20 08:08:07
|
||||||
|
# faults/0 | |
|
||||||
|
#/SP/faultmgmt/0/ | sp_detected_fault | Input power unavailable for PSU
|
||||||
|
# faults/0 | | at PS1
|
||||||
|
|
||||||
|
my @lines = split(/\n/, $otp2);
|
||||||
|
my $num_lines = $#lines;
|
||||||
|
my $datas = {};
|
||||||
|
if ($num_lines > 3) {
|
||||||
|
my $severity;
|
||||||
|
|
||||||
|
while ($otp2 =~ m/\s+timestamp\s+\|\s+(.*?)\n\s+faults\/([0-9]+)/mg) {
|
||||||
|
my $timestamp = $1;
|
||||||
|
$timestamp = centreon::plugins::misc::trim($1);
|
||||||
|
my $num = $2;
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
my $old_timestamp = $self->{statefile_cache}->get(name => "fault_$num");
|
||||||
|
if (!defined($old_timestamp) || $old_timestamp ne $timestamp) {
|
||||||
|
$severity = 'CRITICAL';
|
||||||
|
}
|
||||||
|
$datas->{"fault_$num"} = $timestamp;
|
||||||
|
} else {
|
||||||
|
$severity = 'CRITICAL';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($severity)) {
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Some new errors on system (see additional info).");
|
||||||
|
} else {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => "Some errors on system (see additional info).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{memory})) {
|
||||||
|
$self->{statefile_cache}->write(data => $datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check Sun 'T3-x', 'T4-x' and 'T5xxx' Hardware (through ILOM).
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--username>
|
||||||
|
|
||||||
|
ssh username.
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
ssh password.
|
||||||
|
|
||||||
|
=item B<--memory>
|
||||||
|
|
||||||
|
Returns new errors (retention file is used by the following option).
|
||||||
|
|
||||||
|
=item B<--command-plink>
|
||||||
|
|
||||||
|
Plink command (default: plink). Use to set a path.
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Timeout in seconds for the command (Default: 30).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
77
hardware/server/sun/mgmtcards/plugin.pm
Normal file
77
hardware/server/sun/mgmtcards/plugin.pm
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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::mgmtcards::plugin;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use base qw(centreon::plugins::script_simple);
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
# $options->{options} = options object
|
||||||
|
|
||||||
|
$self->{version} = '0.1';
|
||||||
|
%{$self->{modes}} = (
|
||||||
|
'show-faulty' => 'hardware::server::sun::mgmtcards::mode::showfaulty',
|
||||||
|
'showfaults' => 'hardware::server::sun::mgmtcards::mode::showfaults',
|
||||||
|
'showboards' => 'hardware::server::sun::mgmtcards::mode::showboards',
|
||||||
|
'showenvironment' => 'hardware::server::sun::mgmtcards::mode::showenvironment',
|
||||||
|
'environment-v8xx' => 'hardware::server::sun::mgmtcards::mode::environmentv8xx',
|
||||||
|
'environment-v4xx' => 'hardware::server::sun::mgmtcards::mode::environmentv4xx',
|
||||||
|
'environment-sf2xx' => 'hardware::server::sun::mgmtcards::mode::environmentsf2xx',
|
||||||
|
);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
|
Check a variety of Sun Hardware through management cards:
|
||||||
|
- mode 'show-faulty': ILOM (T3-x, T4-x, T5xxx) (in ssh with 'plink' command) ;
|
||||||
|
- mode 'showfaults': ALOM4v (in T1xxx, T2xxx, T5xxx) (in ssh with 'plink' command) ;
|
||||||
|
- mode 'showboards': ScApp (SFxxxx - sf6900, sf6800, sf3800,...) (in telnet with Net::Telnet) ;
|
||||||
|
- mode 'showenvironment': ALOM (v240, v440, v245,...) (in telnet with Net::Telnet) ;
|
||||||
|
- mode 'environment-v8xx': RSC cards (v890, v880) (in telnet with Net::Telnet) ;
|
||||||
|
- mode 'environment-v4xx': RSC cards (v480, v490) (in telnet with Net::Telnet) ;
|
||||||
|
- mode 'environment-sf2xx': RSC cards (sf280) (in telnet with Net::Telnet).
|
||||||
|
|
||||||
|
=cut
|
Loading…
x
Reference in New Issue
Block a user