Debian Codegraph @

src/storage/netapp/ontap/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::netapp::ontap::snmp::mode::globalstatus;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28
29 sub set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'global', type => 0, skipped_code => { -10 => 1 } }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'read', nlabel => 'storage.io.read.usage.bytespersecond', set => {
38 key_values => [ { name => 'read', per_second => 1 } ],
39 output_template => 'Read I/O : %s %s/s',
40 output_change_bytes => 1,
41 perfdatas => [
42 { template => '%d', unit => 'B/s', min => 0 }
43 ]
44 }
45 },
46 { label => 'write', nlabel => 'storage.io.write.usage.bytespersecond', set => {
47 key_values => [ { name => 'write', per_second => 1 } ],
48 output_template => 'Write I/O : %s %s/s',
49 output_change_bytes => 1,
50 perfdatas => [
51 { template => '%d', unit => 'B/s', min => 0 }
52 ]
53 }
54 }
55 ];
56 }
57
58 sub new {
59 my ($class, %options) = @_;
60 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
61 bless $self, $class;
62
63 $options{options}->add_options(arguments => {});
64
65 return $self;
66 }
67
68 my %states = (
69 1 => ['other', 'WARNING'],
70 2 => ['unknown', 'UNKNOWN'],
71 3 => ['ok', 'OK'],
72 4 => ['non critical', 'WARNING'],
73 5 => ['critical', 'CRITICAL'],
74 6 => ['nonRecoverable', 'WARNING']
75 );
76 my %fs_states = (
77 1 => ['ok', 'OK'],
78 2 => ['nearly full', 'WARNING'],
79 3 => ['full', 'CRITICAL']
80 );
81
82 my $oid_fsOverallStatus = '.1.3.6.1.4.1.789.1.5.7.1.0';
83 my $oid_fsStatusMessage = '.1.3.6.1.4.1.789.1.5.7.2.0';
84 my $oid_miscGlobalStatus = '.1.3.6.1.4.1.789.1.2.2.4.0';
85 my $oid_miscGlobalStatusMessage = '.1.3.6.1.4.1.789.1.2.2.25.0';
86 my $oid_misc64DiskReadBytes = '.1.3.6.1.4.1.789.1.2.2.32.0';
87 my $oid_misc64DiskWriteBytes = '.1.3.6.1.4.1.789.1.2.2.33.0';
88 my $oid_miscHighDiskReadBytes = '.1.3.6.1.4.1.789.1.2.2.15.0';
89 my $oid_miscLowDiskReadBytes = '.1.3.6.1.4.1.789.1.2.2.16.0';
90 my $oid_miscHighDiskWriteBytes = '.1.3.6.1.4.1.789.1.2.2.17.0';
91 my $oid_miscLowDiskWriteBytes = '.1.3.6.1.4.1.789.1.2.2.18.0';
92
93 sub manage_selection {
94 my ($self, %options) = @_;
95
96 my $request = [
97 $oid_fsOverallStatus, $oid_fsStatusMessage,
98 $oid_miscGlobalStatus, $oid_miscGlobalStatusMessage,
99 $oid_miscHighDiskReadBytes, $oid_miscLowDiskReadBytes,
100 $oid_miscHighDiskWriteBytes, $oid_miscLowDiskWriteBytes
101 ];
102 if (!$options{snmp}->is_snmpv1()) {
103 push @{$request}, ($oid_misc64DiskReadBytes, $oid_misc64DiskWriteBytes);
104 }
105
106 my $snmp_result = $options{snmp}->get_leef(oids => $request, nothing_quit => 1);
107
108 $self->{global} = {};
109
110 if (defined($snmp_result->{$oid_misc64DiskReadBytes})) {
111 $self->{global}->{read} = $snmp_result->{$oid_misc64DiskReadBytes};
112 } elsif (defined($snmp_result->{$oid_miscLowDiskReadBytes})) {
113 $self->{global}->{read} = ($snmp_result->{$oid_miscHighDiskReadBytes} << 32) + $snmp_result->{$oid_miscLowDiskReadBytes};
114 }
115
116 if (defined($snmp_result->{$oid_misc64DiskWriteBytes})) {
117 $self->{global}->{write} = $snmp_result->{$oid_misc64DiskWriteBytes};
118 } elsif (defined($snmp_result->{$oid_miscLowDiskWriteBytes})) {
119 $self->{global}->{write} = ($snmp_result->{$oid_miscHighDiskWriteBytes} << 32) + $snmp_result->{$oid_miscLowDiskWriteBytes};
120 }
121
122 $snmp_result->{$oid_miscGlobalStatusMessage} =~ s/\n//g;
123 $self->{output}->output_add(
124 severity => ${$states{$snmp_result->{$oid_miscGlobalStatus}}}[1],
125 short_msg => sprintf(
126 "Overall global status is '%s' [message: '%s']",
127 $states{ $snmp_result->{$oid_miscGlobalStatus} }->[0], $snmp_result->{$oid_miscGlobalStatusMessage}
128 )
129 );
130
131 if (defined($snmp_result->{$oid_fsStatusMessage})) {
132 $snmp_result->{$oid_fsStatusMessage} =~ s/\n//g;
133 $self->{output}->output_add(
134 severity => ${$fs_states{$snmp_result->{$oid_fsOverallStatus}}}[1],
135 short_msg => sprintf(
136 "Overall file system status is '%s' [message: '%s']",
137 $fs_states{ $snmp_result->{$oid_fsOverallStatus} }->[0], $snmp_result->{$oid_fsStatusMessage}
138 )
139 );
140 }
141
142 $self->{cache_name} = "cache_netapp_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
143 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
144 }
145
146 1;
147
148 __END__
149
150 =head1 MODE
151
152 Check the overall status of the appliance and some metrics (total read bytes per seconds and total write bytes per seconds).
153 If you are in cluster mode, the following mode doesn't work. Ask to netapp to add it :)
154
155 =over 8
156
157 =item B<--warning-*> B<--critical-*>
158
159 Thresholds.
160 Can be: 'read', 'write'.
161
162 =back
163
164 =cut