| 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::cmc::snmp::mode::hardware; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::hardware); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::misc; |
| 28 |
|
| 29 |
sub set_system { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|psu\.(voltage|power|current)|chassis\.(power|current))$'; |
| 33 |
|
| 34 |
$self->{cb_hook2} = 'snmp_execute'; |
| 35 |
|
| 36 |
$self->{thresholds} = { |
| 37 |
default => [ |
| 38 |
['other', 'UNKNOWN'], |
| 39 |
['unknown', 'UNKNOWN'], |
| 40 |
['ok', 'OK'], |
| 41 |
['nonCritical', 'WARNING'], |
| 42 |
['critical', 'CRITICAL'], |
| 43 |
['nonRecoverable', 'CRITICAL'] |
| 44 |
], |
| 45 |
vdisk => [ |
| 46 |
['online', 'OK'], |
| 47 |
['degraded', 'WARNING'], |
| 48 |
['failed', 'CRITICAL'], |
| 49 |
['unknown', 'UNKNOWN'] |
| 50 |
] |
| 51 |
}; |
| 52 |
|
| 53 |
$self->{components_path} = 'hardware::server::dell::cmc::snmp::mode::components'; |
| 54 |
$self->{components_module} = ['chassis', 'disk', 'health', 'psu', 'temperature', 'vdisk']; |
| 55 |
} |
| 56 |
|
| 57 |
sub snmp_execute { |
| 58 |
my ($self, %options) = @_; |
| 59 |
|
| 60 |
$self->{snmp} = $options{snmp}; |
| 61 |
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); |
| 62 |
$self->display_system_information(); |
| 63 |
} |
| 64 |
|
| 65 |
sub display_system_information { |
| 66 |
my ($self, %options) = @_; |
| 67 |
|
| 68 |
my $oid_drsProductShortName = '.1.3.6.1.4.1.674.10892.2.1.1.2.0'; |
| 69 |
my $oid_drsChassisServiceTag = '.1.3.6.1.4.1.674.10892.2.1.1.6.0'; |
| 70 |
my $oid_drsFirmwareVersion = '.1.3.6.1.4.1.674.10892.2.1.2.1.0'; |
| 71 |
|
| 72 |
my $snmp_result = $self->{snmp}->get_leef(oids => [$oid_drsProductShortName, $oid_drsChassisServiceTag, $oid_drsFirmwareVersion]); |
| 73 |
$self->{output}->output_add( |
| 74 |
long_msg => sprintf("Product Name: %s, Service Tag: %s, Firmware Version: %s", |
| 75 |
defined($snmp_result->{$oid_drsProductShortName}) ? centreon::plugins::misc::trim($snmp_result->{$oid_drsProductShortName}) : 'unknown', |
| 76 |
defined($snmp_result->{$oid_drsChassisServiceTag}) ? $snmp_result->{$oid_drsChassisServiceTag} : 'unknown', |
| 77 |
defined($snmp_result->{$oid_drsFirmwareVersion}) ? $snmp_result->{$oid_drsFirmwareVersion} : 'unknown' |
| 78 |
) |
| 79 |
); |
| 80 |
} |
| 81 |
|
| 82 |
sub new { |
| 83 |
my ($class, %options) = @_; |
| 84 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 85 |
bless $self, $class; |
| 86 |
|
| 87 |
$options{options}->add_options(arguments => {}); |
| 88 |
|
| 89 |
return $self; |
| 90 |
} |
| 91 |
|
| 92 |
1; |
| 93 |
|
| 94 |
__END__ |
| 95 |
|
| 96 |
=head1 MODE |
| 97 |
|
| 98 |
Check hardware. |
| 99 |
|
| 100 |
=over 8 |
| 101 |
|
| 102 |
=item B<--component> |
| 103 |
|
| 104 |
Which component to check (default: '.*'). |
| 105 |
Can be: 'chassis', 'disk', 'health', 'psu', 'temperature', 'vdisk'. |
| 106 |
|
| 107 |
=item B<--filter> |
| 108 |
|
| 109 |
Exclude the items given as a comma-separated list (example: --filter=fan). |
| 110 |
You can also exclude items from specific instances: --filter=health,2 |
| 111 |
|
| 112 |
=item B<--no-component> |
| 113 |
|
| 114 |
Define the expected status if no components are found (default: critical). |
| 115 |
|
| 116 |
=item B<--threshold-overload> |
| 117 |
|
| 118 |
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,status,regexp). |
| 119 |
Example: --threshold-overload='health,CRITICAL,^(?!(ok)$)' |
| 120 |
|
| 121 |
=item B<--warning> |
| 122 |
|
| 123 |
Set warning threshold for temperatures (syntax: type,regexp,threshold) |
| 124 |
Example: --warning='temperature,.*,30' |
| 125 |
|
| 126 |
=item B<--critical> |
| 127 |
|
| 128 |
Set critical threshold for temperatures (syntax: type,regexp,threshold) |
| 129 |
Example: --critical='temperature,.*,40' |
| 130 |
|
| 131 |
=back |
| 132 |
|
| 133 |
=cut |