PHP code example of drakelid / librenms-netbox-context

1. Go to this page and download the library: Download drakelid/librenms-netbox-context library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

drakelid / librenms-netbox-context example snippets


PluginManager::hasHooks(App\Plugins\Hooks\PortTabHook::class, ...)   // abstract class

PluginManager::call(LibreNMS\Interfaces\Plugins\Hooks\PortTabHook::class, ...)   // interface

'sync' => [
    'device_filters' => ['site' => ['haugesund', 'bergen']],
    'interface_filters' => [],
],

'matching' => [
    'interface' => [
        'abbreviations' => ['swp' => 'swport'],
    ],
],

use LibreNMS\Plugins\NetBoxContext\Contracts\DeviceContextProviderInterface;
use LibreNMS\Plugins\NetBoxContext\Contracts\InterfaceContextProviderInterface;

$context = app(DeviceContextProviderInterface::class)->forDevice($device);

if ($context->hasNetBoxDevice()) {
    $site   = $context->netboxDevice->site_name;
    $tenant = $context->netboxDevice->tenant_name;
    $issues = $context->mismatches();
}

$portContext = app(InterfaceContextProviderInterface::class)->forPort($port);
$circuit     = $portContext->circuit?->cid;
bash
cd /opt/librenms

composer config repositories.netbox-context \
  '{"type":"path","url":"/opt/librenms-netbox-context","symlink":true}'

./lnms plugin:add drakelid/librenms-netbox-context @dev

php artisan migrate
cron
* * * * * librenms /usr/bin/php /opt/librenms/artisan schedule:run >> /dev/null 2>&1
bash
cd /opt/librenms
./lnms plugin:add drakelid/librenms-netbox-context ^1.0    # or composer update
php artisan migrate --force