| 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 storage::hp::storeonce::ssh::mode::components::hardware; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use centreon::plugins::misc; |
| 26 |
|
| 27 |
sub load { |
| 28 |
my ($self) = @_; |
| 29 |
|
| 30 |
#Name |
| 31 |
#------------------------------------------------------------------ |
| 32 |
#hp80239e8624-1 |
| 33 |
# Dev-id = 31343337-3338-5A43-3235-323430375631 |
| 34 |
# Status = OK |
| 35 |
# message = - |
| 36 |
# type = server |
| 37 |
# model = ProLiant DL380p Gen8 |
| 38 |
# serialNumber = CZ252407V1 |
| 39 |
# firmwareVersion = P70 07/01/2015 |
| 40 |
# location = - |
| 41 |
# warrantySerialNumber = CZ35283EK4 |
| 42 |
# warrantyPartNumber = BB896A |
| 43 |
# SKU = 734183-B21 |
| 44 |
# |
| 45 |
#hp80239e8624-2 |
| 46 |
# Dev-id = 31343337-3338-5A43-3235-323431303648 |
| 47 |
# Status = OK |
| 48 |
# message = - |
| 49 |
# type = server |
| 50 |
# model = ProLiant DL380p Gen8 |
| 51 |
# serialNumber = CZ2524106H |
| 52 |
# firmwareVersion = P70 07/01/2015 |
| 53 |
# location = - |
| 54 |
# warrantySerialNumber = CZ35283EK4 |
| 55 |
# warrantyPartNumber = BB896A |
| 56 |
# SKU = 734183-B21 |
| 57 |
|
| 58 |
push @{$self->{commands}}, "hardware show status details"; |
| 59 |
} |
| 60 |
|
| 61 |
sub check { |
| 62 |
my ($self) = @_; |
| 63 |
|
| 64 |
$self->{output}->output_add(long_msg => "Checking hardwares"); |
| 65 |
$self->{components}->{hardware} = {name => 'hardwares', total => 0, skip => 0}; |
| 66 |
return if ($self->check_filter(section => 'hardware')); |
| 67 |
|
| 68 |
return if ($self->{result} !~ /[>#]\s*hardware show status details(.*?)\n[>#]/msi); |
| 69 |
my $content = $1; |
| 70 |
|
| 71 |
while ($content =~ /^(\S+[^\n]*?)\n\s+(.*?)\n\s*?\n/msgi) { |
| 72 |
my ($name, $details) = (centreon::plugins::misc::trim($1), $2); |
| 73 |
|
| 74 |
$details =~ /type.*?=\s*(.*?)\n/msi; |
| 75 |
my $type = centreon::plugins::misc::trim($1); |
| 76 |
$details =~ /Status.*?=\s*(.*?)\n/msi; |
| 77 |
my $status = centreon::plugins::misc::trim($1); |
| 78 |
$details =~ /Dev-id.*?=\s*(.*?)\n/msi; |
| 79 |
my $dev_id = centreon::plugins::misc::trim($1); |
| 80 |
|
| 81 |
next if ($self->check_filter(section => 'hardware', instance => $type . '.' . $dev_id)); |
| 82 |
$self->{components}->{hardware}->{total}++; |
| 83 |
|
| 84 |
$self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance: %s, name: %s].", |
| 85 |
$type, $dev_id, $status, |
| 86 |
$type . '.' . $dev_id, $name |
| 87 |
)); |
| 88 |
my $exit = $self->get_severity(section => 'hardware', instance => $type . '.' . $dev_id, value => $status); |
| 89 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 90 |
$self->{output}->output_add(severity => $exit, |
| 91 |
short_msg => sprintf("%s '%s' status is '%s'", |
| 92 |
$type, $dev_id, $status)); |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
1; |