| 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::omem::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 |
}; |
| 46 |
|
| 47 |
$self->{components_path} = 'hardware::server::dell::omem::snmp::mode::components'; |
| 48 |
$self->{components_module} = ['chassis', 'health', 'psu', 'temperature']; |
| 49 |
} |
| 50 |
|
| 51 |
sub snmp_execute { |
| 52 |
my ($self, %options) = @_; |
| 53 |
|
| 54 |
$self->{snmp} = $options{snmp}; |
| 55 |
$self->display_system_information(); |
| 56 |
|
| 57 |
push @{$self->{request}}, { oid => '.1.3.6.1.4.1.674.10892.6.3.1' }; |
| 58 |
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); |
| 59 |
} |
| 60 |
|
| 61 |
sub display_system_information { |
| 62 |
my ($self, %options) = @_; |
| 63 |
|
| 64 |
my $oid_dmmProductShortName = '.1.3.6.1.4.1.674.10892.6.1.1.2.0'; |
| 65 |
my $oid_dmmChassisServiceTag = '.1.3.6.1.4.1.674.10892.6.1.1.6.0'; |
| 66 |
my $oid_dmmFirmwareVersion = '.1.3.6.1.4.1.674.10892.6.1.2.1.0'; |
| 67 |
my $oid_dmmFirmwareVersion2 = '.1.3.6.1.4.1.674.10892.6.1.2.2.0'; |
| 68 |
|
| 69 |
my $snmp_result = $self->{snmp}->get_leef(oids => [$oid_dmmProductShortName, $oid_dmmChassisServiceTag, $oid_dmmFirmwareVersion, $oid_dmmFirmwareVersion2]); |
| 70 |
$self->{output}->output_add( |
| 71 |
long_msg => sprintf( |
| 72 |
"Product Name: %s, Service Tag: %s, Firmware Version of MM1: %s, Firmware Version of MM2: %s", |
| 73 |
defined($snmp_result->{$oid_dmmProductShortName}) ? centreon::plugins::misc::trim($snmp_result->{$oid_dmmProductShortName}) : 'unknown', |
| 74 |
defined($snmp_result->{$oid_dmmChassisServiceTag}) ? $snmp_result->{$oid_dmmChassisServiceTag} : 'unknown', |
| 75 |
defined($snmp_result->{$oid_dmmFirmwareVersion}) ? $snmp_result->{$oid_dmmFirmwareVersion} : 'unknown', |
| 76 |
defined($snmp_result->{$oid_dmmFirmwareVersion2}) ? $snmp_result->{$oid_dmmFirmwareVersion2} : 'unknown' |
| 77 |
) |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
sub new { |
| 82 |
my ($class, %options) = @_; |
| 83 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 84 |
bless $self, $class; |
| 85 |
|
| 86 |
$options{options}->add_options(arguments => {}); |
| 87 |
|
| 88 |
return $self; |
| 89 |
} |
| 90 |
|
| 91 |
1; |
| 92 |
|
| 93 |
__END__ |
| 94 |
|
| 95 |
=head1 MODE |
| 96 |
|
| 97 |
Check hardware (health, temperatures, power supplies metrics and chassis metrics). |
| 98 |
|
| 99 |
=over 8 |
| 100 |
|
| 101 |
=item B<--component> |
| 102 |
|
| 103 |
Which component to check (default: '.*'). |
| 104 |
Can be: 'health', 'temperature', 'chassis', 'psu'. |
| 105 |
|
| 106 |
=item B<--filter> |
| 107 |
|
| 108 |
Exclude the items given as a comma-separated list (example: --filter=fan). |
| 109 |
You can also exclude items from specific instances: --filter=health,2 |
| 110 |
|
| 111 |
=item B<--no-component> |
| 112 |
|
| 113 |
Define the expected status if no components are found (default: critical). |
| 114 |
|
| 115 |
=item B<--threshold-overload> |
| 116 |
|
| 117 |
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,status,regexp). |
| 118 |
Example: --threshold-overload='health,CRITICAL,^(?!(ok)$)' |
| 119 |
|
| 120 |
=item B<--warning> |
| 121 |
|
| 122 |
Set warning threshold for temperature (syntax: type,regexp,threshold) |
| 123 |
Example: --warning='temperature,.*,30' |
| 124 |
|
| 125 |
=item B<--critical> |
| 126 |
|
| 127 |
Set critical threshold for temperature (syntax: type,regexp,threshold) |
| 128 |
Example: --critical='temperature,.*,40' |
| 129 |
|
| 130 |
=back |
| 131 |
|
| 132 |
=cut |