| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package hardware::server::sun::sfxxk::mode::environment; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::misc; |
| 28 |
|
| 29 |
sub new { |
| 30 |
my ($class, %options) = @_; |
| 31 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 32 |
bless $self, $class; |
| 33 |
|
| 34 |
$options{options}->add_options(arguments => {}); |
| 35 |
|
| 36 |
return $self; |
| 37 |
} |
| 38 |
|
| 39 |
sub check_options { |
| 40 |
my ($self, %options) = @_; |
| 41 |
$self->SUPER::init(%options); |
| 42 |
} |
| 43 |
|
| 44 |
sub run { |
| 45 |
my ($self, %options) = @_; |
| 46 |
|
| 47 |
my ($stdout) = $options{custom}->execute_command( |
| 48 |
command => 'showfailover', |
| 49 |
command_options => '-r 2>&1', |
| 50 |
command_path => '/opt/SUNWSMS/bin' |
| 51 |
); |
| 52 |
|
| 53 |
if ($stdout =~ /SPARE/i) { |
| 54 |
$self->{output}->output_add( |
| 55 |
severity => 'OK', |
| 56 |
short_msg => "System Controller is in spare mode." |
| 57 |
); |
| 58 |
$self->{output}->display(); |
| 59 |
$self->{output}->exit(); |
| 60 |
} elsif ($stdout !~ /MAIN/i) { |
| 61 |
$self->{output}->output_add(long_msg => $stdout); |
| 62 |
$self->{output}->output_add( |
| 63 |
severity => 'UNKNOWN', |
| 64 |
short_msg => "Command problems (see additional info)." |
| 65 |
); |
| 66 |
$self->{output}->display(); |
| 67 |
$self->{output}->exit(); |
| 68 |
} |
| 69 |
|
| 70 |
($stdout) = $options{custom}->execute_command( |
| 71 |
command => 'showenvironment', |
| 72 |
command_options => '2>&1', |
| 73 |
command_path => '/opt/SUNWSMS/bin' |
| 74 |
); |
| 75 |
|
| 76 |
$self->{output}->output_add( |
| 77 |
severity => 'OK', |
| 78 |
short_msg => "No problems detected." |
| 79 |
); |
| 80 |
if ($stdout =~ /^LOCATION(.*?)\n\n/ims) { |
| 81 |
#LOCATION SENSOR VALUE UNIT AGE STATUS |
| 82 |
#---------- ------------ ----- ---- ------ ------ |
| 83 |
#SCPER at SCPER1 AMB 0 Temp 27 C 30.0 sec HIGH_WARN |
| 84 |
#EXB at EX0 -- -- -- -- OFF |
| 85 |
#CP at CP1 DMX0 Temp 39 C 29.8 sec OK |
| 86 |
my @content = split(/\n/, $1); |
| 87 |
shift @content; |
| 88 |
foreach (@content) { |
| 89 |
next if (/^---/); |
| 90 |
if (/(\S+)\s*$/ && $1 !~ /^OK|OFF|PRESENCE$/) { |
| 91 |
my $sensor_status = $1; |
| 92 |
|
| 93 |
/^\s*(.*?)\s{2}\s*(.*?)\s{2}\s*/; |
| 94 |
my $location = $1; |
| 95 |
$location = centreon::plugins::misc::trim($location); |
| 96 |
my $sensor = $2; |
| 97 |
$sensor = centreon::plugins::misc::trim($sensor); |
| 98 |
|
| 99 |
$self->{output}->output_add( |
| 100 |
severity => 'CRITICAL', |
| 101 |
short_msg => "Sensor '$location/$sensor' status is '" . $sensor_status . "'" |
| 102 |
); |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
if ($stdout =~ /^FANTRAY(.*?)\n\n/ims) { |
| 108 |
#FANTRAY POWER SPEED FAN0 FAN1 FAN2 FAN3 FAN4 FAN5 |
| 109 |
#------ ------ ----- ---- ---- ---- ---- ---- ---- |
| 110 |
#FT0 ON NORMAL OK OK OK OK OK OK |
| 111 |
#FT1 ON NORMAL OK OK OK OK OK OK |
| 112 |
my @content = split(/\n/, $1); |
| 113 |
shift @content; |
| 114 |
foreach my $line (@content) { |
| 115 |
|
| 116 |
next if ($line =~ /^---/); |
| 117 |
my $save_line = $line; |
| 118 |
$line =~ s/^\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*//; |
| 119 |
$save_line =~ /^\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*/; |
| 120 |
my $fantray = $1; |
| 121 |
my $fanspeed = $3; |
| 122 |
|
| 123 |
if ($fanspeed !~ /^NORMAL$/i) { |
| 124 |
$self->{output}->output_add( |
| 125 |
severity => 'CRITICAL', |
| 126 |
short_msg => "FanTray '$fantray' speed status is '" . $fanspeed . "'" |
| 127 |
); |
| 128 |
} |
| 129 |
|
| 130 |
my $fan_num = 0; |
| 131 |
while ($line =~ /\s*(.+?)(\s{2}|$)/ig) { |
| 132 |
my $status = $1; |
| 133 |
$status = centreon::plugins::misc::trim($1); |
| 134 |
|
| 135 |
next if ($status eq ''); |
| 136 |
|
| 137 |
if ($status !~ /^OK$/i) { |
| 138 |
$self->{output}->output_add( |
| 139 |
severity => 'CRITICAL', |
| 140 |
short_msg => "FanTray '$fantray' fan '$fan_num' status is '" . $status . "'" |
| 141 |
); |
| 142 |
} |
| 143 |
$fan_num++; |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
if ($stdout =~ /^POWER\s*UNIT(.*?)\n\n/ims) { |
| 149 |
#POWER UNIT AC0 AC1 DC0 DC1 FAN0 FAN1 |
| 150 |
#----- ---- --- --- --- --- ---- ---- |
| 151 |
#PS-A196 at PS0 FAIL FAIL FAIL ON ON OK OK |
| 152 |
#PS-A196 at PS1 OK FAIL OK ON ON OK OK |
| 153 |
my @content = split(/\n/, $1); |
| 154 |
shift @content; |
| 155 |
foreach my $line (@content) { |
| 156 |
|
| 157 |
next if ($line =~ /^---/); |
| 158 |
next if ($line !~ /^\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)\s{2}\s*(.*?)(\s{2}|$)/); |
| 159 |
my ($power_name, $unit, $ac0, $ac1, $dc0, $dc1, $fan0, $fan1) = ($1, $2, $3, $4, $5, $6, $7, $8); |
| 160 |
my $errors = ''; |
| 161 |
$errors .= ' [UNIT=' . centreon::plugins::misc::trim($unit) . ']' if ($unit !~ /OK/i); |
| 162 |
$errors .= ' [AC0=' . centreon::plugins::misc::trim($ac0) . ']' if ($ac0 !~ /OK/i); |
| 163 |
$errors .= ' [AC1=' . centreon::plugins::misc::trim($ac1) . ']' if ($ac1 !~ /OK/i); |
| 164 |
$errors .= ' [DC0=' . centreon::plugins::misc::trim($dc0) . ']' if ($dc0 !~ /ON/i); |
| 165 |
$errors .= ' [DC1=' . centreon::plugins::misc::trim($dc1) . ']' if ($dc1 !~ /ON/i); |
| 166 |
$errors .= ' [DC1=' . centreon::plugins::misc::trim($fan0) . ']' if ($fan0 !~ /OK/i); |
| 167 |
$errors .= ' [DC1=' . centreon::plugins::misc::trim($fan1) . ']' if ($fan1 !~ /OK/i); |
| 168 |
if ($errors ne '') { |
| 169 |
$self->{output}->output_add( |
| 170 |
severity => 'CRITICAL', |
| 171 |
short_msg => "Some errors on power '$power_name':" . $errors |
| 172 |
); |
| 173 |
} |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
#POWER VALUE UNIT STATUS |
| 178 |
#--------- ----- ---- ------ |
| 179 |
#PS-A196 at PS0 |
| 180 |
# Current0 0.00 A N/A |
| 181 |
# Current1 0.00 A N/A |
| 182 |
# 48VDC 0.20 V N/A |
| 183 |
# Power 0.00 W N/A |
| 184 |
#PS-A196 at PS1 |
| 185 |
# Current0 0.00 A N/A |
| 186 |
# Current1 14.00 A N/A |
| 187 |
# 48VDC 49.60 V N/A |
| 188 |
# Power 694.40 W N/A |
| 189 |
#Total Power 2427.44 W N/A |
| 190 |
# |
| 191 |
# Not managed. Dont know if there is a status??? |
| 192 |
|
| 193 |
$self->{output}->display(); |
| 194 |
$self->{output}->exit(); |
| 195 |
} |
| 196 |
|
| 197 |
1; |
| 198 |
|
| 199 |
__END__ |
| 200 |
|
| 201 |
=head1 MODE |
| 202 |
|
| 203 |
Check Sun 'sfxxk' environment. |
| 204 |
|
| 205 |
=over 8 |
| 206 |
|
| 207 |
=back |
| 208 |
|
| 209 |
=cut |