Hi
I seem to be having problems with my snmptrap handlers since Aug 19 update.
They worked fine before that.
I have my own dying gasp trap handlers for Huawei equipment. If a DG trap comes in i should get a trap in librenms. This is no longer working.
In logs i see the following when a dying gasp message hits the server:
Sep 6 13:42:48 librenms.local.net snmptrapd[750657]: In Trap.php line 133:
Sep 6 13:42:48 librenms.local.net snmptrapd[750657]: LibreNMS\Snmptrap\Trap::log(): Argument #2 ($severity) must be of type LibreNMS\Enum\Severity, int given, called in /opt/librenms/LibreNMS/Snmptrap/Handlers/HuaDG.php on line 14
This is my previously working handler:
<?php
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class HuaDG implements SnmptrapHandler
{
public function handle(Device $device, Trap $trap)
{
$dyinggasp = $trap->getOidData($trap->findOid('HUAWEI-BASE-TRAP-MIB::hwEntityDyingGasp'));
Log::event("Dying Gasp received", $device->device_id, 'trap', 5);
}
}
?>
Ive tried several combinations of using “5” and “Severity::Warning”, ive also tried having
“use LibreNMS\Enum\Severity;” in the code.
To no avail. Still getting the same error about Argument #2 being an integer.
Is this a bug with latest release? How do i alter my handler to work correctly?
<?php
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Enum\Severity;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class HuaDG implements SnmptrapHandler
{
public function handle(Device $device, Trap $trap)
{
$dyinggasp = $trap->getOidData($trap->findOid('HUAWEI-BASE-TRAP-MIB::hwEntityDyingGasp'));
$trap->log("Dying Gasp received", $device->device_id, 'trap', Severity::Warning);
}
}
Sep 6 14:42:33 librenms.local.net snmptrapd[1038237]: In Trap.php line 133:
Sep 6 14:42:33 librenms.local.net snmptrapd[1038237]: LibreNMS\Snmptrap\Trap::log(): Argument #2 ($severity) must be of type LibreNMS\Enum\Severity, int given, called in /opt/librenms/LibreNMS/Snmptrap/Handlers/HuaDG.php on line 16
Its complaning about Argument #2. What part of that is argument 2? I cant find that in docs.