| 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 hardware::server::dell::idrac::snmp::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->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|voltage|amperage|coolingdevice)$'; |
| 32 |
|
| 33 |
$self->{cb_hook2} = 'snmp_execute'; |
| 34 |
|
| 35 |
$self->{thresholds} = { |
| 36 |
'default.state' => [ |
| 37 |
['unknown', 'UNKNOWN'], |
| 38 |
['enabled', 'OK'], |
| 39 |
['notReady', 'WARNING'], |
| 40 |
['enabledAndNotReady', 'WARNING'] |
| 41 |
], |
| 42 |
'default.status' => [ |
| 43 |
['other', 'UNKNOWN'], |
| 44 |
['unknown', 'UNKNOWN'], |
| 45 |
['ok', 'OK'], |
| 46 |
['nonCritical', 'WARNING'], |
| 47 |
['critical', 'CRITICAL'], |
| 48 |
['nonRecoverable', 'CRITICAL'] |
| 49 |
], |
| 50 |
'probe.status' => [ |
| 51 |
['other', 'UNKNOWN'], |
| 52 |
['unknown', 'UNKNOWN'], |
| 53 |
['ok', 'OK'], |
| 54 |
['nonCriticalUpper', 'WARNING'], |
| 55 |
['criticalUpper', 'CRITICAL'], |
| 56 |
['nonRecoverableUpper', 'CRITICAL'], |
| 57 |
['nonCriticalLower', 'WARNING'], |
| 58 |
['criticalLower', 'CRITICAL'], |
| 59 |
['nonRecoverableLower', 'CRITICAL'], |
| 60 |
['failed', 'CRITICAL'] |
| 61 |
], |
| 62 |
'pdisk.state' => [ |
| 63 |
['unknown', 'UNKNOWN'], |
| 64 |
['readySpareDedicated', 'OK'], |
| 65 |
['readySpareGlobal', 'OK'], |
| 66 |
['ready', 'WARNING'], |
| 67 |
['online', 'OK'], |
| 68 |
['foreign', 'OK'], |
| 69 |
['offline', 'WARNING'], |
| 70 |
['blocked', 'WARNING'], |
| 71 |
['failed', 'CRITICAL'], |
| 72 |
['non-raid', 'OK'], |
| 73 |
['removed', 'OK'], |
| 74 |
['readonly', 'WARNING'] |
| 75 |
], |
| 76 |
'enclosure.state' => [ |
| 77 |
['unknown', 'UNKNOWN'], |
| 78 |
['ready', 'OK'], |
| 79 |
['failed', 'CRITICAL'], |
| 80 |
['missing', 'WARNING'], |
| 81 |
['degraded', 'WARNING'] |
| 82 |
], |
| 83 |
'pdisk.smartalert' => [ |
| 84 |
['off', 'OK'], |
| 85 |
['on', 'WARNING'] |
| 86 |
], |
| 87 |
'vdisk.state' => [ |
| 88 |
['unknown', 'UNKNOWN'], |
| 89 |
['online', 'OK'], |
| 90 |
['failed', 'CRITICAL'], |
| 91 |
['degraded', 'WARNING'] |
| 92 |
] |
| 93 |
}; |
| 94 |
|
| 95 |
$self->{components_path} = 'hardware::server::dell::idrac::snmp::mode::components'; |
| 96 |
$self->{components_module} = [ |
| 97 |
'amperage', 'coolingdevice', 'coolingunit', 'enclosure', 'health', |
| 98 |
'fru', 'memory', 'network', 'pci', 'pdisk', |
| 99 |
'processor', 'psu', 'punit', 'slot', 'storagebattery', |
| 100 |
'storagectrl', 'systembattery', 'temperature', 'voltage', 'vdisk' |
| 101 |
]; |
| 102 |
} |
| 103 |
|
| 104 |
my $oid_chassisName = '.1.3.6.1.4.1.674.10892.5.4.300.10.1.7'; |
| 105 |
|
| 106 |
sub snmp_execute { |
| 107 |
my ($self, %options) = @_; |
| 108 |
|
| 109 |
$self->{snmp} = $options{snmp}; |
| 110 |
push @{$self->{request}}, { oid => $oid_chassisName }; |
| 111 |
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); |
| 112 |
} |
| 113 |
|
| 114 |
sub get_chassis_name { |
| 115 |
my ($self, %options) = @_; |
| 116 |
|
| 117 |
my $name = 'unknown'; |
| 118 |
if (defined($self->{results}->{$oid_chassisName}->{ $oid_chassisName . '.' . $options{id} })) { |
| 119 |
$name = $self->{results}->{$oid_chassisName}->{ $oid_chassisName . '.' . $options{id} } |
| 120 |
} |
| 121 |
|
| 122 |
return $name; |
| 123 |
} |
| 124 |
|
| 125 |
sub get_chassis_instances { |
| 126 |
my ($self, %options) = @_; |
| 127 |
|
| 128 |
my $instances = []; |
| 129 |
foreach (keys %{$self->{results}->{$oid_chassisName}}) { |
| 130 |
/\.(\d+)$/; |
| 131 |
push @$instances, $1; |
| 132 |
} |
| 133 |
|
| 134 |
return $instances; |
| 135 |
} |
| 136 |
|
| 137 |
sub new { |
| 138 |
my ($class, %options) = @_; |
| 139 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 140 |
bless $self, $class; |
| 141 |
|
| 142 |
$options{options}->add_options(arguments => {}); |
| 143 |
|
| 144 |
return $self; |
| 145 |
} |
| 146 |
|
| 147 |
1; |
| 148 |
|
| 149 |
__END__ |
| 150 |
|
| 151 |
=head1 MODE |
| 152 |
|
| 153 |
Check hardware components. |
| 154 |
|
| 155 |
=over 8 |
| 156 |
|
| 157 |
=item B<--component> |
| 158 |
|
| 159 |
Which component to check (default: '.*'). |
| 160 |
Can be: 'amperage', 'coolingdevice', 'coolingunit', 'enclosure', |
| 161 |
'health', 'fru', 'memory', 'network', 'pci', 'pdisk', |
| 162 |
'processor', 'psu', 'punit', 'slot', 'storagebattery', |
| 163 |
'storagectrl', 'systembattery', 'temperature', 'voltage', 'vdisk'. |
| 164 |
|
| 165 |
=item B<--filter> |
| 166 |
|
| 167 |
Exclude the items given as a comma-separated list (example: --filter=temperature --filter=psu). |
| 168 |
You can also exclude items from specific instances: --filter=temperature,1.1 |
| 169 |
|
| 170 |
=item B<--add-name-instance> |
| 171 |
|
| 172 |
Add literal description for instance value (used in filter and threshold options). |
| 173 |
|
| 174 |
=item B<--no-component> |
| 175 |
|
| 176 |
Define the expected status if no components are found (default: critical). |
| 177 |
|
| 178 |
=item B<--threshold-overload> |
| 179 |
|
| 180 |
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp). |
| 181 |
Example: --threshold-overload='temperature.state,CRITICAL,^(?!(enabled)$)' |
| 182 |
|
| 183 |
=item B<--warning> |
| 184 |
|
| 185 |
Set warning threshold (syntax: type,regexp,threshold) |
| 186 |
Example: --warning='temperature,.*,30' |
| 187 |
|
| 188 |
=item B<--critical> |
| 189 |
|
| 190 |
Set critical threshold (syntax: type,regexp,threshold) |
| 191 |
Example: --critical='temperature,.*,40' |
| 192 |
|
| 193 |
=back |
| 194 |
|
| 195 |
=cut |