Snmp trap - event log not working

Im having an issue with snmptraps in Librenms.
Im using Huawei equipment that generates Dying gasps on power failure. I want these traps in the event log but in a more human friendly format. I already set this up and it worked for a while but last few months it hasnt. Ive now set up a new blank Librenms to test but to no avail. I cant figure out where the problem is. Any suggestions based on the following?

Snmptrapd is working as expected. Logs confirm that i receive all traps, but seems there is something wrong with my handler.
My handler:
/opt/librenms/LibreNMS/Snmptrap/Handlers/HuaDG.php

<?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);
        }
}
?>

Added the following to /opt/librenms/config/snmptraps.php:
‘HUAWEI-BASE-TRAP-MIB::hwEntityDyingGasp’ => \LibreNMS\Snmptrap\Handlers\HuaDG::class,

/opt/librenms/logs/librenms.log shows the following:

production.ERROR: Call to undefined method Monolog\Logger::event() {“exception”:“[object] (Error(code: 0): Call to undefined method Monolog\Logger::event() at /opt/librenms/vendor/laravel/framework/src/Illuminate/Log/Logger.php:308)”}

Contents of that file line 308 is “return $this->logger->{$method}(…$parameters);”.

public function __call($method, $parameters)
{
    return $this->logger->{$method}(...$parameters);
}

}

Event is no longer a method?

I found the solution myself.
At some point Libre was updated and the old “Log::event” doesnt work anymore.
Made the following change:

#Log::event(“Dying Gasp received”, $device->device_id, ‘trap’, 5);
$trap->log(“Dying Gasp received”, $device->device_id, ‘trap’, 5);

And i now receive “Dying Gasp received” in event log and my alert rules work.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.