| 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 centreon::common::cisco::standard::snmp::mode::environment; |
| 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|voltage|sensor.*)$'; |
| 33 |
|
| 34 |
$self->{cb_hook2} = 'snmp_execute'; |
| 35 |
|
| 36 |
$self->{thresholds} = { |
| 37 |
fan => [ |
| 38 |
['normal', 'OK'], |
| 39 |
['warning', 'WARNING'], |
| 40 |
['critical', 'CRITICAL'], |
| 41 |
['shutdown', 'CRITICAL'], |
| 42 |
['not present', 'OK'], |
| 43 |
['not functioning', 'WARNING'], |
| 44 |
|
| 45 |
['unknown', 'UNKNOWN'], |
| 46 |
['down', 'CRITICAL'], |
| 47 |
['up', 'OK'] |
| 48 |
], |
| 49 |
psu => [ |
| 50 |
['normal', 'OK'], |
| 51 |
['warning', 'WARNING'], |
| 52 |
['critical', 'CRITICAL'], |
| 53 |
['shutdown', 'CRITICAL'], |
| 54 |
['not present', 'OK'], |
| 55 |
['not functioning', 'WARNING'], |
| 56 |
|
| 57 |
['^off*', 'WARNING'], |
| 58 |
['failed', 'CRITICAL'], |
| 59 |
['onButFanFail|onButInlinePowerFail', 'WARNING'], |
| 60 |
['on', 'OK'] |
| 61 |
], |
| 62 |
temperature => [ |
| 63 |
['normal', 'OK'], |
| 64 |
['warning', 'WARNING'], |
| 65 |
['critical', 'CRITICAL'], |
| 66 |
['shutdown', 'CRITICAL'], |
| 67 |
['not present', 'OK'], |
| 68 |
['not functioning', 'WARNING'] |
| 69 |
], |
| 70 |
voltage => [ |
| 71 |
['normal', 'OK'], |
| 72 |
['warning', 'WARNING'], |
| 73 |
['critical', 'CRITICAL'], |
| 74 |
['shutdown', 'CRITICAL'], |
| 75 |
['not present', 'OK'], |
| 76 |
['not functioning', 'WARNING'] |
| 77 |
], |
| 78 |
module => [ |
| 79 |
['unknown|mdr', 'UNKNOWN'], |
| 80 |
['disabled|okButDiagFailed|missing|mismatchWithParent|mismatchConfig|dormant|outOfServiceAdmin|outOfServiceEnvTemp|powerCycled|okButPowerOverWarning|okButAuthFailed|fwMismatchFound|fwDownloadFailure', 'WARNING'], |
| 81 |
['failed|diagFailed|powerDenied|okButPowerOverCritical', 'CRITICAL'], |
| 82 |
['boot|selfTest|poweredUp|syncInProgress|upgrading|fwDownloadSuccess|ok|poweredDown', 'OK'] |
| 83 |
], |
| 84 |
physical => [ |
| 85 |
['other', 'UNKNOWN'], |
| 86 |
['incompatible|unsupported', 'CRITICAL'], |
| 87 |
['supported', 'OK'] |
| 88 |
], |
| 89 |
sensor => [ |
| 90 |
['ok', 'OK'], |
| 91 |
['unavailable', 'OK'], |
| 92 |
['nonoperational', 'CRITICAL'] |
| 93 |
] |
| 94 |
}; |
| 95 |
|
| 96 |
$self->{components_path} = 'centreon::common::cisco::standard::snmp::mode::components'; |
| 97 |
$self->{components_module} = ['fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor']; |
| 98 |
} |
| 99 |
|
| 100 |
my $oid_ciscoEnvMonPresent = '.1.3.6.1.4.1.9.9.13.1.1'; |
| 101 |
|
| 102 |
my %map_type_mon = ( |
| 103 |
1 => 'oldAgs', |
| 104 |
2 => 'ags', |
| 105 |
3 => 'c7000', |
| 106 |
4 => 'ci', |
| 107 |
6 => 'cAccessMon', |
| 108 |
7 => 'cat6000', |
| 109 |
8 => 'ubr7200', |
| 110 |
9 => 'cat4000', |
| 111 |
10 => 'c10000', |
| 112 |
11 => 'osr7600', |
| 113 |
12 => 'c7600', |
| 114 |
13 => 'c37xx', |
| 115 |
14 => 'other' |
| 116 |
); |
| 117 |
|
| 118 |
sub snmp_execute { |
| 119 |
my ($self, %options) = @_; |
| 120 |
|
| 121 |
$self->{snmp} = $options{snmp}; |
| 122 |
$self->{physical_name} = defined($self->{option_results}->{use_physical_name}) ? '.1.3.6.1.2.1.47.1.1.1.1.7' : '.1.3.6.1.2.1.47.1.1.1.1.2'; |
| 123 |
|
| 124 |
push @{$self->{request}}, { oid => $self->{physical_name} }, { oid => $oid_ciscoEnvMonPresent }; |
| 125 |
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); |
| 126 |
while (my ($key, $value) = each %{$self->{results}->{ $self->{physical_name} }}) { |
| 127 |
$self->{results}->{ $self->{physical_name} }->{$key} = centreon::plugins::misc::trim($value); |
| 128 |
} |
| 129 |
$self->{output}->output_add( |
| 130 |
long_msg => sprintf( |
| 131 |
'Environment type: %s', |
| 132 |
defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ? |
| 133 |
$map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} : 'unknown' |
| 134 |
) |
| 135 |
); |
| 136 |
} |
| 137 |
|
| 138 |
sub new { |
| 139 |
my ($class, %options) = @_; |
| 140 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 141 |
bless $self, $class; |
| 142 |
|
| 143 |
$options{options}->add_options(arguments => { |
| 144 |
'use-physical-name' => { name => 'use_physical_name' }, |
| 145 |
'add-fru-power' => { name => 'add_fru_power' } |
| 146 |
}); |
| 147 |
|
| 148 |
return $self; |
| 149 |
} |
| 150 |
|
| 151 |
1; |
| 152 |
|
| 153 |
__END__ |
| 154 |
|
| 155 |
=head1 MODE |
| 156 |
|
| 157 |
Check environment (Power Supplies, Fans, Temperatures, Voltages, Modules, Physical Entities). |
| 158 |
|
| 159 |
=over 8 |
| 160 |
|
| 161 |
=item B<--component> |
| 162 |
|
| 163 |
Which component to check (default: '.*'). |
| 164 |
Can be: 'fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'. |
| 165 |
|
| 166 |
=item B<--filter> |
| 167 |
|
| 168 |
Exclude the items given as a comma-separated list (example: --filter=fan --filter=psu). |
| 169 |
You can also exclude items from specific instances: --filter=fan,1 |
| 170 |
|
| 171 |
=item B<--add-name-instance> |
| 172 |
|
| 173 |
Add literal description for instance value (used in filter, absent-problem and threshold options). |
| 174 |
|
| 175 |
=item B<--use-physical-name> |
| 176 |
|
| 177 |
Use entPhysicalName OID instead of entPhysicalDescr. |
| 178 |
|
| 179 |
=item B<--add-fru-power> |
| 180 |
|
| 181 |
Check FRU power status. |
| 182 |
|
| 183 |
=item B<--absent-problem> |
| 184 |
|
| 185 |
Return an error if an entity is not 'present' (default is skipping) (comma separated list) |
| 186 |
Can be specific or global: --absent-problem=fan,1 |
| 187 |
|
| 188 |
=item B<--no-component> |
| 189 |
|
| 190 |
Define the expected status if no components are found (default: critical). |
| 191 |
|
| 192 |
|
| 193 |
=item B<--threshold-overload> |
| 194 |
|
| 195 |
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,status,regexp). |
| 196 |
Example: --threshold-overload='fan,CRITICAL,^(?!(up|normal)$)' |
| 197 |
|
| 198 |
=item B<--warning> |
| 199 |
|
| 200 |
Set warning threshold for temperatures, voltages, sensors (syntax: type,regexp,threshold) |
| 201 |
Example: --warning='temperature,.*,30' |
| 202 |
|
| 203 |
=item B<--critical> |
| 204 |
|
| 205 |
Set critical threshold for temperatures, voltages, sensors (syntax: type,regexp,threshold) |
| 206 |
Example: --critical='temperature,.*,40' |
| 207 |
|
| 208 |
=back |
| 209 |
|
| 210 |
=cut |