librenms-librenms/app/Providers/SnmptrapProvider.php
Tony Murray 4c6f917d9e Updates to snmptrap handling (#9010)
* Updates to snmptrap handling
fix a bug in findDeviceByIP.  Add more tests for that.
Move handle outside of the Trap class, it doesn't fit.
Add developer docs.

* fix tests copy paste issue.

* Fix findByIp when port may not exist.

* Logging: Output context (and extra) if they exist

* Generic trap event logging and new config setting.
2018-08-14 07:56:16 +01:00

37 lines
744 B
PHP

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Handlers\Fallback;
class SnmptrapProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind(SnmptrapHandler::class, function ($app, $oid) {
if ($handler = config('snmptraps.trap_handlers.' . reset($oid))) {
return $app->make($handler);
}
return $app->make(Fallback::class);
});
}
}