| 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::emc::datadomain::snmp::mode::listfilesystems; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use storage::emc::datadomain::snmp::lib::functions; |
| 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 |
|
| 37 |
return $self; |
| 38 |
} |
| 39 |
|
| 40 |
sub check_options { |
| 41 |
my ($self, %options) = @_; |
| 42 |
$self->SUPER::init(%options); |
| 43 |
} |
| 44 |
|
| 45 |
my $oid_fileSystemSpaceEntry = '.1.3.6.1.4.1.19746.1.3.2.1.1'; |
| 46 |
my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752' |
| 47 |
my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceAvail); |
| 48 |
|
| 49 |
my @mapping = ('name', 'total', 'used'); |
| 50 |
|
| 51 |
sub manage_selection { |
| 52 |
my ($self, %options) = @_; |
| 53 |
|
| 54 |
my $snmp_result = $options{snmp}->get_leef( |
| 55 |
oids => [ $oid_sysDescr ], |
| 56 |
nothing_quit => 1 |
| 57 |
); |
| 58 |
if (!($self->{os_version} = storage::emc::datadomain::snmp::lib::functions::get_version(value => $snmp_result->{$oid_sysDescr}))) { |
| 59 |
$self->{output}->output_add( |
| 60 |
severity => 'UNKNOWN', |
| 61 |
short_msg => 'Cannot get DataDomain OS version.' |
| 62 |
); |
| 63 |
$self->{output}->display(); |
| 64 |
$self->{output}->exit(); |
| 65 |
} |
| 66 |
|
| 67 |
$snmp_result = $options{snmp}->get_table( |
| 68 |
oid => $oid_fileSystemSpaceEntry, |
| 69 |
nothing_quit => 1 |
| 70 |
); |
| 71 |
|
| 72 |
if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { |
| 73 |
$oid_fileSystemResourceName = '.1.3.6.1.4.1.19746.1.3.2.1.1.3'; |
| 74 |
$oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.5'; |
| 75 |
$oid_fileSystemSpaceAvail = '.1.3.6.1.4.1.19746.1.3.2.1.1.6'; |
| 76 |
} else { |
| 77 |
$oid_fileSystemResourceName = '.1.3.6.1.4.1.19746.1.3.2.1.1.2'; |
| 78 |
$oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.4'; |
| 79 |
$oid_fileSystemSpaceAvail = '.1.3.6.1.4.1.19746.1.3.2.1.1.5'; |
| 80 |
} |
| 81 |
|
| 82 |
my $results = {}; |
| 83 |
foreach my $oid (keys %$snmp_result) { |
| 84 |
next if ($oid !~ /^$oid_fileSystemResourceName\.(\d+)$/); |
| 85 |
my $instance = $1; |
| 86 |
|
| 87 |
my $name = $snmp_result->{$oid_fileSystemResourceName . '.' . $instance}; |
| 88 |
my $precomp = 0; |
| 89 |
my $postcomp = 0; |
| 90 |
|
| 91 |
$precomp = 1 if ($name =~ /:\s*pre-comp/); |
| 92 |
$postcomp = 1 if ($name =~ /:\s*post-comp/); |
| 93 |
$name =~ s/:\s*(pre-comp|post-comp).*//; |
| 94 |
|
| 95 |
my $used = int($snmp_result->{$oid_fileSystemSpaceUsed . '.' . $instance} * 1024 * 1024 * 1024); |
| 96 |
my $free = int($snmp_result->{$oid_fileSystemSpaceAvail . '.' . $instance} * 1024 * 1024 * 1024); |
| 97 |
my $total = $used + $free; |
| 98 |
|
| 99 |
next if ($total == 0 || $precomp == 1); |
| 100 |
|
| 101 |
$results->{$name} = { |
| 102 |
name => $name, |
| 103 |
used => $used, |
| 104 |
total => $total |
| 105 |
}; |
| 106 |
} |
| 107 |
|
| 108 |
return $results; |
| 109 |
} |
| 110 |
|
| 111 |
sub run { |
| 112 |
my ($self, %options) = @_; |
| 113 |
|
| 114 |
my $results = $self->manage_selection(snmp => $options{snmp}); |
| 115 |
foreach my $name (sort keys %$results) { |
| 116 |
$self->{output}->output_add(long_msg => |
| 117 |
join('', map("[$_ = " . $results->{$name}->{$_} . ']', @mapping)) |
| 118 |
); |
| 119 |
} |
| 120 |
|
| 121 |
$self->{output}->output_add( |
| 122 |
severity => 'OK', |
| 123 |
short_msg => 'List filesystems:' |
| 124 |
); |
| 125 |
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); |
| 126 |
$self->{output}->exit(); |
| 127 |
} |
| 128 |
|
| 129 |
sub disco_format { |
| 130 |
my ($self, %options) = @_; |
| 131 |
|
| 132 |
$self->{output}->add_disco_format(elements => [@mapping]); |
| 133 |
} |
| 134 |
|
| 135 |
sub disco_show { |
| 136 |
my ($self, %options) = @_; |
| 137 |
|
| 138 |
my $results = $self->manage_selection(snmp => $options{snmp}); |
| 139 |
foreach (sort keys %$results) { |
| 140 |
$self->{output}->add_disco_entry( |
| 141 |
%{$results->{$_}} |
| 142 |
); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
1; |
| 147 |
|
| 148 |
__END__ |
| 149 |
|
| 150 |
=head1 MODE |
| 151 |
|
| 152 |
List filesystems. |
| 153 |
|
| 154 |
=over 8 |
| 155 |
|
| 156 |
=back |
| 157 |
|
| 158 |
=cut |