2021-09-21 23:20:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace LibreNMS\Snmptrap\Handlers;
|
|
|
|
|
|
|
|
use App\Models\Device;
|
2023-08-05 12:12:36 -05:00
|
|
|
use LibreNMS\Enum\Severity;
|
2021-09-21 23:20:49 +02:00
|
|
|
use LibreNMS\Interfaces\SnmptrapHandler;
|
|
|
|
use LibreNMS\Snmptrap\Trap;
|
|
|
|
|
|
|
|
class HpFault implements SnmptrapHandler
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle snmptrap.
|
|
|
|
* Data is pre-parsed and delivered as a Trap.
|
|
|
|
*
|
|
|
|
* @param Device $device
|
|
|
|
* @param Trap $trap
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle(Device $device, Trap $trap)
|
|
|
|
{
|
|
|
|
$type = $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfLogFaultType'));
|
|
|
|
switch ($type) {
|
2023-03-13 22:32:22 +01:00
|
|
|
case 'badXcvr':
|
2023-08-05 12:12:36 -05:00
|
|
|
$trap->log('Fault - CRC Error ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), Severity::Warning, $type);
|
2023-03-13 22:32:22 +01:00
|
|
|
break;
|
|
|
|
case 'badCable':
|
2023-08-05 12:12:36 -05:00
|
|
|
$trap->log('Fault - Bad Cable ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), Severity::Warning, $type);
|
2023-03-13 22:32:22 +01:00
|
|
|
break;
|
|
|
|
case 'bcastStorm':
|
2023-08-05 12:12:36 -05:00
|
|
|
$trap->log('Fault - Broadcaststorm ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), Severity::Error, $type);
|
2023-03-13 22:32:22 +01:00
|
|
|
break;
|
|
|
|
default:
|
2023-08-05 12:12:36 -05:00
|
|
|
$trap->log('Fault - Unhandled ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), Severity::Info, $type);
|
2023-03-13 22:32:22 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-09-21 23:20:49 +02:00
|
|
|
}
|
|
|
|
}
|