From b9e4f706b1406d5b15fdf6d5f0d663036357f439 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 28 Apr 2020 10:59:58 +0200 Subject: [PATCH] adva fsp150 wip --- network/adva/fsp150/snmp/mode/alarms.pm | 326 --------------- .../adva/fsp150/snmp/mode/components/card.pm | 106 +++++ .../fsp150/snmp/mode/components/resources.pm | 123 ++++++ .../adva/fsp150/snmp/mode/components/shelf.pm | 116 ++++++ network/adva/fsp150/snmp/mode/hardware.pm | 108 +++++ network/adva/fsp150/snmp/mode/interfaces.pm | 370 ------------------ .../adva/fsp150/snmp/mode/listinterfaces.pm | 160 -------- network/adva/fsp150/snmp/plugin.pm | 10 +- 8 files changed, 457 insertions(+), 862 deletions(-) delete mode 100644 network/adva/fsp150/snmp/mode/alarms.pm create mode 100644 network/adva/fsp150/snmp/mode/components/card.pm create mode 100644 network/adva/fsp150/snmp/mode/components/resources.pm create mode 100644 network/adva/fsp150/snmp/mode/components/shelf.pm create mode 100644 network/adva/fsp150/snmp/mode/hardware.pm delete mode 100644 network/adva/fsp150/snmp/mode/interfaces.pm delete mode 100644 network/adva/fsp150/snmp/mode/listinterfaces.pm diff --git a/network/adva/fsp150/snmp/mode/alarms.pm b/network/adva/fsp150/snmp/mode/alarms.pm deleted file mode 100644 index 7bbd27ee7..000000000 --- a/network/adva/fsp150/snmp/mode/alarms.pm +++ /dev/null @@ -1,326 +0,0 @@ -# -# Copyright 2020 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package network::adva::fsp150::snmp::mode::alarms; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use centreon::plugins::misc; -use centreon::plugins::statefile; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); - -sub custom_status_output { - my ($self, %options) = @_; - - my $msg = sprintf("alarm %s [severity: %s] [type: %s] %s", $self->{result_values}->{label}, $self->{result_values}->{severity}, - $self->{result_values}->{type}, $self->{result_values}->{generation_time}); - return $msg; -} - -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - $self->{result_values}->{severity} = $options{new_datas}->{$self->{instance} . '_severity'}; - $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; - $self->{result_values}->{generation_time} = $options{new_datas}->{$self->{instance} . '_generation_time'}; - $self->{result_values}->{label} = $options{new_datas}->{$self->{instance} . '_label'}; - return 0; -} - - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { label => 'alerts', min => 0 }, - group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ] - } - ]; - - $self->{maps_counters}->{alarm} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'severity' }, { name => 'type' }, { name => 'label'}, { name => 'since' }, { name => 'generation_time' } ], - closure_custom_calc => $self->can('custom_status_calc'), - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, - } - }, - ]; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning-status:s" => { name => 'warning_status', default => '%{severity} =~ /warning|minor/i' }, - "critical-status:s" => { name => 'critical_status', default => '%{severity} =~ /critical|major/i' }, - "memory" => { name => 'memory' }, - "timezone:s" => { name => 'timezone' }, - }); - - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime', - error_msg => "Cannot load module 'DateTime'."); - $self->{statefile_cache} = centreon::plugins::statefile->new(%options); - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_status', 'critical_status']); - if (defined($self->{option_results}->{memory})) { - $self->{statefile_cache}->check_options(%options); - } - - $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); -} - -my %map_type = ( - 0 => 'undefined', 5 => 'terminalLoopback', 6 => 'oosDisabled', 7 => 'oosManagement', 8 => 'oosMaintenance', 9 => 'oosAins', 10 => 'removed', - 11 => 'lossOfSignal', 12 => 'optInputPwrReceivedTooLow', 13 => 'optInputPwrReceivedTooHigh', 14 => 'laserTemperatureTooHigh', 15 => 'laserTemperatureTooLow', 16 => 'optOutputPowerTransTooLow', 17 => 'optOutputPowerTransTooHigh', - 18 => 'autoShutdownToHighTemp', 19 => 'autoShutdownToHighTxPwr', 20 => 'laserEndOfLife', 21 => 'serverSignalFailureVf', 22 => 'equalizationProgress', - 23 => 'uPortFailure', 24 => 'autoShutdownBlock', 25 => 'autoPowerShutdown', 26 => 'confOutPowerTransTooHigh', 27 => 'confOutPowerTransTooLow', - 28 => 'optSignalFailure', 29 => 'dsbdChannelPowerTooHigh', 30 => 'lossOfSignalCPort', 31 => 'lossOfSignalNPort', 32 => 'outputPowerFault', - 33 => 'eqlzAdjust', 34 => 'ampFailure', 35 => 'eqptProvMismatch', 36 => 'backreflectionTooHigh', 48 => 'fiberConnLos', 49 => 'fiberConnOptFault', - 50 => 'fiberConnInvalid', 51 => 'fiberConnMismatch', 52 => 'fiberConnCommError', 53 => 'fiberConnProtocolFailure', 54 => 'fiberConnDataFailure', - 55 => 'fiberAttenuationHigh', 57 => 'laserBiasCurrAbnormal', 58 => 'fiberConnInvalidTx', 59 => 'fiberConnMismatchTx', 60 => 'fiberAttenuationHighTx', - 61 => 'laserFailure', 62 => 'lossOfReceiverClockRecovery', 63 => 'fiberAttenuationCond', 64 => 'channelMismatch', 65 => 'alarmIndicationSignalLine', - 66 => 'alarmIndicationSignalLowerOrderPath', 67 => 'alarmIndicationSignalOdu', 68 => 'alarmIndicationSignalOpu', 69 => 'alarmIndicationSignalOtu', - 70 => 'alarmIndicationSignalHigherOrderPath', 71 => 'alarmIndicationSignalOduTcmA', 72 => 'alarmIndicationSignalOduTcmB', 73 => 'alarmIndicationSignalOduTcmC', 74 => 'virtualChannelAis', - 75 => 'amplifierAbnormal', 76 => 'automaticPowerReduction', 77 => 'automaticPowerReductionForEyeSafety', 80 => 'apsConfigMismatch', 81 => 'apsProtocolFailure', 82 => 'aseLow', - 83 => 'aseTableGenFailLow', 84 => 'aseTableGenFailHighBackreflection', 85 => 'aseTableGenFailOscMissing', 86 => 'aseTableGenFailPilot', 87 => 'aseTableGenFailSignalinput', - 88 => 'aseTableNotAvailable', 89 => 'aseTableGenProgress', 90 => 'encryptionPortAuthPasswdMissing', 92 => 'backwardDefectIndicationOdu', 93 => 'backwardDefectIndicationOtu', - 94 => 'backwardDefectIndicationOduTcmA', 95 => 'backwardDefectIndicationOduTcmB', 96 => 'backwardDefectIndicationOduTcmC', 97 => 'topologyDataCalculationInProgress', 99 => 'dispertionTunningCondition', 100 => 'lossOfCharSync', - 101 => 'lossOfCharSyncFromFarEnd', 103 => 'encryptionPortEncryptionSwitchOffEnabled', 104 => 'encryptionModuleCryPasswdMissing', 107 => 'encryptionModuleSelfTestStarted', 108 => 'encryptionPortEncryptionSwitchedOff', 109 => 'opuClientSignalFail', - 110 => 'databaseMismatch', 111 => 'databaseFailure', 112 => 'databaseNcuMismatch', 113 => 'dbReplicationIncompleted', 114 => 'databaseVersionMismatch', 115 => 'xfpDecisionThresSetFailed', 116 => 'duplexLinkFailure', 118 => 'singleFanFailure', - 119 => 'multipleFanFailure', 120 => 'lossOfSignalTransmitter', 122 => 'farEndIpAddressUnknown', 123 => 'farEndCommFailure', 125 => 'backupForcedToHalt', 127 => 'facilityForcedOn', 128 => 'fwdAseTableFailPilot', 129 => 'fwdAseTableOnPilot', - 131 => 'encryptionModuleFwpUpdateEnabled', 132 => 'fwpMismatchDownloadNotServiceAffecting', 133 => 'fwpMismatchDownloadServiceAffecting', 135 => 'gainTiltNotSettable', 136 => 'highBer', 137 => 'receiverOverloadProtection', 138 => 'hwInitializing', 139 => 'hwOprReachedHT', - 140 => 'hwDegrade', 141 => 'hwFailure', 142 => 'switchtoProtectionInhibited', 143 => 'switchtoWorkingInhibited', 148 => 'encryptionPortKeyInitExchgMissed', 149 => 'encryptionPortMaxKeyExchgFailuresReachedIs', 150 => 'encryptionPortMaxKeyExchgFailuresReachedOos', - 151 => 'encryptionPortKeyExchangedForced', 152 => 'laserOnDelay', 153 => 'lockedDefectOdu', 154 => 'lockedDefectOduTcmA', 155 => 'lockedDefectOduTcmB', 156 => 'lockedDefectOduTcmC', 157 => 'linkControlProtocolFailure', 158 => 'linkDown', 159 => 'autoShutdownSendingAisLine', - 160 => 'autoShutdownSendingAisOdu', 161 => 'autoShutdownSendingAisOpu', 162 => 'clientFailForwarding', 163 => 'autoShutdownAls', 164 => 'autoAmpShutdown', 165 => 'autoShutdownAmpAps', 166 => 'aseTableBuild', 167 => 'autoShutdownOpuClientSignalFail', 168 => 'autoShutdownSendingEPC', - 169 => 'autoShutdownSendingLckOdu', 170 => 'autoShutdownSendingOciOdu', 171 => 'autoShutdownLaserOffDueToErrFwd', 172 => 'autoShutdownTxRxLasersDueToHighTemp', 173 => 'localFault', 174 => 'localOscLevelAbnormal', 175 => 'lossOfGfpFrame', 176 => 'lossOfFrameMux', 177 => 'lossOfFrameOtu', - 178 => 'lossOfFrame', 179 => 'lossOfFrameLossOfMultiFrameOdu', 180 => 'lossOfLane', 181 => 'lossofMultiframeLowerOrderPath', 182 => 'lossOfMultiFrameOtu', 183 => 'lossofMultiframeHigherOrderPath', 184 => 'lossOfPointerLowerOrderPath', 185 => 'lossOfPointerHigherOrderPath', - 186 => 'losAttProgress', 187 => 'lossOsc', 188 => 'gfpLossOfClientSig', 189 => 'loopbackError', 190 => 'facilityLoopback', 191 => 'lossofTandemConnectionOduTcmA', 192 => 'lossofTandemConnectionOduTcmB', 193 => 'lossofTandemConnectionOduTcmC', 194 => 'mansw', 197 => 'equipmentNotAccepted', 198 => 'equipmentNotApproved', 199 => 'capabilityLevelMismatch', - 200 => 'equipmentMismatch', 201 => 'equipmentNotSupportedByPhysicalLayer', 202 => 'meaSwRevision', 203 => 'mismatch', 204 => 'midstageFault', 205 => 'multiplexStructureIdentifierMismatchOPU', 206 => 'backupNotResponding', 207 => 'openConnectionIndicationOdu', - 208 => 'openConnectionIndicationOduTcmA', 209 => 'openConnectionIndicationOduTcmB', 210 => 'openConnectionIndicationOduTcmC', 211 => 'oduTribMsiMismatch', 212 => 'transmitterDisabledOff', 213 => 'receiverDisabled', 214 => 'opmAbnormalCondition', 215 => 'faultOnOpm', 216 => 'thresOptPowerCtrlFailureHigh', - 217 => 'thresOptPowerCtrlFailureLow', 218 => 'txPowerLimited', 219 => 'oscOpticalPowerControlFailHigh', 220 => 'oscOpticalPowerControlFailLow', 221 => 'oTDRMeasuringinProgress', 222 => 'encryptionModuleCryPasswdError', 223 => 'peerLink', 224 => 'pilotReceiveLevelHigh', - 225 => 'lossOfPilotSignal', 226 => 'payloadMismatchGfp', 227 => 'payloadMismatchLowerOrderPath', 228 => 'payloadMismatchOPU', 229 => 'payloadMismatchHigherOrderPath', 230 => 'provPayloadMismatch', 231 => 'prbsLossOfSeqSynch', 232 => 'prbsRcvActivated', 233 => 'prbsTrmtActivated', 234 => 'protectionNotAvailable', 235 => 'powerSupplyUnitFailure', 236 => 'maxPowerConsProvModulesToHigh', - 237 => 'maxPowerConsEquipModulesToHigh', 238 => 'powerMissing', 239 => 'remoteDefectIndicationLine', 240 => 'remoteDefectIndicationLowerOrderPath', 241 => 'remoteDefectIndicationHigherOrderPath', 243 => 'dcnCommunicationFail', 244 => 'ntpForSchedEqlzRequired', 245 => 'signalDegradeOlm', 246 => 'signalDegradeLine', 247 => 'signalDegradationonLinkVector', - 248 => 'signalDegradeOdu', 249 => 'signalDegradeOtu', 250 => 'pcsSignalDegrade', 251 => 'signalDegradeScn', 252 => 'signalDegradeOduTcmA', 253 => 'signalDegradeOduTcmB', 254 => 'signalDegradeOduTcmC', 255 => 'encryptionModuleSelfTestFail', 256 => 'encryptionModuleSelfTestFailCritical', - 257 => 'signalFailureOnLink', 258 => 'signalFailureonLinkVector', 259 => 'signalFailureOPU', 260 => 'serverSignalFailTx', 261 => 'facilityDataRateNotSupported', 263 => 'lossofSequenceLowerOrderPath', 264 => 'lossofSequenceHigherOrderPath', 265 => 'serverSignalFail', 266 => 'serverSignalFailureGfp', - 267 => 'serverSignalFailureODU', 268 => 'serverSignalFailurePath', 269 => 'serverSignalFailureSectionRS', 272 => 'switchToDuplexInhibited', 274 => 'switchFailed', 276 => 'currentTooHigh', 277 => 'attOnReceiverFiberHigherThanMonitor', 278 => 'attOnReceiverFiberLowerThanMonitor', 279 => 'attOnTransmitterFiberHigherThanMonitor', - 280 => 'attOnTransmitterFiberLowerThanMonitor', 281 => 'thres15MinExceededOduBbe', 283 => 'thres15MinExceededOtuBbe', 285 => 'thres15MinExceededOduTcmABbe', 287 => 'thres15MinExceededOduTcmBBbe', 289 => 'thres15MinExceededOduTcmCBbe', 291 => 'thres15MinExceededFecBERCE', 293 => 'brPwrRxTooHigh', 294 => 'chromaticDispersionTooHigh', - 295 => 'chromaticDispersionTooLow', 296 => 'dispersionCompensationTooHigh', 297 => 'dispersionCompensationTooLow', 298 => 'thres15MinExceededFecCE', 300 => 'carrierFreqOffsetTooHigh', 301 => 'carrierFreqOffsetTooLow', 302 => 'thres15MinExceededSonetLineCV', 304 => 'thres15MinExceededPhysConvCV', - 306 => 'thres15MinExceededSonetSectCV', 308 => 'thres15MinExceededPhysConvDE', 310 => 'differentialGroupDelayTooHigh', 311 => 'thres15MinExceededFecES', 313 => 'thres15MinExceededSonetLineES', 315 => 'thres15MinExceededOduES', 317 => 'thres15MinExceededOtuES', - 319 => 'thres15MinExceededPhysConvES', 321 => 'thres15MinExceededSonetSectES', 323 => 'thres15MinExceededOduTcmAES', 325 => 'thres15MinExceededOduTcmBES', 327 => 'thres15MinExceededOduTcmCES', 329 => 'latencyTooHigh', 330 => 'latencyTooLow', 331 => 'laserBiasCurrentNormalizedtooHigh', 332 => 'localOscTemperatureTooHigh', 333 => 'localOscTemperatureTooLow', - 334 => 'pumpLaser1TempTooHigh', 335 => 'pumpLaser1TempTooLow', 336 => 'pumpLaser2TempTooHigh', 337 => 'pumpLaser2TempTooLow', 338 => 'pumpLaser3TempTooHigh', 339 => 'pumpLaser3TempTooLow', 340 => 'pumpLaser4TempTooHigh', 341 => 'pumpLaser4TempTooLow', 342 => 'oscPwrTooHigh', - 343 => 'oscPwrTooLow', 344 => 'ramanPumpPwrTooHigh', 345 => 'ramanPumpPwrTooLow', 346 => 'roundTripDelayTooHigh', 347 => 'roundTripDelayTooLow', 348 => 'thres15MinExceededSonetSectSEFS', 350 => 'thres15MinExceededFecSES', 352 => 'thres15MinExceededSonetLineSES', - 354 => 'thres15MinExceededOduSES', 356 => 'thres15MinExceededOtuSES', 358 => 'thres15MinExceededSonetSectSES', 360 => 'thres15MinExceededOduTcmASES', 362 => 'thres15MinExceededOduTcmBSES', 364 => 'thres15MinExceededOduTcmCSES', 366 => 'logicalLanesSkewTooHigh', - 367 => 'signalToNoiseRatioTooLow', 368 => 'subModuleTempTooHigh', 369 => 'temperatureTooHigh', 370 => 'temperatureTooLow', 371 => 'thres15MinExceededSonetLineUAS', 373 => 'thres15MinExceededOduUAS', 375 => 'thres15MinExceededOtuUAS', - 377 => 'thres15MinExceededOduTcmAUAS', 379 => 'thres15MinExceededOduTcmBUAS', 381 => 'thres15MinExceededOduTcmCUAS', 383 => 'thres15MinExceededFecUBE', 385 => 'encryptionModuleTamperDetected', 386 => 'thermoElectricCoolerEndOfLife', 387 => 'alarmInputTIF', 389 => 'traceIdentifierMismatchOdu', - 390 => 'traceIdentifierMismatchOtu', 391 => 'sectionTraceMismatch', 392 => 'traceIdentifierMismatchOduTcmA', 393 => 'traceIdentifierMismatchOduTcmB', 394 => 'traceIdentifierMismatchOduTcmC', 395 => 'turnupFailed', 396 => 'turnupCondition', 397 => 'unequippedLowerOrderPath', 398 => 'unequippedHigherOrderPath', 399 => 'voaControlFail', 400 => 'voltageOutOfRange', 401 => 'inputVoltageFailure', 402 => 'inputVoltageFailurePort1', - 403 => 'inputVoltageFailurePort2', 406 => 'wtrTimerRunning', 407 => 'lossOfLaneOtu', 408 => 'lossOfTestSeqSynchOpu', 409 => 'lossOfMfiOpu', 410 => 'oosDisabledLckOduTrmt', 411 => 'configurationMismatch', 412 => 'oduAutoShutdownRxAIS', 413 => 'oduAutoShutdownTxAIS', 414 => 'oosDisabledLckOduRx', 420 => 'thres15MinExceededBbePcs', - 422 => 'autoShutdownGAis', 423 => 'equipmentMismatchAllow', 424 => 'warmUp', 432 => 'networkPathRestricted', 434 => 'vfClientSignalFail', 435 => 'autoShutdownVfCSF', 439 => 'linkFailToPartner1', 440 => 'linkFailToPartner2', 441 => 'linkFailToPartner3', 442 => 'linkFailToPartner4', 443 => 'partnerUnavailable', - 445 => 'partner1Deleted', 446 => 'partner2Deleted', 447 => 'partner3Deleted', 448 => 'partner4Deleted', 450 => 'thres15MinExceededPhysConvSE', 452 => 'thres15MinExceededPhysConvCVDE', 456 => 'autoShutdownSendingOciOduTx', 457 => 'acpLinkLoss', 458 => 'acpChannelUnAvail', 459 => 'acpPartnerUnassigned', 460 => 'acpPartnerDeleted', 461 => 'thres15MinExceededCrcErrorsRcv', 463 => 'thres15MinExceededCrcFramesEgress', - 465 => 'autoServiceMismatch', 466 => 'batteryNoCharge', 469 => 'tagReceiveFail', 470 => 'tagReceiveFailMaxReached', 473 => 'internalEncryptionFail', 13006 => 'cfmRemoteDefectIndication', 13007 => 'cfmCcmMacStatus', 13008 => 'cfmCcmError', 13009 => 'cfmCcmLost', 13010 => 'cfmCcmXConn', 100005 => 'mepNotPresentL2', 100006 => 'priVidNotEqualExtVidL2', 100009 => 'sfCfmLevel0L2', 100010 => 'sfCfmLevel1L2', 100011 => 'sfCfmLevel2L2', - 100012 => 'sfCfmLevel3L2', 100013 => 'sfCfmLevel4L2 ', 100014 => 'sfCfmLevel5L2', 100015 => 'sfCfmLevel6L2', 100016 => 'sfCfmLevel7L2', 120004 => 'messageLossSpeq', 120005 => 'oscFiberMissingSpeq', 120006 => 'optLowSpeq', 120007 => 'ppcOutOfRangeSpeq', 120008 => 'gainTooHighSpeq', 120009 => 'gainTooLowSpeq', 120010 => 'gainAdoptFailedSpeq', 120011 => 'processLockedOutSpeq', 120012 => 'ppcLimitExceededSpeq', -); -my %map_severity = (1 => 'indeterminate', 2 => 'critical', 3 => 'major', 4 => 'minor', 5 => 'warning', 6 => 'cleared', 7 => 'notReported'); - -my $oids = { - alarmSysTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.1', label => 'sys', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.1.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.1.1.4' }, - } - }, - alarmEqptTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.5', label => 'eqpt', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.5.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.5.1.4' }, - } - }, - alarmFacilityTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.7', label => 'facility', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.7.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.7.1.4' }, - } - }, - alarmTerminPointTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.9', label => 'terminpoint', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.9.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.9.1.4' }, - } - }, - alarmExternalPortTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.11', label => 'externalport', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.11.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.11.1.4' }, - } - }, - alarmDcnTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.16', label => 'dcn', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.16.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.16.1.4' }, - } - }, - alarmEnvTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.20', label => 'env', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.20.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.20.1.4' }, - } - }, - alarmContainerTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.24', label => 'container', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.24.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.24.1.4' }, - } - }, - alarmOpticalMuxTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.28', label => 'opticalmux', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.28.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.28.1.4' }, - } - }, - alarmShelfConnTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.34', label => 'shelfconn', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.32.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.32.1.4' }, - } - }, - alarmNtpIPv4Table => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.36', label => 'ntpipv4', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.36.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.36.1.4' }, - } - }, -}; - -sub manage_selection { - my ($self, %options) = @_; - - my $snmp_result = $options{snmp}->get_table(oid => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.5'); - use Data::Dumper; print Data::Dumper::Dumper($snmp_result); - print unpack('B*', $snmp_result->{'.1.3.6.1.4.1.2544.1.12.3.1.4.1.5.1.1.5'}); - exit(1); - - $self->{alarms}->{global} = { alarm => {} }; - my $get_oids = []; - foreach (keys %$oids) { - push @$get_oids, { oid => $oids->{$_}->{oid} }; - } - my $snmp_result = $options{snmp}->get_multiple_table(oids => $get_oids); - - my $last_time; - if (defined($self->{option_results}->{memory})) { - $self->{statefile_cache}->read(statefile => "cache_adva_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port(). '_' . $self->{mode}); - $last_time = $self->{statefile_cache}->get(name => 'last_time'); - } - - my ($i, $current_time) = (1, time()); - - foreach (keys %$oids) { - my $branch_oid = $oids->{$_}->{oid}; - next if (!defined($snmp_result->{$branch_oid})); - - foreach my $oid (keys %{$snmp_result->{$branch_oid}}) { - next if ($oid !~ /^$oids->{$_}->{mapping}->{severity}->{oid}\.(.*)\.(.*?)$/); - my $instance = $1 . '.' . $2; - my $type = defined($map_type{$2}) ? $map_type{$2} : 'unknown'; - my $result = $options{snmp}->map_instance(mapping => $oids->{$_}->{mapping}, results => $snmp_result->{$branch_oid}, instance => $instance); - - my @date = unpack 'n C6 a C2', $result->{timestamp}; - my $timezone = $self->{option_results}->{timezone}; - if (defined($date[7])) { - $timezone = sprintf("%s%02d%02d", $date[7], $date[8], $date[9]); - } - - my $tz = centreon::plugins::misc::set_timezone(name => $timezone); - my $dt = DateTime->new(year => $date[0], month => $date[1], day => $date[2], hour => $date[3], minute => $date[4], second => $date[5], - %$tz); - - next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $dt->epoch); - - my $diff_time = $current_time - $dt->epoch; - - $self->{alarms}->{global}->{alarm}->{$i} = { severity => $result->{severity}, - type => $type, since => $diff_time, - generation_time => centreon::plugins::misc::change_seconds(value => $diff_time), - label => $oids->{$_}->{label} - }; - $i++; - } - } - - if (defined($self->{option_results}->{memory})) { - $self->{statefile_cache}->write(data => { last_time => $current_time }); - } -} - -1; - -__END__ - -=head1 MODE - -Check alarms. - -=over 8 - -=item B<--warning-status> - -Set warning threshold for status (Default: '%{severity} =~ /warning|minor/i') -Can used special variables like: %{severity}, %{type}, %{label}, %{since} - -=item B<--critical-status> - -Set critical threshold for status (Default: '%{severity} =~ /critical|major/i'). -Can used special variables like: %{severity}, %{type}, %{label}, %{since} - -=item B<--timezone> - -Timezone options (the date from the equipment overload that option). Default is 'GMT'. - -=item B<--memory> - -Only check new alarms. - -=back - -=cut diff --git a/network/adva/fsp150/snmp/mode/components/card.pm b/network/adva/fsp150/snmp/mode/components/card.pm new file mode 100644 index 000000000..5d799452e --- /dev/null +++ b/network/adva/fsp150/snmp/mode/components/card.pm @@ -0,0 +1,106 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::adva::fsp150::snmp::mode::components::card; + +use strict; +use warnings; +use network::adva::fsp150::snmp::mode::components::resources qw( + $map_card_type $oids + get_secondary_states +); + +my $mapping = { + slotEntityIndex => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.3.1.2' }, + slotCardType => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.3.1.4', map => $map_card_type }, + slotSecondaryState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.3.1.15' } +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, + { oid => $mapping->{slotEntityIndex}->{oid} }, + { oid => $mapping->{slotCardType}->{oid} }, + { oid => $mapping->{slotSecondaryState}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking cards'); + $self->{components}->{card} = { name => 'cards', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'card')); + + my $results = { + %{$self->{results}->{ $mapping->{slotEntityIndex}->{oid} }}, + %{$self->{results}->{ $mapping->{slotCardType}->{oid} }}, + %{$self->{results}->{ $mapping->{slotSecondaryState}->{oid} }} + }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) { + next if ($oid !~ /^$mapping->{slotEntityIndex}->{oid}\.(\d+)\.(\d+)\.(\d+)$/); + + my ($ne_index, $shelf_index, $card_index, $instance) = ($1, $2, $3, $1 . '.' . $2 . '.' . $3); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + + my $ne_name = $self->{results}->{ $oids->{neName} }->{ $oids->{neName} . '.' . $ne_index }; + my $entity_name = $self->{results}->{ $oids->{entPhysicalName} }->{ $oids->{entPhysicalName} . '.' . $result->{slotEntityIndex} }; + my $name = $ne_name . ':' . $entity_name; + my $secondary_states = get_secondary_states(state => $result->{slotSecondaryState}); + + my $secondary_str = join(',', @$secondary_states); + if ($secondary_str =~ /mainteance/) { + $self->{output}->output_add( + long_msg => sprintf("skipping card '%s': in maintenance mode", $name) + ); + next; + } + + next if ($self->check_filter(section => 'card', instance => $result->{slotCardType} . '.' . $instance)); + $self->{components}->{card}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "card '%s' secondary status is '%s' [instance: %s].", + $name, + $secondary_str, + $result->{slotCardType} . '.' . $instance + ) + ); + + my $exit = 'ok'; + foreach (@$secondary_states) { + my $exit_tmp = $self->get_severity(label => 'secondary', section => 'card', instance => $result->{slotCardType} . '.' . $instance, value => $_); + $exit = $self->{output}->get_most_critical(status => [ $exit, $exit_tmp ]); + } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "card '%s' secondary status is '%s'", + $name, + $secondary_str + ) + ); + } + } +} + +1; diff --git a/network/adva/fsp150/snmp/mode/components/resources.pm b/network/adva/fsp150/snmp/mode/components/resources.pm new file mode 100644 index 000000000..8570326be --- /dev/null +++ b/network/adva/fsp150/snmp/mode/components/resources.pm @@ -0,0 +1,123 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::adva::fsp150::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_admin_state; +our $map_oper_state; +our $bits_secondary_state; +our $map_card_type; +our $oids; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw( + $map_admin_state $map_oper_state $bits_secondary_state $map_card_type + $oids get_secondary_states +); + +$oids = { + neName => '.1.3.6.1.4.1.2544.1.12.3.1.1.1.2', + shelfEntityIndex => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.2', + entPhysicalName => '.1.3.6.1.2.1.47.1.1.1.1.7' +}; + +$map_admin_state = { + 1 => 'in-service', 2 => 'management', + 3 => 'maintenance', 4 => 'disabled', + 5 => 'unassigned', 6 => 'monitored' +}; +$map_oper_state = { + 1 => 'normal', 2 => 'outage' +}; +$bits_secondary_state = { + 0 => 'not-applicable', 1 => 'active', + 2 => 'automaticinservice', 3 => 'facilityfailure', + 4 => 'fault', 5 => 'loopback', 6 => 'maintenance', + 7 => 'mismatchedeqpt', 8 => 'standbyhot', + 9 => 'supportingentityoutage', 10 => 'unassigned', + 11 => 'unequipped', 12 => 'disabled', + 13 => 'forcedoffline', 14 => 'initializing', + 15 => 'prtcl', 16 => 'blckd', 17 => 'mon-tx', + 18 => 'mir-rx', 19 => 'cema', 20 => 'lkdo', + 21 => 'nomber' +}; +$map_card_type = { + 1 => 'none', 2 => 'psu', 3 => 'fan', 4 => 'nemi', + 5 => 'scu', 6 => 'eth-10-100-1000-ntu', 7 => 'eth-cpmr', + 8 => 'eth-ge-101', 9 => 'eth-ge-206', 10 => 'eth-ge-201', + 11 => 'eth-ge-201se', 12 => 'eth-10-100-1000-nte', + 13 => 'scu-t', 14 => 'eth-ge-206f', 15 => 'eth-xg-1x', + 16 => 'swf-140g', 17 => 'stu', 18 => 'eth-ge-10s', + 19 => 'ami', 20 => 'sti', 21 => 'eth-ge-112', + 22 => 'eth-ge-114', 23 => 'eth-ge-206v', + 24 => 'eth-ge-4e-cc', 25 => 'eth-ge-4s-cc', + 26 => 'eth-xg-210', 27 => 'eth-xg-1x-cc', + 28 => 'eth-xg-1s-cc', 29 => 'stm1-4-et', + 30 => 'pwe3-ocnstm', 31 => 'pwe3-e1t1', 32 => 'eth-xg-1x-h', + 33 => 'eth-ge-10s-h', 34 => 'eth-t1804', 35 => 'eth-t3204', + 36 => 'eth-ge-syncprobe', 37 => 'eth-ge-8s-cc', + 38 => 'eth-ge-114h', 39 => 'eth-ge-114ph', + 40 => 'eth-fe-36e', 41 => 'eth-ge-114sh', + 42 => 'eth-ge-114s', 43 => 'sti-h', 44 => 'stu-h', + 45 => 'eth-ge-8e-cc', 46 => 'eth-sh1pcs', 47 => 'eth-osa5411', + 48 => 'ethGe112Pro', 49 => 'ethGe112ProM', + 50 => 'ethGe114Pro', 51 => 'ethGe114ProC', + 52 => 'ethGe114ProSH', 53 => 'ethGe114ProCSH', + 54 => 'ethGe114ProHE', 55 => 'ethGe112ProH', + 56 => 'eth-xg-210c', 57 => 'eth-ge-8sc-cc', + 58 => 'eth-osa5420', 59 => 'eth-osa5421', + 60 => 'bits-x16', 61 => 'eth-ge-114g', + 62 => 'ethGe114ProVmH', 63 => 'ethGe114ProVmCH', + 64 => 'ethGe114ProVmCSH', 65 => 'serverCard', + 66 => 'eth-ptpv2-osa', 67 => 'gnss-osa', + 68 => 'thc-osa', 69 => 'sgc-osa', 70 => 'pps-x16', + 71 => 'clk-x16', 72 => 'todAndPps-x16', 73 => 'eth-ge-101pro', + 74 => 'ethgo102proS',75 => 'ethgo102proSP', + 76 => 'ethcx101pro30A', 77 => 'ethcx102pro30A', + 78 => 'osa-ge-4s', 79 => 'eth-xg-116pro', + 80 => 'eth-xg-120pro', 81 => 'ethGe112ProVm', + 82 => 'eth-osa5401', 83 => 'eth-osa5405', + 84 => 'eth-csm', 85 => 'aux-osa', 86 => 'bits-x16-enhanced', + 87 => 'osa-ge-4s-protected', 88 => 'eth-ge-102pro-h', + 89 => 'eth-ge-102pro-efmh', 90 => 'eth-xg-116pro-h', + 91 => 'ethgo102proSM', 92 => 'eth-xg-118pro-sh', + 93 => 'eth-xg-118proac-sh', 94 => 'ethGe114ProVmSH', + 95 => 'ethGe104', 96 => 'eth-xg-120pro-sh' +}; + +sub get_secondary_states { + my (%options) = @_; + + my @bits_str = split //, unpack('B*', $options{state}); + my $results = []; + foreach (keys %$bits_secondary_state) { + if ($bits_str[$_]) { + push @$results, $bits_secondary_state->{$_}; + } + } + + return $results; +} + +1; diff --git a/network/adva/fsp150/snmp/mode/components/shelf.pm b/network/adva/fsp150/snmp/mode/components/shelf.pm new file mode 100644 index 000000000..e8de6f13b --- /dev/null +++ b/network/adva/fsp150/snmp/mode/components/shelf.pm @@ -0,0 +1,116 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::adva::fsp150::snmp::mode::components::shelf; + +use strict; +use warnings; +use network::adva::fsp150::snmp::mode::components::resources qw( + $map_admin_state $map_oper_state $oids + get_secondary_states +); + +my $mapping = { + shelfEntityIndex => { oid => $oids->{shelfEntityIndex} }, + shelfAdminState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.8', map => $map_admin_state }, + shelfOperationalState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.9', map => $map_oper_state }, + shelfSecondaryState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.10' } +}; +my $oid_shelfEntry = '.1.3.6.1.4.1.2544.1.12.3.1.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_shelfEntry, + start => $mapping->{shelfAdminState}->{oid}, + end => $mapping->{shelfSecondaryState}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking shelfs'); + $self->{components}->{shelf} = { name => 'shelfs', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'shelf')); + + $self->{results}->{$oid_shelfEntry} = { %{$self->{results}->{$oid_shelfEntry}}, %{$self->{results}->{ $oids->{shelfEntityIndex} }} }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_shelfEntry}})) { + next if ($oid !~ /^$mapping->{shelfAdminState}->{oid}\.(.*?)\.(.*)$/); + + my ($ne_index, $shelf_index, $instance) = ($1, $2, $1 . '.' . $2); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_shelfEntry}, instance => $instance); + + my $ne_name = $self->{results}->{ $oids->{neName} }->{ $oids->{neName} . '.' . $ne_index }; + my $entity_name = $self->{results}->{ $oids->{entPhysicalName} }->{ $oids->{entPhysicalName} . '.' . $result->{shelfEntityIndex} }; + my $name = $ne_name . ':' . $entity_name; + + if ($result->{shelfAdminState} eq 'maintenance') { + $self->{output}->output_add( + long_msg => sprintf("skipping shelf '%s': in maintenance mode", $name) + ); + next; + } + + next if ($self->check_filter(section => 'shelf', instance => $instance)); + $self->{components}->{shelf}->{total}++; + + my $secondary_states = get_secondary_states(state => $result->{shelfSecondaryState}); + $self->{output}->output_add( + long_msg => sprintf( + "shelf '%s' operational status is '%s' [secondary status: %s][instance: %s].", + $name, + $result->{shelfOperationalState}, + join(',', @$secondary_states), + $instance + ) + ); + my $exit = $self->get_severity(label => 'operational', section => 'shelf', value => $result->{shelfOperationalState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "shelf '%s' operational status is '%s'", + $name, + $result->{shelfOperationalState} + ) + ); + } + + $exit = 'ok'; + foreach (@$secondary_states) { + my $exit_tmp = $self->get_severity(label => 'secondary', section => 'shelf', instance => $instance, value => $_); + $exit = $self->{output}->get_most_critical(status => [ $exit, $exit_tmp ]); + } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "shelf '%s' secondary status is '%s'", + $name, + join(',', @$secondary_states) + ) + ); + } + } +} + +1; diff --git a/network/adva/fsp150/snmp/mode/hardware.pm b/network/adva/fsp150/snmp/mode/hardware.pm new file mode 100644 index 000000000..82887d745 --- /dev/null +++ b/network/adva/fsp150/snmp/mode/hardware.pm @@ -0,0 +1,108 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::adva::fsp150::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use network::adva::fsp150::snmp::mode::components::resources qw($oids); + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(?:shefl|card)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + operational => [ + ['normal', 'OK'], + ['outage', 'CRITICAL'], + ], + secondary => [ + ['fault', 'CRITICAL'], + ['facilityfailure', 'CRITICAL'], + ['.*', 'OK'] + ] + }; + + $self->{components_path} = 'network::adva::fsp150::snmp::mode::components'; + $self->{components_module} = ['shelf', 'card']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + push @{$self->{request}}, + { oid => $oids->{neName} }, + { oid => $oids->{shelfEntityIndex} }, + { oid => $oids->{entPhysicalName} }; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'shelf', 'card'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=shelf) +Can also exclude specific instance: --filter=card,psu.1.1.4 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='card,WARNING,initializing' + +=back + +=cut diff --git a/network/adva/fsp150/snmp/mode/interfaces.pm b/network/adva/fsp150/snmp/mode/interfaces.pm deleted file mode 100644 index c5d33d00f..000000000 --- a/network/adva/fsp150/snmp/mode/interfaces.pm +++ /dev/null @@ -1,370 +0,0 @@ -# -# Copyright 2020 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package network::adva::fsp3000::snmp::mode::interfaces; - -use base qw(snmp_standard::mode::interfaces); - -use strict; -use warnings; - -sub set_oids_traffic { - my ($self, %options) = @_; - - $self->{currentEthRx15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.52.1.5'; # in B - $self->{currentEthRx1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.53.1.5'; # in B - $self->{currentEthTx15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.56.1.3'; # in B - $self->{currentEthTx1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.57.1.3'; # in B - $self->{currentEthRxHighSpeed15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.88.1.4'; # in B - $self->{currentEthRxHighSpeed1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.89.1.4'; # in B -} - -sub set_counters_traffic { - my ($self, %options) = @_; - - push @{$self->{maps_counters}->{int}}, - { label => 'traffic-in', filter => 'add_traffic', nlabel => 'interface.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in_15min', diff => 1 }, { name => 'traffic_in_1day', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], - per_second => 1, - closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, - closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', - closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), - } - }, - { label => 'traffic-out', filter => 'add_traffic', nlabel => 'interface.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out_15min', diff => 1 }, { name => 'traffic_out_1day', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], - per_second => 1, - closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, - closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', - closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), - } - }, - ; -} - -sub set_counters { - my ($self, %options) = @_; - - $self->SUPER::set_counters(%options); - - push @{$self->{maps_counters}->{int}}, - { label => 'laser-temp', filter => 'add_optical', nlabel => 'interface.laser.temperature.celsius', set => { - key_values => [ { name => 'laser_temp' }, { name => 'display' } ], - output_template => 'Laser Temperature : %.2f C', output_error_template => 'Laser Temperature : %.2f', - perfdatas => [ - { label => 'laser_temp', value => 'laser_temp_absolute', template => '%.2f', - unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'input-power', filter => 'add_optical', nlabel => 'interface.input.power.dbm', set => { - key_values => [ { name => 'input_power' }, { name => 'display' } ], - output_template => 'Input Power : %s dBm', output_error_template => 'Input Power : %s', - perfdatas => [ - { label => 'input_power', value => 'input_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'output-power', filter => 'add_optical', nlabel => 'interface.output.power.dbm', set => { - key_values => [ { name => 'output_power' }, { name => 'display' } ], - output_template => 'Output Power : %s dBm', output_error_template => 'Output Power : %s', - perfdatas => [ - { label => 'output_power', value => 'output_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - ; -} - -sub custom_traffic_perfdata { - my ($self, %options) = @_; - - my ($warning, $critical); - if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { - $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { - $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}); - $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}); - } - - $self->{output}->perfdata_add( - label => 'traffic_' . $self->{result_values}->{label}, unit => 'b/s', - nlabel => $self->{nlabel}, - instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, - value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}), - warning => $warning, - critical => $critical, - min => 0, max => $self->{result_values}->{speed} - ); -} - -sub custom_traffic_threshold { - my ($self, %options) = @_; - - my $exit = 'ok'; - if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { - $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); - } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { - $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); - } - return $exit; -} - -sub custom_traffic_output { - my ($self, %options) = @_; - - my $label = $self->{result_values}->{label}; - $label =~ s/_/ /g; - $label =~ s/(\w+)/\u$1/g; - my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1); - my $msg = sprintf("Traffic %s : %s/s (%s)", - $label, $traffic_value . $traffic_unit, - defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-'); - return $msg; -} - -sub custom_traffic_calc { - my ($self, %options) = @_; - - return -10 if (defined($self->{instance_mode}->{last_status}) && $self->{instance_mode}->{last_status} == 0); - - # we choose the performance value (1day is updated every 15 minutes. 15min is updated all the time but reset every 15min - my $counter = 'traffic_' . $options{extra_options}->{label_ref} . '_15min'; - if ($options{delta_time} >= 600) { - $counter = 'traffic_' . $options{extra_options}->{label_ref} . '_1day'; - } - - my $diff_traffic = ($options{new_datas}->{$self->{instance} . '_' . $counter} - $options{old_datas}->{$self->{instance} . '_' . $counter}); - - $self->{result_values}->{traffic_per_seconds} = $diff_traffic / $options{delta_time}; - if (defined($options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}) && - $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}} > 0) { - $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic_per_seconds} * 100 / $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}; - $self->{result_values}->{speed} = $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}; - } - - $self->{result_values}->{label} = $options{extra_options}->{label_ref}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_set_traffic => 1, no_errors => 1, no_cast => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - 'add-optical' => { name => 'add_optical' }, - } - ); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->{checking} = ''; - foreach (('add_global', 'add_status', 'add_traffic', 'add_speed', 'add_volume', 'add_optical')) { - if (defined($self->{option_results}->{$_})) { - $self->{checking} .= $_; - } - } -} - -my $oid_opticalIfDiagLaserTemp = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.2'; -my $oid_opticalIfDiagInputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.3'; -my $oid_opticalIfDiagOutputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.4'; - -sub custom_load { - my ($self, %options) = @_; - - return if (!defined($self->{option_results}->{add_optical})); - - $self->{snmp}->load(oids => [$oid_opticalIfDiagLaserTemp, $oid_opticalIfDiagInputPower, $oid_opticalIfDiagOutputPower], - instances => $self->{array_interface_selected}); -} - -sub custom_add_result { - my ($self, %options) = @_; - - return if (!defined($self->{option_results}->{add_optical})); - $self->{int}->{$options{instance}}->{laser_temp} = undef; - if (defined($self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}}) && - $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} != -2147483648) { - $self->{int}->{$options{instance}}->{laser_temp} = $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} * 0.1; - } - - $self->{int}->{$options{instance}}->{input_power} = undef; - if (defined($self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}}) && - $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} != -65535) { - $self->{int}->{$options{instance}}->{input_power} = $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} / 10; - } - - $self->{int}->{$options{instance}}->{output_power} = undef; - if (defined($self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}}) && - $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} != -65535) { - $self->{int}->{$options{instance}}->{output_power} = $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} / 10; - } -} - -sub load_traffic { - my ($self, %options) = @_; - - if ($self->{snmp}->is_snmpv1()) { - $self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); - $self->{output}->option_exit(); - } - - $self->set_oids_traffic(); - $self->{snmp}->load(oids => [$self->{currentEthRx15minBytes}, $self->{currentEthRx1dayBytes}, - $self->{currentEthTx15minBytes}, $self->{currentEthTx1dayBytes}, - $self->{currentEthRxHighSpeed15minBytes}, $self->{currentEthRxHighSpeed1dayBytes}], instances => $self->{array_interface_selected}); -} - -sub add_result_traffic { - my ($self, %options) = @_; - - $self->{int}->{$options{instance}}->{traffic_in_15min} = - defined($self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}} * 8 : - (defined($self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}} * 8 : undef); - $self->{int}->{$options{instance}}->{traffic_in_1day} = - defined($self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}} * 8 : - (defined($self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}} * 8 : undef); - $self->{int}->{$options{instance}}->{traffic_out_15min} = - defined($self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}} * 8 : undef; - $self->{int}->{$options{instance}}->{traffic_out_1day} = - defined($self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}} * 8 : undef; - - $self->{int}->{$options{instance}}->{speed_in} = 0; - $self->{int}->{$options{instance}}->{speed_out} = 0; - if ($self->{get_speed} == 0) { - if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { - $self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000; - $self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000; - } - $self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne ''); - $self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne ''); - } -} - -1; - -__END__ - -=head1 MODE - -Check interfaces. - -=over 8 - -=item B<--add-status> - -Check interface status. - -=item B<--add-traffic> - -Check interface traffic. - -=item B<--add-optical> - -Check interface optical. - -=item B<--warning-status> - -Set warning threshold for status. -Can used special variables like: %{admstatus}, %{opstatus}, %{display} - -=item B<--critical-status> - -Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). -Can used special variables like: %{admstatus}, %{opstatus}, %{display} - -=item B<--warning-*> - -Threshold warning. -Can be: 'laser-temp', 'input-power', 'output-power', 'traffic-in', 'traffic-out'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'laser-temp', 'input-power', 'output-power', 'traffic-in', 'traffic-out'. - -=item B<--units-traffic> - -Units of thresholds for the traffic (Default: '%') ('%', 'b/s'). - -=item B<--interface> - -Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). - -=item B<--name> - -Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) - -=item B<--speed> - -Set interface speed for incoming/outgoing traffic (in Mb). - -=item B<--speed-in> - -Set interface speed for incoming traffic (in Mb). - -=item B<--speed-out> - -Set interface speed for outgoing traffic (in Mb). - -=item B<--reload-cache-time> - -Time in minutes before reloading cache file (default: 180). - -=item B<--oid-filter> - -Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName). - -=item B<--oid-display> - -Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName). - -=item B<--oid-extra-display> - -Add an OID to display. - -=item B<--display-transform-src> - -Regexp src to transform display value. - -=item B<--display-transform-dst> - -Regexp dst to transform display value. - -=item B<--show-cache> - -Display cache interface datas. - -=back - -=cut diff --git a/network/adva/fsp150/snmp/mode/listinterfaces.pm b/network/adva/fsp150/snmp/mode/listinterfaces.pm deleted file mode 100644 index 167bfa0bc..000000000 --- a/network/adva/fsp150/snmp/mode/listinterfaces.pm +++ /dev/null @@ -1,160 +0,0 @@ -# -# Copyright 2020 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package network::adva::fsp3000::snmp::mode::listinterfaces; - -use base qw(snmp_standard::mode::listinterfaces); - -use strict; -use warnings; - -my $mapping = { - advaInventoryAidString => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.6' }, - advaInventoryUnitName => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.7' }, -}; - -sub set_oids_label { - my ($self, %options) = @_; - - $self->{oids_label} = { - 'ifdesc' => '.1.3.6.1.2.1.2.2.1.2', - 'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18', - }; -} - -sub default_oid_filter_name { - my ($self, %options) = @_; - - return 'ifdesc'; -} - -sub default_oid_display_name { - my ($self, %options) = @_; - - return 'ifdesc'; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->SUPER::manage_selection(%options); - - my $oid_advaInventoryEntry = '.1.3.6.1.4.1.2544.1.11.7.10.1.1'; - my $snmp_result = $self->{snmp}->get_table( - oid => $oid_advaInventoryEntry, - begin => $mapping->{advaInventoryAidString}->{oid}, - end => $mapping->{advaInventoryUnitName}->{oid} - ); - - $self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; - $self->{results}->{ $self->{extra_oids}->{type} } = {}; - foreach my $oid (keys %{$snmp_result}) { - next if ($oid !~ /^$mapping->{advaInventoryUnitName}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - - next if ($result->{advaInventoryUnitName} !~ /^(SFP|XFP)/i); - - # interface name example: CH-1-3-N1 - # inventory name example: PL-1-3-N1 - next if ($result->{advaInventoryAidString} !~ /(\d+-\d+-[^\-]+)$/); - my $lookup = $1; - - foreach (sort @{$self->{interface_id_selected}}) { - my $display_value = $self->get_display_value(id => $_); - - if ($display_value =~ /CH-$lookup$/) { - $self->{results}->{ $self->{extra_oids}->{type}->{oid} }->{ $self->{extra_oids}->{type}->{oid} . '.' . $_ } = $result->{advaInventoryUnitName}; - } - } - } -} - -sub disco_format { - my ($self, %options) = @_; - - $self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; - $self->SUPER::disco_format(%options); -} - -1; - -__END__ - -=head1 MODE - -=over 8 - -=item B<--interface> - -Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). - -=item B<--name> - -Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) - -=item B<--speed> - -Set interface speed (in Mb). - -=item B<--skip-speed0> - -Don't display interface with speed 0. - -=item B<--filter-status> - -Display interfaces matching the filter (example: 'up'). - -=item B<--use-adminstatus> - -Display interfaces with AdminStatus 'up'. - -=item B<--oid-filter> - -Choose OID used to filter interface (default: ifDesc) (values: ifDesc, ifAlias). - -=item B<--oid-display> - -Choose OID used to display interface (default: ifDesc) (values: ifDesc, ifAlias). - -=item B<--display-transform-src> - -Regexp src to transform display value. (security risk!!!) - -=item B<--display-transform-dst> - -Regexp dst to transform display value. (security risk!!!) - -=item B<--add-extra-oid> - -Display an OID. -Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18' -or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*' - -=back - -=cut diff --git a/network/adva/fsp150/snmp/plugin.pm b/network/adva/fsp150/snmp/plugin.pm index b4409a7e3..2f45f7132 100644 --- a/network/adva/fsp150/snmp/plugin.pm +++ b/network/adva/fsp150/snmp/plugin.pm @@ -31,11 +31,9 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'alarms' => 'network::adva::fsp150::snmp::mode::alarms', - 'interfaces' => 'network::adva::fsp3000::snmp::mode::interfaces', - 'list-interfaces' => 'network::adva::fsp3000::snmp::mode::listinterfaces', - 'memory' => 'snmp_standard::mode::memory', - 'uptime' => 'snmp_standard::mode::uptime' + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'hardware' => 'network::adva::fsp150::snmp::mode::hardware' ); return $self; @@ -47,6 +45,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Adva fsp3000 equipments in SNMP. +Check Adva fsp150 equipments in SNMP. =cut