diff --git a/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm b/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm index d17ed692b..4a40d5d9a 100644 --- a/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm +++ b/hardware/server/sun/mgmt_cards/mode/environmentsf2xx.pm @@ -40,7 +40,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; -use hardware::server::sun::mgmtcards::lib::telnet; +use hardware::server::sun::mgmt_cards::lib::telnet; sub new { my ($class, %options) = @_; @@ -80,11 +80,12 @@ sub check_options { sub run { my ($self, %options) = @_; - my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect( + my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect( username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, hostname => $self->{option_results}->{hostname}, port => $self->{option_results}->{port}, + timeout => $self->{option_results}->{timeout}, output => $self->{output}); my @lines = $telnet_handle->cmd("showenvironment"); diff --git a/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm b/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm index 97c7b6a83..a291646cb 100644 --- a/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm +++ b/hardware/server/sun/mgmt_cards/mode/environmentv4xx.pm @@ -40,7 +40,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; -use hardware::server::sun::mgmtcards::lib::telnet; +use hardware::server::sun::mgmt_cards::lib::telnet; sub new { my ($class, %options) = @_; @@ -80,11 +80,12 @@ sub check_options { sub run { my ($self, %options) = @_; - my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect( + my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect( username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, hostname => $self->{option_results}->{hostname}, port => $self->{option_results}->{port}, + timeout => $self->{option_results}->{timeout}, output => $self->{output}); my @lines = $telnet_handle->cmd("showenvironment"); diff --git a/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm b/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm index fefdf6ad5..bc64c1784 100644 --- a/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm +++ b/hardware/server/sun/mgmt_cards/mode/environmentv8xx.pm @@ -40,7 +40,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; -use hardware::server::sun::mgmtcards::lib::telnet; +use hardware::server::sun::mgmt_cards::lib::telnet; sub new { my ($class, %options) = @_; @@ -80,11 +80,12 @@ sub check_options { sub run { my ($self, %options) = @_; - my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect( + my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect( username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, hostname => $self->{option_results}->{hostname}, port => $self->{option_results}->{port}, + timeout => $self->{option_results}->{timeout}, output => $self->{output}); my @lines = $telnet_handle->cmd("showenvironment"); diff --git a/hardware/server/sun/mgmt_cards/mode/showboards.pm b/hardware/server/sun/mgmt_cards/mode/showboards.pm index 72a8ab9e1..d50fc9f94 100644 --- a/hardware/server/sun/mgmt_cards/mode/showboards.pm +++ b/hardware/server/sun/mgmt_cards/mode/showboards.pm @@ -39,7 +39,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use hardware::server::sun::mgmtcards::lib::telnet; +use hardware::server::sun::mgmt_cards::lib::telnet; use centreon::plugins::statefile; sub new { @@ -102,11 +102,12 @@ sub telnet_shell_plateform { sub run { my ($self, %options) = @_; - my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect( + my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect( username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, hostname => $self->{option_results}->{hostname}, port => $self->{option_results}->{port}, + timeout => $self->{option_results}->{timeout}, output => $self->{output}, closure => \&telnet_shell_plateform); my @lines = $telnet_handle->cmd("showboards"); diff --git a/hardware/server/sun/mgmt_cards/mode/showenvironment.pm b/hardware/server/sun/mgmt_cards/mode/showenvironment.pm index c4a0fa9d9..403b358a3 100644 --- a/hardware/server/sun/mgmt_cards/mode/showenvironment.pm +++ b/hardware/server/sun/mgmt_cards/mode/showenvironment.pm @@ -39,7 +39,7 @@ use base qw(centreon::plugins::mode); use strict; use warnings; -use hardware::server::sun::mgmtcards::lib::telnet; +use hardware::server::sun::mgmt_cards::lib::telnet; sub new { my ($class, %options) = @_; @@ -79,11 +79,12 @@ sub check_options { sub run { my ($self, %options) = @_; - my $telnet_handle = hardware::server::sun::mgmtcards::lib::telnet::connect( + my $telnet_handle = hardware::server::sun::mgmt_cards::lib::telnet::connect( username => $self->{option_results}->{username}, password => $self->{option_results}->{password}, hostname => $self->{option_results}->{hostname}, port => $self->{option_results}->{port}, + timeout => $self->{option_results}->{timeout}, output => $self->{output}); my @lines = $telnet_handle->cmd("showenvironment"); @@ -94,7 +95,7 @@ sub run { $output =~ s/\r//g; my $long_msg = $output; $long_msg =~ s/\|/~/mg; - output_add(long_msg => $long_msg); + $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 diff --git a/hardware/server/sun/mgmt_cards/mode/showfaults.pm b/hardware/server/sun/mgmt_cards/mode/showfaults.pm index 2ef8c7faa..4c3af011f 100644 --- a/hardware/server/sun/mgmt_cards/mode/showfaults.pm +++ b/hardware/server/sun/mgmt_cards/mode/showfaults.pm @@ -81,7 +81,7 @@ sub run { ###### # 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 $cmd = "echo -e '" . $self->{option_results}->{username} . "\n" . $self->{option_results}->{password} . "\nshowfaults\nlogout\n' | " . $self->{option_results}->{command_plink} . ' -T -batch ' . $self->{option_results}->{hostname} . " 2>&1"; my ($lerror, $stdout, $exit_code) = centreon::plugins::misc::backtick( command => $cmd, timeout => $self->{option_results}->{timeout}, @@ -106,13 +106,17 @@ sub run { # Command treatment ###### my ($otp1, $otp2) = split(/showfaults\n/, $stdout); - $self->{output}->output_add(long_msg => $otp2); - if ($otp2 !~ /ID.*?FRU.*?Fault/mi) { + my $long_msg = $otp2; + $long_msg =~ s/\|/~/mg; + if (!defined($otp2) || $otp2 !~ /(No failures|ID.*?FRU.*?Fault)/mi) { + $self->{output}->output_add(long_msg => $stdout); $self->{output}->output_add(severity => 'UNKNOWN', short_msg => "Command 'showfaults' problems (see additional info)."); - return ; + $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."); # Check showfaults @@ -134,7 +138,7 @@ __END__ =head1 MODE -Check Sun 'T1xxx', 'T2xxx' ans 'T5xxx' Hardware (through ALOM4v). +Check Sun 'T1xxx', 'T2xxx' Hardware (through ALOM4v). =over 8 diff --git a/hardware/server/sun/mgmt_cards/mode/showfaulty.pm b/hardware/server/sun/mgmt_cards/mode/showfaulty.pm index 5a62f0e8f..1ee1be9db 100644 --- a/hardware/server/sun/mgmt_cards/mode/showfaulty.pm +++ b/hardware/server/sun/mgmt_cards/mode/showfaulty.pm @@ -117,14 +117,16 @@ sub run { 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) { + + if (!defined($otp2) || $otp2 !~ /Target.*?Property.*?Value/mi) { + $self->{output}->output_add(long_msg => $stdout); $self->{output}->output_add(severity => 'UNKNOWN', short_msg => "Command '$cmd_in' problems (see additional info)."); $self->{output}->display(); $self->{output}->exit(); } + $self->{output}->output_add(long_msg => $long_msg); 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', diff --git a/hardware/server/sun/mgmt_cards/plugin.pm b/hardware/server/sun/mgmt_cards/plugin.pm index 9c68aca21..468362382 100644 --- a/hardware/server/sun/mgmt_cards/plugin.pm +++ b/hardware/server/sun/mgmt_cards/plugin.pm @@ -50,10 +50,10 @@ sub new { 'show-faulty' => 'hardware::server::sun::mgmt_cards::mode::showfaulty', 'showfaults' => 'hardware::server::sun::mgmt_cards::mode::showfaults', 'showboards' => 'hardware::server::sun::mgmt_cards::mode::showboards', - 'showenvironment' => 'hardware::server::sun::mgmt_cards::mode::showenvironment', - 'environment-v8xx' => 'hardware::server::sun::mgmt_cards::mode::environmentv8xx', - 'environment-v4xx' => 'hardware::server::sun::mgmt_cards::mode::environmentv4xx', - 'environment-sf2xx' => 'hardware::server::sun::mgmt_cards::mode::environmentsf2xx', + 'showenvironment' => 'hardware::server::sun::mgmt_cards::mode::showenvironment', + 'environment-v8xx' => 'hardware::server::sun::mgmt_cards::mode::environmentv8xx', + 'environment-v4xx' => 'hardware::server::sun::mgmt_cards::mode::environmentv4xx', + 'environment-sf2xx' => 'hardware::server::sun::mgmt_cards::mode::environmentsf2xx', ); return $self; @@ -67,7 +67,7 @@ __END__ 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 'showfaults': ALOM4v (in T1xxx, T2xxx) (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) ; diff --git a/hardware/server/sun/sfxxk/mode/boards.pm b/hardware/server/sun/sfxxk/mode/boards.pm index f38e0275a..7fbd884a3 100644 --- a/hardware/server/sun/sfxxk/mode/boards.pm +++ b/hardware/server/sun/sfxxk/mode/boards.pm @@ -82,11 +82,17 @@ sub run { command => $self->{option_results}->{command_pasv}, command_path => $self->{option_results}->{command_path_pasv}, command_options => $self->{option_results}->{command_options_pasv}); - if ($stdout !~ /MAIN/i) { + if ($stdout =~ /SPARE/i) { $self->{output}->output_add(severity => 'OK', short_msg => "System Controller is in spare mode."); $self->{output}->display(); $self->{output}->exit(); + } elsif ($stdout !~ /MAIN/i) { + $self->{output}->output_add(long_msg => $stdout); + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => "Command problems (see additional info)."); + $self->{output}->display(); + $self->{output}->exit(); } $stdout = centreon::plugins::misc::execute(output => $self->{output}, @@ -144,7 +150,7 @@ Hostname to query (need --remote). =item B<--ssh-option> -Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52"). +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). =item B<--ssh-path> diff --git a/hardware/server/sun/sfxxk/mode/environment.pm b/hardware/server/sun/sfxxk/mode/environment.pm index 93828d4de..f74d094fa 100644 --- a/hardware/server/sun/sfxxk/mode/environment.pm +++ b/hardware/server/sun/sfxxk/mode/environment.pm @@ -82,11 +82,17 @@ sub run { command => $self->{option_results}->{command_pasv}, command_path => $self->{option_results}->{command_path_pasv}, command_options => $self->{option_results}->{command_options_pasv}); - if ($stdout !~ /MAIN/i) { + if ($stdout =~ /SPARE/i) { $self->{output}->output_add(severity => 'OK', short_msg => "System Controller is in spare mode."); $self->{output}->display(); $self->{output}->exit(); + } elsif ($stdout !~ /MAIN/i) { + $self->{output}->output_add(long_msg => $stdout); + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => "Command problems (see additional info)."); + $self->{output}->display(); + $self->{output}->exit(); } $stdout = centreon::plugins::misc::execute(output => $self->{output}, @@ -227,7 +233,7 @@ Hostname to query (need --remote). =item B<--ssh-option> -Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52"). +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). =item B<--ssh-path> diff --git a/hardware/server/sun/sfxxk/mode/failover.pm b/hardware/server/sun/sfxxk/mode/failover.pm index 7b6f6f4d1..f939182cf 100644 --- a/hardware/server/sun/sfxxk/mode/failover.pm +++ b/hardware/server/sun/sfxxk/mode/failover.pm @@ -82,11 +82,17 @@ sub run { command => $self->{option_results}->{command_pasv}, command_path => $self->{option_results}->{command_path_pasv}, command_options => $self->{option_results}->{command_options_pasv}); - if ($stdout !~ /MAIN/i) { + if ($stdout =~ /SPARE/i) { $self->{output}->output_add(severity => 'OK', short_msg => "System Controller is in spare mode."); $self->{output}->display(); $self->{output}->exit(); + } elsif ($stdout !~ /MAIN/i) { + $self->{output}->output_add(long_msg => $stdout); + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => "Command problems (see additional info)."); + $self->{output}->display(); + $self->{output}->exit(); } $stdout = centreon::plugins::misc::execute(output => $self->{output}, @@ -133,7 +139,7 @@ Hostname to query (need --remote). =item B<--ssh-option> -Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52"). +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). =item B<--ssh-path>