From pusurspirity, 1 Year ago, written in Plain Text.
Embed
  1. Im having an issue with snmptraps in Librenms.
  2. 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?
  3.  
  4. Snmptrapd is working as expected. Logs confirum that i receive all traps, but seems there is something wrong with my handler.
  5. My handler:
  6. /opt/librenms/LibreNMS/Snmptrap/Handlers/HuaDG.php
  7.  
  8.  
  9. <?php
  10.  
  11. namespace LibreNMS\Snmptrap\Handlers;
  12.  
  13. use App\Models\Device;
  14. use LibreNMS\Interfaces\SnmptrapHandler;
  15. use LibreNMS\Snmptrap\Trap;
  16. use Log;
  17.  
  18. class HuaDG implements SnmptrapHandler
  19. {
  20.         public function handle(Device $device, Trap $trap)
  21.         {
  22.                 $dyinggasp = $trap->getOidData($trap->findOid('HUAWEI-BASE-TRAP-MIB::hwEntityDyingGasp'));
  23.                 Log::event("Dying Gasp received", $device->device_id, 'trap', 5);
  24.         }
  25. }
  26. ?>
  27.  
  28.  
  29. Added the following to /opt/librenms/config/snmptraps.php:
  30. 'HUAWEI-BASE-TRAP-MIB::hwEntityDyingGasp' => \LibreNMS\Snmptrap\Handlers\HuaDG::class,
  31.  
  32.  
  33. /opt/librenms/logs/librenms.log shows the following:
  34.  
  35. 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)"}
  36.  
  37. Contents of that file line 308 is return "$this->logger->{$method}(...$parameters);".
  38.  
  39.     public function __call($method, $parameters)
  40.     {
  41.         return $this->logger->{$method}(...$parameters);
  42.     }
  43. }
  44.  
  45. Event is no longer a method?
  46.  
  47.