Debian Codegraph @

src/os/solaris/local/mode/hwsas2ircu.pm

raw
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 os::solaris::local::mode::hwsas2ircu;
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 => 'sas2ircu',
49 command_options => 'LIST 2>&1',
50 command_path => '/usr/bin'
51 );
52
53 $self->{output}->output_add(
54 severity => 'OK',
55 short_msg => "No problems on volumes"
56 );
57
58 while (($stdout =~ /^\s*Index.*?\n.*?\n\s+(\d+)\s+/imsg)) {
59 # Index Type ID ID Pci Address Ven ID Dev ID
60 # ----- ------------ ------ ------ ----------------- ------ ------
61 # 0 SAS2008 1000h 72h 00h:04h:00h:00h 1000h 0072h
62 #
63 # Adapter Vendor Device SubSys SubSys
64 # Index Type ID ID Pci Address Ven ID Dev ID
65 # ----- ------------ ------ ------ ----------------- ------ ------
66 # 1 SAS2008 1000h 72h 00h:0bh:00h:00h 1000h 0072h
67 #SAS2IRCU: Utility Completed Successfully.
68 my $index = $1;
69
70 my ($stdout2) = $options{custom}->execute_command(
71 command => 'sas2ircu',
72 command_options => sprintf('%s DISPLAY 2>&1', $index),
73 command_path => '/usr/bin'
74 );
75
76 #IR Volume information
77 #------------------------------------------------------------------------
78 #IR volume 1
79 # Volume ID : 905
80 # Volume Name : test
81 # Status of volume : Okay (OKY)
82 # RAID level : RAID1
83 # Size (in MB) : 68664
84 # Physical hard disks :
85 # PHY[0] Enclosure#/Slot# : 1:2
86 # PHY[1] Enclosure#/Slot# : 1:3
87 #------------------------------------------------------------------------
88 #Physical device information
89
90 if ($stdout2 =~ /^IR Volume information(.*)Physical device information/ims) {
91 my @content = split(/\n/, $1);
92 shift @content;
93 my $volume_name = '';
94 foreach my $line (@content) {
95
96 next if ($line =~ /^---/);
97
98 if ($line =~ /Volume Name\s+:\s+(.*)/i) {
99 $volume_name = $1;
100 $volume_name = centreon::plugins::misc::trim($volume_name);
101 next;
102 }
103
104 if ($line =~ /Status of volume\s+:\s+(.*)(\n|\()/i) {
105 my $status_volume = $1;
106 $status_volume = centreon::plugins::misc::trim($status_volume);
107 if ($status_volume !~ /Okay/i) {
108 $self->{output}->output_add(
109 severity => 'CRITICAL',
110 short_msg => "Volume 'volume_name' status is '$status_volume'"
111 );
112 }
113 }
114 }
115 }
116 }
117
118 $self->{output}->display();
119 $self->{output}->exit();
120 }
121
122 1;
123
124 __END__
125
126 =head1 MODE
127
128 Check hardware raid status (use 'sas2ircu' command).
129
130 Command used: '/usr/bin/sas2ircu LIST 2>&1' and '/usr/bin/sas2ircu %(index) DISPLAY 2>&1'
131
132 =over 8
133
134 =back
135
136 =cut