Debian Codegraph @

src/os/solaris/local/mode/lomv1280.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::lomv1280;
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 => 'lom',
49 command_options => '-fpv 2>&1',
50 command_path => '/usr/sbin'
51 );
52
53 my $long_msg = $stdout;
54 $long_msg =~ s/\|/~/mg;
55 $self->{output}->output_add(long_msg => $long_msg);
56
57 $self->{output}->output_add(
58 severity => 'OK',
59 short_msg => "No problems detected."
60 );
61
62 if ($stdout =~ /^Fans:(.*?):/ims) {
63 #Fans:
64 # 1 FT0/FAN3 ft_fan3 OK speed self-regulating
65 # 9 IB6/FAN0 ft_fan0 OK speed 100 %
66 my @content = split(/\n/, $1);
67 shift @content;
68 pop @content;
69 foreach my $line (@content) {
70 next if ($line !~ /^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/);
71 my ($fan_name, $status) = ($2, $4);
72
73 if ($status !~ /OK/i) {
74 $self->{output}->output_add(
75 severity => 'CRITICAL',
76 short_msg => "Fan '$fan_name' status is '$status'"
77 );
78 }
79 }
80 }
81
82 if ($stdout =~ /^PSUs:(.*?):/ims) {
83 #PSUs:
84 # PS0 OK
85 # PS1 OK
86 my @content = split(/\n/, $1);
87 shift @content;
88 pop @content;
89 foreach my $line (@content) {
90 next if ($line !~ /^\s*(\S+)\s+(\S+)/);
91 my ($psu_num, $status) = ($1, $2);
92
93 if ($status !~ /OK/i) {
94 $self->{output}->output_add(
95 severity => 'CRITICAL',
96 short_msg => "Psu '$psu_num' status is '$status'"
97 );
98 }
99 }
100 }
101
102 if ($stdout =~ /^Supply voltages:(.*?):/ims) {
103 #Supply voltages:
104 # 1 SSC1 v_1.5vdc0 status=ok
105 # 2 SSC1 v_3.3vdc0 status=ok
106 # 3 SSC1 v_5vdc0 status=ok
107 # 4 RP0 v_1.5vdc0 status=ok
108 my @content = split(/\n/, $1);
109 shift @content;
110 pop @content;
111 foreach my $line (@content) {
112 $line = centreon::plugins::misc::trim($line);
113 my @fields = split(/\s+/, $line);
114
115 shift @fields;
116 my $field_status = pop(@fields);
117 $field_status =~ /status=(.*)/i;
118 my $status = $1;
119 my $name = join(' ', @fields);
120 if ($status !~ /OK/i) {
121 $self->{output}->output_add(
122 severity => 'CRITICAL',
123 short_msg => "Supply voltage '$name' status is '$status'"
124 );
125 }
126 }
127 }
128
129 if ($stdout =~ /^System status flags:(.*)/ims) {
130 #System status flags:
131 # 1 PS0 status=okay
132 # 2 PS1 status=okay
133 # 3 PS2 status=okay
134 # 4 PS3 status=okay
135 # 5 FT0 status=okay
136 # 6 FT0/FAN3 status=okay
137 my @content = split(/\n/, $1);
138 shift @content;
139 pop @content;
140 foreach my $line (@content) {
141 $line = centreon::plugins::misc::trim($line);
142 my @fields = split(/\s+/, $line);
143
144 shift @fields;
145 my $field_status = pop(@fields);
146 $field_status =~ /status=(.*)/i;
147 my $status = $1;
148 my $name = join(' ', @fields);
149 if ($status !~ /OK/i) {
150 $self->{output}->output_add(
151 severity => 'CRITICAL',
152 short_msg => "System '$name' flag status is '$status'"
153 );
154 }
155 }
156 }
157
158 $self->{output}->display();
159 $self->{output}->exit();
160 }
161
162 1;
163
164 __END__
165
166 =head1 MODE
167
168 Check hardware status for 'v1280'.
169
170 Command used '/usr/sbin/lom -fpv 2>&1'
171
172 =over 8
173
174 =back
175
176 =cut