Debian Codegraph @

src/os/solaris/local/mode/lomv120components/sf.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::lomv120components::sf;
22
23 use strict;
24 use warnings;
25 use centreon::plugins::misc;
26
27 sub check {
28 my ($self) = @_;
29
30 $self->{output}->output_add(long_msg => "Checking system flag");
31 $self->{components}->{sf} = {name => 'system flag', total => 0, skip => 0};
32 return if ($self->check_filter(section => 'sf'));
33
34 #System status flags:
35 # 1 SCSI-Term status=ok
36 # 2 USB0 status=ok
37 # 3 USB1 status=ok
38 return if ($self->{stdout} !~ /^System status flags:(.*)/ims);
39
40 my @content = split(/\n/, $1);
41 shift @content;
42 foreach my $line (@content) {
43 $line = centreon::plugins::misc::trim($line);
44 next if ($line !~ /^\s*(\S+).*?status=(.*)/);
45 my ($instance, $status) = ($1, $2);
46
47 next if ($self->check_filter(section => 'sf', instance => $instance));
48 $self->{components}->{sf}->{total}++;
49
50 $self->{output}->output_add(
51 long_msg => sprintf(
52 "system flag '%s' status is %s.",
53 $instance, $status
54 )
55 );
56 my $exit = $self->get_severity(label => 'default', section => 'sf', value => $status);
57 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
58 $self->{output}->output_add(severity => $exit,
59 short_msg => sprintf("system flag '%s' status is %s",
60 $instance, $status));
61 }
62 }
63 }
64
65 1;