Debian Codegraph @

src/storage/hp/storeonce/ssh/mode/hardware.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 storage::hp::storeonce::ssh::mode::hardware;
22
23 use base qw(centreon::plugins::templates::hardware);
24
25 use strict;
26 use warnings;
27
28 sub set_system {
29 my ($self, %options) = @_;
30
31 $self->{cb_hook2} = 'ssh_execute';
32
33 $self->{thresholds} = {
34 hardware => [
35 ['ok', 'OK'],
36 ['failed', 'CRITICAL'],
37 ['degraded', 'WARNING'],
38 ['missing', 'OK'],
39 ],
40 serviceset => [
41 ['running', 'OK'],
42 ['fault', 'CRITICAL'],
43 ],
44 };
45
46 $self->{components_path} = 'storage::hp::storeonce::ssh::mode::components';
47 $self->{components_module} = ['hardware', 'serviceset'];
48 }
49
50 sub ssh_execute {
51 my ($self, %options) = @_;
52
53 ($self->{result}, $self->{exit_code}) = $options{custom}->execute_command(commands => $self->{commands});
54 }
55
56 sub new {
57 my ($class, %options) = @_;
58 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1);
59 bless $self, $class;
60
61 $options{options}->add_options(arguments => {});
62
63 $self->{commands} = [];
64 return $self;
65 }
66
67 sub get_hasharray {
68 my ($self, %options) = @_;
69
70 my $result = [];
71 return $result if ($options{content} eq '');
72 my ($header, @lines) = split /\n/, $options{content};
73 my @header_names = split /$options{delim}/, $header;
74
75 for (my $i = 0; $i <= $#lines; $i++) {
76 my @content = split /$options{delim}/, $lines[$i];
77 my $data = {};
78 for (my $j = 0; $j <= $#header_names; $j++) {
79 $data->{$header_names[$j]} = $content[$j];
80 }
81 push @$result, $data;
82 }
83
84 return $result;
85 }
86
87 1;
88
89 __END__
90
91 =head1 MODE
92
93 Check components (hardware and service set).
94
95 =over 8
96
97 =item B<--component>
98
99 Which component to check (default: '.*').
100 Can be: 'hardware', 'serviceset'.
101
102 =item B<--filter>
103
104 Exclude the items given as a comma-separated list (example: --filter=hardware --filter=serviceset).
105 You can also exclude items from specific instances: --filter=hardware,storageCluster
106
107 =item B<--no-component>
108
109 Define the expected status if no components are found (default: critical).
110
111 =item B<--threshold-overload>
112
113 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
114 Example: --threshold-overload='hardware,networkSwitch,OK,degraded'
115
116 =back
117
118 =cut