Debian Codegraph @

src/storage/dell/compellent/snmp/mode/globalstatus.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::dell::compellent::snmp::mode::globalstatus;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
28
29 sub custom_status_output {
30 my ($self, %options) = @_;
31
32 return sprintf("global status is '%s'", $self->{result_values}->{status});
33 }
34
35 sub prefix_global_output {
36 my ($self, %options) = @_;
37
38 return "'" . $self->{global}->{display} . "': ";
39 }
40
41 sub set_counters {
42 my ($self, %options) = @_;
43
44 $self->{maps_counters_type} = [
45 { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }
46 ];
47
48 $self->{maps_counters}->{global} = [
49 {
50 label => 'status',
51 type => 2,
52 unknown_default => '%{status} =~ /unknown/',
53 warning_default => '%{status} =~ /nonCritical|other/',
54 critical_default => '%{status} =~ /critical|nonRecoverable/',
55 set => {
56 key_values => [ { name => 'status' } ],
57 closure_custom_output => $self->can('custom_status_output'),
58 closure_custom_perfdata => sub { return 0; },
59 closure_custom_threshold_check => \&catalog_status_threshold_ng
60 }
61 }
62 ];
63 }
64
65 sub new {
66 my ($class, %options) = @_;
67 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
68 bless $self, $class;
69
70 $options{options}->add_options(arguments => {
71 });
72
73 return $self;
74 }
75
76 my $map_status = {
77 1 => 'other', 2 => 'unknown',
78 3 => 'ok', 4 => 'nonCritical',
79 5 => 'critical', 6 => 'nonRecoverable'
80 };
81
82 my $mapping = {
83 global_status => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.6', map => $map_status }, # productIDGlobalStatus
84 build_number => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.7' } # productIDBuildNumber
85 };
86 my $mapping_ctrl = {
87 ctrl_model => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1.7' } # scCtlrModel
88 };
89
90 my $oid_scCtlrEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1';
91 my $oid_storageCenterObjects = '.1.3.6.1.4.1.674.11000.2000.500.1.2';
92
93 sub manage_selection {
94 my ($self, %options) = @_;
95
96 my $snmp_result = $options{snmp}->get_multiple_table(
97 oids => [
98 { oid => $oid_storageCenterObjects, start => $mapping->{global_status}->{oid}, end => $mapping->{build_number}->{oid} },
99 { oid => $oid_scCtlrEntry, start => $mapping_ctrl->{ctrl_model}->{oid}, end => $mapping_ctrl->{ctrl_model}->{oid} }
100 ],
101 nothing_quit => 1
102 );
103
104 my $display = '';
105 foreach (keys %{$snmp_result->{$oid_scCtlrEntry}}) {
106 next if (! /^$mapping_ctrl->{ctrl_model}->{oid}\.(.*)$/);
107 my $result = $options{snmp}->map_instance(mapping => $mapping_ctrl, results => $snmp_result->{$oid_scCtlrEntry}, instance => $1);
108 $display = $result->{ctrl_model};
109 last if (length($display));
110 }
111
112 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_storageCenterObjects}, instance => 0);
113 $display .= '.' . $result->{build_number};
114
115 $self->{global} = {
116 display => $display,
117 status => $result->{global_status}
118 };
119 }
120
121 1;
122
123 __END__
124
125 =head1 MODE
126
127 Check the overall status of Dell Compellent.
128
129 =over 8
130
131 =item B<--unknown-status>
132
133 Define the conditions to match for the status to be UNKNOWN (default: '%{status} =~ /unknown/').
134 You can use the following variables: %{status}
135
136 =item B<--warning-status>
137
138 Define the conditions to match for the status to be WARNING (default: '%{status} =~ /nonCritical|other/').
139 You can use the following variables: %{status}
140
141 =item B<--critical-status>
142
143 Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /critical|nonRecoverable/').
144 You can use the following variables: %{status}
145
146 =back
147
148 =cut