Device page dropdown hero button, Performance -> Latency (#11328)

* Throw some shit together, rough outline.

* Reorganize tabs, use tab controllers

* Implement performance (into the latency tab)

* Update resources/views/device/header.blade.php

Co-Authored-By: Jellyfrog <Jellyfrog@users.noreply.github.com>

* Add more tabs

* All controllers created

* Implement routes

* Implement smokeping

* routing and auth

* fix smokeping check

* Implement device dropdown menu

* Update deviceUrl to new style

* Use Gates

* Fix style

* use more appropriate gates

* add show-config gate
remove Laravel helper

* Only show vlan tab if VLANs exist for the device :D

* Fix rancid file check will return false

* revert over-zealous file name changes

* don't need to request the location parameter, just cast to string to avoid bugs when not found

* Move latency tab (ping/performance) to the position of performance instead of ping.

Co-authored-by: Jellyfrog <Jellyfrog@users.noreply.github.com>
This commit is contained in:
Tony Murray 2020-04-29 07:25:13 -05:00 committed by GitHub
parent ce8de5cb18
commit 055abcf443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
70 changed files with 3352 additions and 984 deletions

View File

@ -0,0 +1,63 @@
<?php
/**
* DeviceTab.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Interfaces\UI;
use App\Models\Device;
interface DeviceTab
{
/**
* Check if the tab is visible
* @param Device $device
* @return bool
*/
public function visible(Device $device): bool;
/**
* The url slug for this tab
* @return string
*/
public function slug(): string;
/**
* The icon to display for this tab
* @return string
*/
public function icon(): string;
/**
* Name to display for this tab
* @return string
*/
public function name(): string;
/**
* Collect data to send to the view
* @param Device $device
* @return array
*/
public function data(Device $device): array;
}

View File

@ -44,8 +44,8 @@ class Permissions
* Check if a device can be accessed by user (non-global read/admin)
* If no user is given, use the logged in user
*
* @param Device|int $device
* @param User|int $user
* @param \App\Models\Device|int $device
* @param \App\Models\User|int $user
* @return boolean
*/
public function canAccessDevice($device, $user = null)
@ -58,8 +58,8 @@ class Permissions
* Check if a access can be accessed by user (non-global read/admin)
* If no user is given, use the logged in user
*
* @param Port|int $port
* @param User|int $user
* @param \App\Models\Port|int $port
* @param \App\Models\User|int $user
* @return boolean
*/
public function canAccessPort($port, $user = null)
@ -74,8 +74,8 @@ class Permissions
* Check if a bill can be accessed by user (non-global read/admin)
* If no user is given, use the logged in user
*
* @param Bill|int $bill
* @param User|int $user
* @param \App\Models\Bill|int $bill
* @param \App\Models\User|int $user
* @return boolean
*/
public function canAccessBill($bill, $user = null)
@ -89,7 +89,7 @@ class Permissions
/**
* Get the user_id of users that have been granted access to device
*
* @param Device|int $device
* @param \App\Models\Device|int $device
* @return \Illuminate\Support\Collection
*/
/*
@ -103,7 +103,7 @@ class Permissions
/**
* Get the user_id of users that have been granted access to port
*
* @param Port|int $port
* @param \App\Models\Port|int $port
* @return \Illuminate\Support\Collection
*/
public function usersForPort($port)
@ -116,7 +116,7 @@ class Permissions
/**
* Get the user_id of users that have been granted access to bill
*
* @param Bill|int $bill
* @param \App\Models\Bill|int $bill
* @return \Illuminate\Support\Collection
*/
public function usersForBill($bill)
@ -129,7 +129,7 @@ class Permissions
/**
* Get a list of device_id of all devices the user can access
*
* @param User|int $user
* @param \App\Models\User|int $user
* @return \Illuminate\Support\Collection
*/
public function devicesForUser($user = null)
@ -141,7 +141,7 @@ class Permissions
/**
* Get a list of port_id of all ports the user can access directly
*
* @param User|int $user
* @param \App\Models\User|int $user
* @return \Illuminate\Support\Collection
*/
public function portsForUser($user = null)
@ -154,7 +154,7 @@ class Permissions
/**
* Get a list of bill_id of all bills the user can access directly
*
* @param User|int $user
* @param \App\Models\User|int $user
* @return \Illuminate\Support\Collection
*/
public function billsForUser($user = null)
@ -167,7 +167,7 @@ class Permissions
/**
* Get the ids of all device groups the user can access
*
* @param User|int $user
* @param \App\Models\User|int $user
* @return \Illuminate\Support\Collection
*/
public function deviceGroupsForUser($user = null)
@ -188,7 +188,7 @@ class Permissions
/**
* Get the cached data for device permissions. Use helpers instead.
*
* @param User|int $user
* @param \App\Models\User|int $user
* @return \Illuminate\Support\Collection
*/
public function getDevicePermissions($user = null)

126
LibreNMS/Util/Smokeping.php Normal file
View File

@ -0,0 +1,126 @@
<?php
/**
* Smokeping.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Util;
use App\Models\Device;
use Illuminate\Support\Str;
use LibreNMS\Config;
class Smokeping
{
private $device;
private $files;
public function __construct(Device $device)
{
$this->device = $device;
}
public static function make(Device $device)
{
return new static($device);
}
public function getFiles()
{
if (is_null($this->files) && Config::has('smokeping.dir')) {
$dir = $this->generateFileName();
if (is_dir($dir)) {
foreach (array_diff(scandir($dir), ['.', '..']) as $file) {
if (stripos($file, '.rrd') !== false) {
if (strpos($file, '~') !== false) {
list($target, $slave) = explode('~', $this->filenameToHostname($file));
$this->files['in'][$target][$slave] = $file;
$this->files['out'][$slave][$target] = $file;
} else {
$target = $this->filenameToHostname($file);
$this->files['in'][$target][Config::get('own_hostname')] = $file;
$this->files['out'][Config::get('own_hostname')][$target] = $file;
}
}
}
}
}
return $this->files;
}
public function findFiles()
{
$this->files = null;
return $this->getFiles();
}
public function generateFileName($file = '')
{
if (Config::get('smokeping.integration') === true) {
return Config::get('smokeping.dir') . '/' . $this->device->type . '/' . $file;
} else {
return Config::get('smokeping.dir') . '/' . $file;
}
}
public function otherGraphs($direction)
{
$remote = $direction == 'in' ? 'src' : 'dest';
$data = array_keys(array_filter($this->getFiles()[$direction][$this->device->hostname], function ($file) {
return Str::contains($file, '~');
}));
return array_map(function ($other) use ($direction, $remote) {
$device = \DeviceCache::getByHostname($other);
return [
'device' => $device,
'graph' => [
'type' => 'smokeping_' . $direction,
'device' => $this->device->device_id,
$remote => $device->device_id,
]
];
}, $data);
}
public function hasGraphs()
{
return $this->hasInGraph() || $this->hasOutGraph();
}
public function hasInGraph()
{
return !empty($this->getFiles()['in'][$this->device->hostname]);
}
public function hasOutGraph()
{
return !empty($this->getFiles()['out'][$this->device->hostname]);
}
private function filenameToHostname($name)
{
$name = str_replace('.rrd', '', $name);
return str_replace('_', '.', $name);
}
}

View File

@ -29,6 +29,7 @@ use App\Models\Device;
use App\Models\Port;
use Auth;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Illuminate\Support\Str;
use LibreNMS\Config;
@ -104,7 +105,7 @@ class Url
$contents .= '<div class="overlib-box">';
$contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
$contents .= Url::minigraphImage($device, $start, $end, $graph);
$contents .= Url::minigraphImage($device, Carbon::now()->subWeek(1)->timestamp, $end, $graph);
$contents .= Url::minigraphImage($device, Carbon::now()->subWeek()->timestamp, $end, $graph);
$contents .= '</div>';
}
@ -218,9 +219,20 @@ class Url
return self::overlibLink(self::sensorUrl($sensor), $text, $content, self::sensorLinkDisplayClass($sensor));
}
/**
* @param int|Device $device
* @param array $vars
* @return string
*/
public static function deviceUrl($device, $vars = [])
{
return self::generate(['page' => 'device', 'device' => $device->device_id], $vars);
$routeParams = [is_int($device) ? $device : $device->device_id];
if (isset($vars['tab'])) {
$routeParams[] = $vars['tab'];
unset($vars['tab']);
}
return route('device', $routeParams) . self::urlParams($vars);
}
public static function portUrl($port, $vars = [])
@ -264,9 +276,23 @@ class Url
{
$vars = array_merge($vars, $new_vars);
$url = url($vars['page']) . '/';
$url = url($vars['page'] . '');
unset($vars['page']);
return $url . self::urlParams($vars);
}
/**
* Generate url parameters to append to url
* $prefix will only be prepended if there are parameters
*
* @param array $vars
* @param string $prefix
* @return string
*/
private static function urlParams($vars, $prefix = '/')
{
$url = empty($vars) ? '' : $prefix;
foreach ($vars as $var => $value) {
if ($value == '0' || $value != '' && !Str::contains($var, 'opt') && !is_numeric($var)) {
$url .= $var . '=' . urlencode($value) . '/';
@ -290,6 +316,35 @@ class Url
return '<img src="' . url('graph.php') . '?' . implode('&amp;', $urlargs) . '" style="border:0;" />';
}
public static function graphPopup($args)
{
// Take $args and print day,week,month,year graphs in overlib, hovered over graph
$original_from = $args['from'];
$now = CarbonImmutable::now();
$graph = self::graphTag($args);
$content = '<div class=list-large>' . $args['popup_title'] . '</div>';
$content .= '<div style="width: 850px">';
$args['width'] = 340;
$args['height'] = 100;
$args['legend'] = 'yes';
$args['from'] = $now->subDay()->timestamp;
$content .= self::graphTag($args);
$args['from'] = $now->subWeek()->timestamp;
$content .= self::graphTag($args);
$args['from'] = $now->subMonth()->timestamp;
$content .= self::graphTag($args);
$args['from'] = $now->subYear()->timestamp;
$content .= self::graphTag($args);
$content .= '</div>';
$args['from'] = $original_from;
$args['link'] = self::generate($args, ['page' => 'graphs', 'height' => null, 'width' => null, 'bg' => null]);
return self::overlibLink($args['link'], $graph, $content, null);
}
public static function lazyGraphTag($args)
{
$urlargs = [];

View File

@ -0,0 +1,57 @@
<?php
/**
* AccessPointsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class AccessPointsController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->accessPoints()->exists();
}
public function slug(): string
{
return 'accesspoints';
}
public function icon(): string
{
return 'fa-wifi';
}
public function name(): string
{
return __('Access Points');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* AlertStatsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class AlertStatsController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'alert-stats';
}
public function icon(): string
{
return 'fa-bar-chart';
}
public function name(): string
{
return __('Alert Stats');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* AlertsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class AlertsController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'alerts';
}
public function icon(): string
{
return 'fa-exclamation-circle';
}
public function name(): string
{
return __('Alerts');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* AppsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class AppsController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->applications()->exists();
}
public function slug(): string
{
return 'apps';
}
public function icon(): string
{
return 'fa-cubes';
}
public function name(): string
{
return __('Apps');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
* CaptureController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
class CaptureController implements \LibreNMS\Interfaces\UI\DeviceTab
{
public function visible(Device $device): bool
{
return false;
}
public function slug(): string
{
return 'capture';
}
public function icon(): string
{
return 'fa-bug';
}
public function name(): string
{
return __('Capture');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* CollectdController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
class CollectdController implements DeviceTab
{
public function visible(Device $device): bool
{
return Config::has('collectd_dir') && is_dir(Config::get('collectd_dir') . '/' . $device->hostname . '/');
}
public function slug(): string
{
return 'collectd';
}
public function icon(): string
{
return 'fa-pie-chart';
}
public function name(): string
{
return __('CollectD');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
* EditController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
class EditController implements \LibreNMS\Interfaces\UI\DeviceTab
{
public function visible(Device $device): bool
{
return false;
}
public function slug(): string
{
return 'edit';
}
public function icon(): string
{
return 'fa-gear';
}
public function name(): string
{
return __('Edit');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* GraphsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class GraphsController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'graphs';
}
public function icon(): string
{
return 'fa-area-chart';
}
public function name(): string
{
return __('Graphs');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* HealthController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class HealthController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->storage()->exists() || $device->sensors()->exists() || $device->mempools()->exists() || $device->processors()->exists();
}
public function slug(): string
{
return 'health';
}
public function icon(): string
{
return 'fa-heartbeat';
}
public function name(): string
{
return __('Health');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* InventoryController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Facades\DeviceCache;
use App\Models\Device;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
class InventoryController implements DeviceTab
{
private $type = null;
public function __construct()
{
if (Config::get('enable_inventory')) {
$device = DeviceCache::getPrimary();
if ($device->entityPhysical()->exists()) {
$this->type = 'entphysical';
}
if ($device->hostResources()->exists()) {
$this->type = 'hrdevice';
}
}
}
public function visible(Device $device): bool
{
return $this->type !== null;
}
public function slug(): string
{
return 'inventory';
}
public function icon(): string
{
return 'fa-cube';
}
public function name(): string
{
return __('Inventory');
}
public function data(Device $device): array
{
return [
'tab' => $this->type, // inject to load correct legacy file
];
}
}

View File

@ -0,0 +1,110 @@
<?php
/**
* LatencyController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use Carbon\Carbon;
use DB;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
use LibreNMS\Util\Smokeping;
use Request;
class LatencyController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'latency';
}
public function icon(): string
{
return 'fa-line-chart';
}
public function name(): string
{
return __('Latency');
}
public function data(Device $device): array
{
$from = Request::get('dtpickerfrom', Carbon::now()->subDays(2)->format(Config::get('dateformat.byminute')));
$to = Request::get('dtpickerto', Carbon::now()->format(Config::get('dateformat.byminute')));
$perf = $this->fetchPerfData($device, $from, $to);
$duration = abs(strtotime($perf->first()->date) - strtotime($perf->last()->date)) * 1000;
$smokeping = new Smokeping($device);
$smokeping_tabs = [];
if ($smokeping->hasInGraph()) {
$smokeping_tabs[] = 'in';
}
if ($smokeping->hasOutGraph()) {
$smokeping_tabs[] = 'out';
}
return [
'dtpickerfrom' => $from,
'dtpickerto' => $to,
'duration' => $duration,
'perfdata' => $this->formatPerfData($perf),
'smokeping' => $smokeping,
'smokeping_tabs' => $smokeping_tabs,
];
}
private function fetchPerfData(Device $device, $from, $to)
{
return DB::table('device_perf')
->where('device_id', $device->device_id)
->whereBetween('timestamp', [$from, $to])
->select(DB::raw("DATE_FORMAT(timestamp, '%Y-%m-%d %H:%i') date,xmt,rcv,loss,min,max,avg"))
->get();
}
/**
* Data ready for json export
* @param \Illuminate\Support\Collection $data
* @return array
*/
private function formatPerfData($data)
{
return $data->reduce(function ($data, $entry) {
$data[] = ['x' => $entry->date, 'y' => $entry->loss, 'group' => 0];
$data[] = ['x' => $entry->date, 'y' => $entry->min, 'group' => 1];
$data[] = ['x' => $entry->date, 'y' => $entry->max, 'group' => 2];
$data[] = ['x' => $entry->date, 'y' => $entry->avg, 'group' => 3];
return $data;
}, []);
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* LoadBalancerController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Facades\DeviceCache;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class LoadBalancerController implements DeviceTab
{
private $tabs = [];
public function __construct()
{
$device = DeviceCache::getPrimary();
if ($device->os == 'netscaler') {
if ($device->netscalerVservers()->exists()) {
$this->tabs[] = 'netscaler_vsvr';
}
}
// Cisco ACE
if ($device->os == 'acsw') {
if ($device->vServers()->exists()) {
$this->tabs[] = 'loadbalancer_vservers';
}
}
// F5 LTM
if ($device->os == 'f5') {
$component = new \LibreNMS\Component();
$component_count = $component->getComponentCount($device['device_id']);
if (isset($component_count['f5-ltm-vs'])) {
$this->tabs[] = 'ltm_vs';
}
if (isset($component_count['f5-ltm-pool'])) {
$this->tabs[] = 'ltm_pool';
}
if (isset($component_count['f5-gtm-wide'])) {
$this->tabs[] = 'gtm_wide';
}
if (isset($component_count['f5-gtm-pool'])) {
$this->tabs[] = 'gtm_pool';
}
}
}
public function visible(Device $device): bool
{
return !empty($this->tabs);
}
public function slug(): string
{
return 'loadbalancer';
}
public function icon(): string
{
return 'fa-balance-scale';
}
public function name(): string
{
return __('Load Balancer');
}
public function data(Device $device): array
{
return [
'loadbalancer_tabs' => $this->tabs,
];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* LogsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class LogsController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'logs';
}
public function icon(): string
{
return 'fa-sticky-note';
}
public function name(): string
{
return __('Logs');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* MefController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class MefController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->mefInfo()->exists();
}
public function slug(): string
{
return 'mef';
}
public function icon(): string
{
return 'fa-link';
}
public function name(): string
{
return __('Metro Ethernet');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* MibController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
class MibController implements DeviceTab
{
public function visible(Device $device): bool
{
return Config::get("poller_modules.mib") && $device->getAttrib('poll_mib');
}
public function slug(): string
{
return 'mib';
}
public function icon(): string
{
return 'fa-file-text-o';
}
public function name(): string
{
return __('MIB');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* MuninController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class MuninController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->muninPlugins()->exists();
}
public function slug(): string
{
return 'munin';
}
public function icon(): string
{
return 'fa-pie-chart';
}
public function name(): string
{
return __('Munin');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* NacController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class NacController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->portsNac()->exists();
}
public function slug(): string
{
return 'nac';
}
public function icon(): string
{
return 'fa-lock';
}
public function name(): string
{
return __('NAC');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* NeighboursController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class NeighboursController implements DeviceTab
{
public function visible(Device $device): bool
{
return \DB::table('links')->where('local_device_id', $device->device_id)->exists();
}
public function slug(): string
{
return 'neighbours';
}
public function icon(): string
{
return 'fa-sitemap';
}
public function name(): string
{
return __('Neighbours');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* NetflowController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
class NetflowController implements DeviceTab
{
public function visible(Device $device): bool
{
if (Config::get('nfsen_enable')) {
foreach ((array)Config::get('nfsen_rrds', []) as $nfsenrrds) {
if ($nfsenrrds[(strlen($nfsenrrds) - 1)] != '/') {
$nfsenrrds .= '/';
}
$nfsensuffix = Config::get('nfsen_suffix', '');
if (Config::get('nfsen_split_char')) {
$basefilename_underscored = preg_replace('/\./', Config::get('nfsen_split_char'), $device->hostname);
} else {
$basefilename_underscored = $device->hostname;
}
$nfsen_filename = preg_replace('/'.$nfsensuffix.'/', '', $basefilename_underscored);
if (is_file($nfsenrrds.$nfsen_filename.'.rrd')) {
return true;
}
}
}
return false;
}
public function slug(): string
{
return 'netflow';
}
public function icon(): string
{
return 'fa-tint';
}
public function name(): string
{
return __('Netflow');
}
public function data(Device $device): array
{
return [
'tab' => 'nfsen',
];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* NotesController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class NotesController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'notes';
}
public function icon(): string
{
return 'fa-file-text-o';
}
public function name(): string
{
return __('Notes');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* OverviewController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class OverviewController implements DeviceTab
{
public function visible(Device $device): bool
{
return true;
}
public function slug(): string
{
return 'overview';
}
public function icon(): string
{
return 'fa-lightbulb-o';
}
public function name(): string
{
return __('Overview');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* PackagesController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class PackagesController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->packages()->exists();
}
public function slug(): string
{
return 'packages';
}
public function icon(): string
{
return 'fa-folder';
}
public function name(): string
{
return __('Pkgs');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* PortsController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class PortsController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->ports()->exists();
}
public function slug(): string
{
return 'ports';
}
public function icon(): string
{
return 'fa-link';
}
public function name(): string
{
return __('Ports');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* PrinterController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class PrinterController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->printerSupplies()->exists();
}
public function slug(): string
{
return 'printer';
}
public function icon(): string
{
return 'fa-print';
}
public function name(): string
{
return __('Printer');
}
public function data(Device $device): array
{
return [
'tab' => 'toner',
];
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* ProcessesController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use DB;
use LibreNMS\Interfaces\UI\DeviceTab;
class ProcessesController implements DeviceTab
{
public function visible(Device $device): bool
{
return DB::table('processes')->where('device_id', $device->device_id)->exists();
}
public function slug(): string
{
return 'processes';
}
public function icon(): string
{
return 'fa-microchip';
}
public function name(): string
{
return __('Processes');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* PseudowiresController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class PseudowiresController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->pseudowires()->exists();
}
public function slug(): string
{
return 'pseudowires';
}
public function icon(): string
{
return 'fa-arrows-alt';
}
public function name(): string
{
return __('Pseudowires');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* RoutingController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Facades\DeviceCache;
use App\Models\Component;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class RoutingController implements DeviceTab
{
private $tabs;
public function __construct()
{
$device = DeviceCache::getPrimary();
$this->tabs = [
'ospf' => $device->ospfInstances()->exists(),
'bgp' => $device->bgppeers()->exists(),
'vrf' => $device->vrfs()->exists(),
'cef' => $device->cefSwitching()->exists(),
'mpls' => $device->mplsLsps()->exists(),
'cisco-otv' => Component::query()->where('device_id', $device->device_id)->where('type', 'Cisco-OTV')->exists(),
'loadbalancer_rservers' => $device->rServers()->exists(),
'ipsec_tunnels' => $device->ipsecTunnels()->exists(),
'routes' => $device->routes()->exists(),
];
}
public function visible(Device $device): bool
{
return in_array(true, $this->tabs);
}
public function slug(): string
{
return 'routing';
}
public function icon(): string
{
return 'fa-random';
}
public function name(): string
{
return __('Routing');
}
public function data(Device $device): array
{
return [
'routing_tabs' => array_keys(array_filter($this->tabs))
];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* ServicesController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class ServicesController implements DeviceTab
{
public function visible(Device $device): bool
{
return (bool)\LibreNMS\Config::get('show_services') && $device->services()->exists();
}
public function slug(): string
{
return 'services';
}
public function icon(): string
{
return 'fa-cogs';
}
public function name(): string
{
return __('Services');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,115 @@
<?php
/**
* ShowConfigController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Facades\DeviceCache;
use App\Http\Controllers\Controller;
use App\Models\Device;
use Gate;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
class ShowConfigController extends Controller implements DeviceTab
{
private $rancidFile;
public function visible(Device $device): bool
{
if (auth()->user()->can('show-config', $device)) {
return $this->oxidizedEnabled($device) || $this->getRancidConfigFile() !== false;
}
return false;
}
public function slug(): string
{
return 'showconfig';
}
public function icon(): string
{
return 'fa-align-justify';
}
public function name(): string
{
return __('Config');
}
public function data(Device $device): array
{
return [
'rancid_file' => $this->getRancidConfigFile(),
];
}
private function oxidizedEnabled(Device $device)
{
return Config::get('oxidized.enabled') === true
&& Config::has('oxidized.url')
&& !$device->getAttrib('override_Oxidized_disable');
}
private function getRancidConfigFile()
{
if (is_null($this->rancidFile)) {
$this->rancidFile = $this->findRancidConfigFile();
}
return $this->rancidFile;
}
private function findRancidConfigFile()
{
if (Config::has('rancid_configs') && !is_array(Config::get('rancid_configs'))) {
Config::set('rancid_configs', (array)Config::get('rancid_configs', []));
}
if (Config::has('rancid_configs.0')) {
$device = DeviceCache::getPrimary();
foreach (Config::get('rancid_configs') as $configs) {
if ($configs[(strlen($configs) - 1)] != '/') {
$configs .= '/';
}
if (is_file($configs . $device['hostname'])) {
return $configs . $device['hostname'];
} elseif (is_file($configs . strtok($device['hostname'], '.'))) { // Strip domain
return $configs . strtok($device['hostname'], '.');
} else {
if (!empty(Config::get('mydomain'))) { // Try with domain name if set
if (is_file($configs . $device['hostname'] . '.' . Config::get('mydomain'))) {
return $configs . $device['hostname'] . '.' . Config::get('mydomain');
}
}
}
}
}
return false;
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* SlasController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class SlasController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->slas()->exists();
}
public function slug(): string
{
return 'slas';
}
public function icon(): string
{
return 'fa-flag';
}
public function name(): string
{
return __('SLAs');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* StpController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class StpController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->stpInstances()->exists();
}
public function slug(): string
{
return 'stp';
}
public function icon(): string
{
return 'fa-sitemap';
}
public function name(): string
{
return __('STP');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* TnmsneController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use App\Models\TnmsneInfo;
use LibreNMS\Interfaces\UI\DeviceTab;
class TnmsneController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->os == 'coriant' && TnmsneInfo::query()->where('device_id', $device->device_id)->exists();
}
public function slug(): string
{
return 'tnmsne';
}
public function icon(): string
{
return 'fa-link';
}
public function name(): string
{
return __('Hardware');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* VlansController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use App\Models\Vlan;
use LibreNMS\Interfaces\UI\DeviceTab;
class VlansController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->vlans()->exists();
}
public function slug(): string
{
return 'vlans';
}
public function icon(): string
{
return 'fa-tasks';
}
public function name(): string
{
return __('VLANs');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* VmInfoController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class VmInfoController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->vminfo()->exists();
}
public function slug(): string
{
return 'vm';
}
public function icon(): string
{
return 'fa-cog';
}
public function name(): string
{
return __('Virtual Machines');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* WirelessController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Device\Tabs;
use App\Models\Device;
use LibreNMS\Interfaces\UI\DeviceTab;
class WirelessController implements DeviceTab
{
public function visible(Device $device): bool
{
return $device->wirelessSensors()->exists();
}
public function slug(): string
{
return 'wireless';
}
public function icon(): string
{
return 'fa-wifi';
}
public function name(): string
{
return __('Wireless');
}
public function data(Device $device): array
{
return [];
}
}

View File

@ -0,0 +1,208 @@
<?php
namespace App\Http\Controllers;
use App\Facades\DeviceCache;
use App\Models\Device;
use App\Models\Vminfo;
use Auth;
use Carbon\Carbon;
use Gate;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use LibreNMS\Config;
use LibreNMS\Util\Url;
class DeviceController extends Controller
{
private $tabs = [
'overview' => \App\Http\Controllers\Device\Tabs\OverviewController::class,
'graphs' => \App\Http\Controllers\Device\Tabs\GraphsController::class,
'health' => \App\Http\Controllers\Device\Tabs\HealthController::class,
'apps' => \App\Http\Controllers\Device\Tabs\AppsController::class,
'processes' => \App\Http\Controllers\Device\Tabs\ProcessesController::class,
'collectd' => \App\Http\Controllers\Device\Tabs\CollectdController::class,
'ports' => \App\Http\Controllers\Device\Tabs\PortsController::class,
'slas' => \App\Http\Controllers\Device\Tabs\SlasController::class,
'wireless' => \App\Http\Controllers\Device\Tabs\WirelessController::class,
'accesspoints' => \App\Http\Controllers\Device\Tabs\AccessPointsController::class,
'vlans' => \App\Http\Controllers\Device\Tabs\VlansController::class,
'vm' => \App\Http\Controllers\Device\Tabs\VmInfoController::class,
'mef' => \App\Http\Controllers\Device\Tabs\MefController::class,
'tnmsne' => \App\Http\Controllers\Device\Tabs\TnmsneController::class,
'loadbalancer' => \App\Http\Controllers\Device\Tabs\LoadBalancerController::class,
'routing' => \App\Http\Controllers\Device\Tabs\RoutingController::class,
'pseudowires' => \App\Http\Controllers\Device\Tabs\PseudowiresController::class,
'neighbours' => \App\Http\Controllers\Device\Tabs\NeighboursController::class,
'stp' => \App\Http\Controllers\Device\Tabs\StpController::class,
'packages' => \App\Http\Controllers\Device\Tabs\PackagesController::class,
'inventory' => \App\Http\Controllers\Device\Tabs\InventoryController::class,
'services' => \App\Http\Controllers\Device\Tabs\ServicesController::class,
'printer' => \App\Http\Controllers\Device\Tabs\PrinterController::class,
'logs' => \App\Http\Controllers\Device\Tabs\LogsController::class,
'alerts' => \App\Http\Controllers\Device\Tabs\AlertsController::class,
'alert-stats' => \App\Http\Controllers\Device\Tabs\AlertStatsController::class,
'showconfig' => \App\Http\Controllers\Device\Tabs\ShowConfigController::class,
'netflow' => \App\Http\Controllers\Device\Tabs\NetflowController::class,
'latency' => \App\Http\Controllers\Device\Tabs\LatencyController::class,
'nac' => \App\Http\Controllers\Device\Tabs\NacController::class,
'notes' => \App\Http\Controllers\Device\Tabs\NotesController::class,
'mib' => \App\Http\Controllers\Device\Tabs\MibController::class,
'edit' => \App\Http\Controllers\Device\Tabs\EditController::class,
'capture' => \App\Http\Controllers\Device\Tabs\CaptureController::class,
];
public function index(Request $request, $device_id, $current_tab = 'overview', $vars = '')
{
$device_id = (int)str_replace('device=', '', $device_id);
$current_tab = str_replace('tab=', '', $current_tab);
$current_tab = array_key_exists($current_tab, $this->tabs) ? $current_tab : 'overview';
DeviceCache::setPrimary($device_id);
$device = DeviceCache::getPrimary();
$this->authorize('view', [$request->user(), $device]);
$alert_class = $device->disabled ? 'alert-info' : ($device->status ? '' : 'alert-danger');
$parent_id = Vminfo::query()->whereIn('vmwVmDisplayName', [$device->hostname, $device->hostname . '.' . Config::get('mydomain')])->first(['device_id']);
$overview_graphs = $this->buildDeviceGraphArrays($device);
$tabs = array_map(function ($class) {
return app()->make($class);
}, array_filter($this->tabs, 'class_exists')); // TODO remove filter
$title = $tabs[$current_tab]->name();
$data = $tabs[$current_tab]->data($device);
// Device Link Menu, select the primary link
$device_links = $this->deviceLinkMenu($device);
$primary_device_link_name = Config::get('html.device.primary_link', 'edit');
if (!isset($device_links[$primary_device_link_name])) {
$primary_device_link_name = array_key_first($device_links);
}
$primary_device_link = $device_links[$primary_device_link_name];
unset($device_links[$primary_device_link_name], $primary_device_link_name);
if (view()->exists('device.tabs.' . $current_tab)) {
return view('device.tabs.' . $current_tab, get_defined_vars());
}
$tab_content = $this->renderLegacyTab($current_tab, $device, $data);
return view('device.tabs.legacy', get_defined_vars());
}
private function renderLegacyTab($tab, Device $device, $data)
{
ob_start();
$device = $device->toArray();
set_debug(false);
chdir(base_path());
$init_modules = ['web', 'auth'];
require base_path('/includes/init.php');
$vars['device'] = $device['device_id'];
$vars['tab'] = $tab;
extract($data); // set preloaded data into variables
include "includes/html/pages/device/$tab.inc.php";
$output = ob_get_clean();
ob_end_clean();
return $output;
}
private function buildDeviceGraphArrays($device)
{
$graph_array = [
'width' => 150,
'height' => 45,
'device' => $device->device_id,
'type' => 'device_bits',
'from' => Carbon::now()->subDay()->timestamp,
'legend' => 'no',
'bg' => 'FFFFFF00',
];
$graphs = [];
foreach ($this->getDeviceGraphs($device) as $graph) {
$graph_array['type'] = $graph['graph'];
$graph_array['popup_title'] = __($graph['text']);
$graphs[] = $graph_array;
}
return $graphs;
}
private function getDeviceGraphs(Device $device)
{
if ($device->snmp_disable) {
return Config::get('os.ping.over');
} elseif (Config::has("os.$device->os.over")) {
return Config::get("os.$device->os.over");
}
$os_group = Config::getOsSetting($device->os, 'group');
return Config::get("os.$os_group.over", Config::get('os.default.over'));
}
private function deviceLinkMenu(Device $device)
{
$device_links = [];
if (Gate::allows('update', $device)) {
$device_links['edit'] = [
'icon' => 'fa-gear',
'url' => route('device', [$device->device_id, 'edit']),
'title' => __('Edit'),
'external' => false,
];
}
// User defined device links
foreach (array_values(Arr::wrap(Config::get('html.device.links'))) as $index => $link) {
$device_links['custom' . ($index + 1)] = [
'icon' => $link['icon'] ?? 'fa-external-link',
'url' => view(['template' => $link['url']], ['device' => $device])->__toString(),
'title' => $link['title'],
'external' => $link['external'] ?? true,
];
}
// Web
$device_links['web'] = [
'icon' => 'fa-globe',
'url' => 'https://' . $device->hostname,
'title' => __('Web'),
'external' => true,
'onclick' => 'http_fallback(this); return false;',
];
// SSH
$ssh_url = Config::has('gateone.server')
? Config::get('gateone.server') . '?ssh=ssh://' . (Config::get('gateone.use_librenms_user') ? Auth::user()->username . '@' : '') . $device['hostname'] . '&location=' . $device['hostname']
: 'ssh://' . $device->hostname;
$device_links['ssh'] = [
'icon' => 'fa-lock',
'url' => $ssh_url,
'title' => __('SSH'),
'external' => true,
];
// Telnet
$device_links['telnet'] = [
'icon' => 'fa-terminal',
'url' => 'telnet://' . $device->hostname,
'title' => __('Telnet'),
'external' => true,
];
if (Gate::allows('admin')) {
$device_links['capture'] = [
'icon' => 'fa-bug',
'url' => route('device', [$device->device_id, 'capture']),
'title' => __('Capture'),
'external' => false,
];
}
return $device_links;
}
}

View File

@ -277,7 +277,7 @@ class DeviceController extends TableController
$actions .= '<div class="col-xs-1"><a href="' . Url::deviceUrl($device, ['tab' => 'alerts']) . '"> <i class="fa fa-exclamation-circle fa-lg icon-theme" title="View alerts"></i></a></div>';
if (\Auth::user()->hasGlobalAdmin()) {
$actions .= '<div class="col-xs-1"><a href="' . Url::deviceUrl($device, ['tab' => 'edit']) . '"> <i class="fa fa-pencil fa-lg icon-theme" title="Edit device"></i></a></div>';
$actions .= '<div class="col-xs-1"><a href="' . Url::deviceUrl($device, ['tab' => 'edit']) . '"> <i class="fa fa-gear fa-lg icon-theme" title="Edit device"></i></a></div>';
}
if ($this->isDetailed()) {

View File

@ -0,0 +1,9 @@
<?php
namespace App\Models;
class AccessPoint extends DeviceRelatedModel
{
protected $primaryKey = 'accesspoint_id';
public $timestamps = false;
}

View File

@ -582,6 +582,11 @@ class Device extends BaseModel
// ---- Define Relationships ----
public function accessPoints()
{
return $this->hasMany(AccessPoint::class, 'device_id');
}
public function alerts()
{
return $this->hasMany(\App\Models\Alert::class, 'device_id');
@ -622,6 +627,16 @@ class Device extends BaseModel
return $this->hasMany(\App\Models\Component::class, 'device_id');
}
public function hostResources()
{
return $this->hasMany(HrDevice::class, 'device_id');
}
public function entityPhysical()
{
return $this->hasMany(EntPhysical::class, 'device_id');
}
public function eventlogs()
{
return $this->hasMany(\App\Models\Eventlog::class, 'device_id', 'device_id');
@ -632,6 +647,11 @@ class Device extends BaseModel
return $this->belongsToMany(\App\Models\DeviceGroup::class, 'device_group_device', 'device_id', 'device_group_id');
}
public function ipsecTunnels()
{
return $this->hasMany(IpsecTunnel::class, 'device_id');
}
public function ipv4()
{
return $this->hasManyThrough(\App\Models\Ipv4Address::class, \App\Models\Port::class, 'device_id', 'port_id', 'device_id', 'port_id');
@ -647,11 +667,26 @@ class Device extends BaseModel
return $this->belongsTo(\App\Models\Location::class, 'location_id', 'id');
}
public function mefInfo()
{
return $this->hasMany(MefInfo::class, 'device_id');
}
public function muninPlugins()
{
return $this->hasMany('App\Models\MuninPlugin', 'device_id');
}
public function ospfInstances()
{
return $this->hasMany(\App\Models\OspfInstance::class, 'device_id');
}
public function netscalerVservers()
{
return $this->hasMany(NetscalerVserver::class, 'device_id');
}
public function packages()
{
return $this->hasMany(\App\Models\Package::class, 'device_id', 'device_id');
@ -687,6 +722,11 @@ class Device extends BaseModel
return $this->hasMany(\App\Models\Processor::class, 'device_id');
}
public function routes()
{
return $this->hasMany(Route::class, 'device_id');
}
public function rules()
{
return $this->belongsToMany(\App\Models\AlertRule::class, 'alert_device_map', 'device_id', 'rule_id');
@ -707,6 +747,11 @@ class Device extends BaseModel
return $this->hasMany(\App\Models\Storage::class, 'device_id');
}
public function stpInstances()
{
return $this->hasMany(Stp::class, 'device_id');
}
public function mempools()
{
return $this->hasMany(\App\Models\Mempool::class, 'device_id');
@ -752,6 +797,26 @@ class Device extends BaseModel
return $this->hasMany(\App\Models\MplsTunnelCHop::class, 'device_id');
}
public function printerSupplies()
{
return $this->hasMany(Toner::class, 'device_id');
}
public function pseudowires()
{
return $this->hasMany(Pseudowire::class, 'device_id');
}
public function rServers()
{
return $this->hasMany(LoadbalancerRserver::class, 'device_id');
}
public function slas()
{
return $this->hasMany(Sla::class, 'device_id');
}
public function syslogs()
{
return $this->hasMany(\App\Models\Syslog::class, 'device_id', 'device_id');
@ -768,6 +833,11 @@ class Device extends BaseModel
return $this->hasMany(\App\Models\Vminfo::class, 'device_id');
}
public function vlans()
{
return $this->hasMany(\App\Models\Vlan::class, 'device_id');
}
public function vrfLites()
{
return $this->hasMany(\App\Models\VrfLite::class, 'device_id');
@ -778,6 +848,11 @@ class Device extends BaseModel
return $this->hasMany(\App\Models\Vrf::class, 'device_id');
}
public function vServers()
{
return $this->hasMany(LoadbalancerVserver::class, 'device_id');
}
public function wirelessSensors()
{
return $this->hasMany(\App\Models\WirelessSensor::class, 'device_id');

View File

@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class IpsecTunnel extends Model
{
protected $table = 'ipsec_tunnels';
protected $primaryKey = 'tunnel_id';
public $timestamps = false;
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class LoadbalancerRserver extends Model
{
protected $table = 'loadbalancer_rservers';
protected $primaryKey = 'rserver_id';
public $timestamps = false;
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class LoadbalancerVserver extends Model
{
protected $table = 'loadbalancer_vservers';
protected $primaryKey = 'vserver_id';
public $timestamps = false;
}

9
app/Models/MefInfo.php Normal file
View File

@ -0,0 +1,9 @@
<?php
namespace App\Models;
class MefInfo extends DeviceRelatedModel
{
protected $table = 'mefinfo';
public $timestamps = false;
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Models;
class NetscalerVserver extends DeviceRelatedModel
{
protected $primaryKey = 'vsvr_id';
public $timestamps = false;
}

9
app/Models/Sla.php Normal file
View File

@ -0,0 +1,9 @@
<?php
namespace App\Models;
class Sla extends DeviceRelatedModel
{
protected $primaryKey = 'sla_id';
public $timestamps = false;
}

12
app/Models/Stp.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Stp extends Model
{
protected $table = 'stp';
protected $primaryKey = 'stp_id';
public $timestamps = false;
}

11
app/Models/TnmsneInfo.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TnmsneInfo extends Model
{
protected $table = 'tnmsneinfo';
public $timestamps = false;
}

View File

@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Facades\Permissions;
use App\Models\User;
use App\Models\Device;
use Illuminate\Auth\Access\HandlesAuthorization;
class DevicePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any devices.
*
* @param \App\Models\User $user
* @return mixed
*/
public function viewAny(User $user)
{
return $user->hasGlobalRead();
}
/**
* Determine whether the user can view the device.
*
* @param \App\Models\User $user
* @param \App\Models\Device $device
* @return mixed
*/
public function view(User $user, Device $device)
{
return Permissions::canAccessDevice($device, $user);
}
/**
* Determine whether the user can create devices.
*
* @param \App\Models\User $user
* @return mixed
*/
public function create(User $user)
{
return $user->hasGlobalAdmin();
}
/**
* Determine whether the user can update the device.
*
* @param \App\Models\User $user
* @param \App\Models\Device $device
* @return mixed
*/
public function update(User $user, Device $device)
{
return $user->isAdmin();
}
/**
* Determine whether the user can delete the device.
*
* @param \App\Models\User $user
* @param \App\Models\Device $device
* @return mixed
*/
public function delete(User $user, Device $device)
{
return $user->isAdmin();
}
/**
* Determine whether the user can restore the device.
*
* @param \App\Models\User $user
* @param \App\Models\Device $device
* @return mixed
*/
public function restore(User $user, Device $device)
{
return $user->hasGlobalAdmin();
}
/**
* Determine whether the user can permanently delete the device.
*
* @param \App\Models\User $user
* @param \App\Models\Device $device
* @return mixed
*/
public function forceDelete(User $user, Device $device)
{
return $user->isAdmin();
}
/**
* Determine whether the user can view the stored configuration of the device
* from Oxidized or Rancid
*
* @param \App\Models\User $user
* @param \App\Models\Device $device
* @return mixed
*/
public function showConfig(User $user, Device $device)
{
return $user->isAdmin();
}
}

View File

@ -2,6 +2,7 @@
namespace App\Providers;
use App\Facades\DeviceCache;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Log;

View File

@ -2,10 +2,6 @@
namespace App\Providers;
use App\Models\DeviceGroup;
use App\Models\User;
use App\Policies\DeviceGroupPolicy;
use App\Policies\UserPolicy;
use App\Guards\ApiTokenGuard;
use Auth;
use Illuminate\Support\Facades\Gate;
@ -19,8 +15,9 @@ class AuthServiceProvider extends ServiceProvider
* @var array
*/
protected $policies = [
User::class => UserPolicy::class,
DeviceGroup::class => DeviceGroupPolicy::class,
\App\Models\User::class => \App\Policies\UserPolicy::class,
\App\Models\Device::class => \App\Policies\DevicePolicy::class,
\App\Models\DeviceGroup::class => \App\Policies\DeviceGroupPolicy::class,
];
/**

View File

@ -3,10 +3,10 @@
"/css/app.css": "/css/app.css?id=5da3bf931f2f95a17884",
"/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e",
"/js/vendor.js": "/js/vendor.js?id=29212a758157c575d7f8",
"/js/lang/de.js": "/js/lang/de.js?id=8c1c390a5f45ac01d54b",
"/js/lang/en.js": "/js/lang/en.js?id=14d93644610d1daa14af",
"/js/lang/fr.js": "/js/lang/fr.js?id=21b66f3f48a3f67ba443",
"/js/lang/ru.js": "/js/lang/ru.js?id=1a4435677a27aa615af1",
"/js/lang/uk.js": "/js/lang/uk.js?id=6ce358a9e9387947ee03",
"/js/lang/zh-TW.js": "/js/lang/zh-TW.js?id=3ad4a3e6a5a59165e806"
"/js/lang/de.js": "/js/lang/de.js?id=73ed23dde31af205f171",
"/js/lang/en.js": "/js/lang/en.js?id=27824cdf8f5ae90ac13a",
"/js/lang/fr.js": "/js/lang/fr.js?id=520702ceb97d269f707b",
"/js/lang/ru.js": "/js/lang/ru.js?id=aaab82593592e9368a08",
"/js/lang/uk.js": "/js/lang/uk.js?id=58751cdf330e62fa4bee",
"/js/lang/zh-TW.js": "/js/lang/zh-TW.js?id=e578b34b9d5e21cf929d"
}

View File

@ -681,41 +681,16 @@ function get_device_graphs($device)
function get_smokeping_files($device)
{
$smokeping_files = array();
if (Config::has('smokeping.dir')) {
$smokeping_dir = generate_smokeping_file($device);
if ($handle = opendir($smokeping_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if (stripos($file, '.rrd') !== false) {
if (strpos($file, '~') !== false) {
list($target,$slave) = explode('~', str_replace('.rrd', '', $file));
$target = str_replace('_', '.', $target);
$smokeping_files['in'][$target][$slave] = $file;
$smokeping_files['out'][$slave][$target] = $file;
} else {
$target = str_replace('.rrd', '', $file);
$target = str_replace('_', '.', $target);
$smokeping_files['in'][$target][Config::get('own_hostname')] = $file;
$smokeping_files['out'][Config::get('own_hostname')][$target] = $file;
}
}
}
}
}
}
return $smokeping_files;
} // end get_smokeping_files
$smokeping = new \LibreNMS\Util\Smokeping(DeviceCache::get($device['device_id']));
return $smokeping->findFiles();
}
function generate_smokeping_file($device, $file = '')
{
if (Config::get('smokeping.integration') === true) {
return Config::get('smokeping.dir') . '/' . $device['type'] . '/' . $file;
} else {
return Config::get('smokeping.dir') . '/' . $file;
}
} // generate_smokeping_file
$smokeping = new \LibreNMS\Util\Smokeping(DeviceCache::get($device['device_id']));
return $smokeping->generateFileName($file);
}
/*

View File

@ -160,9 +160,8 @@ function generate_minigraph_image($device, $start, $end, $type, $legend = 'no',
function generate_device_url($device, $vars = array())
{
return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars);
}//end generate_device_url()
return \LibreNMS\Util\Url::deviceUrl((int)$device['device_id'], $vars);
}
function generate_device_link($device, $text = null, $vars = array(), $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
{
@ -247,41 +246,10 @@ function overlib_link($url, $text, $contents, $class = null)
return \LibreNMS\Util\Url::overlibLink($url, $text, $contents, $class);
}
function generate_graph_popup($graph_array)
{
// Take $graph_array and print day,week,month,year graps in overlib, hovered over graph
$original_from = $graph_array['from'];
$graph = generate_graph_tag($graph_array);
$content = '<div class=list-large>' . $graph_array['popup_title'] . '</div>';
$content .= "<div style=\'width: 850px\'>";
$graph_array['legend'] = 'yes';
$graph_array['height'] = '100';
$graph_array['width'] = '340';
$graph_array['from'] = Config::get('time.day');
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = Config::get('time.week');
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = Config::get('time.month');
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = Config::get('time.year');
$content .= generate_graph_tag($graph_array);
$content .= '</div>';
$graph_array['from'] = $original_from;
$graph_array['link'] = generate_url($graph_array, array('page' => 'graphs', 'height' => null, 'width' => null, 'bg' => null));
// $graph_array['link'] = "graphs/type=" . $graph_array['type'] . "/id=" . $graph_array['id'];
return overlib_link($graph_array['link'], $graph, $content, null);
}//end generate_graph_popup()
function print_graph_popup($graph_array)
{
echo generate_graph_popup($graph_array);
}//end print_graph_popup()
echo \LibreNMS\Util\Url::graphPopup($graph_array);
}
function bill_permitted($bill_id)
{

View File

@ -1,504 +0,0 @@
<?php
use App\Models\PortsNac;
use LibreNMS\Config;
if (!is_numeric($vars['device'])) {
$vars['device'] = getidbyname($vars['device']);
}
$permitted_by_port = $vars['tab'] == 'port' && port_permitted($vars['port'], $vars['device']);
if (device_permitted($vars['device']) || $permitted_by_port) {
if (empty($vars['tab'])) {
$tab = 'overview';
} else {
$tab = str_replace('.', '', $vars['tab']);
}
$select = array($tab => 'class="active"');
DeviceCache::setPrimary($vars['device']);
$device = device_by_id_cache($vars['device']);
$attribs = get_dev_attribs($device['device_id']);
$device['attribs'] = $attribs;
load_os($device);
$entity_state = get_dev_entity_state($device['device_id']);
// print_r($entity_state);
$pagetitle[] = format_hostname($device, $device['hostname']);
$component = new LibreNMS\Component();
$component_count = $component->getComponentCount($device['device_id']);
$alert_class = '';
if ($device['disabled'] == '1') {
$alert_class = 'alert-info';
} elseif ($device['status'] == '0') {
$alert_class = 'alert-danger';
}
echo '<div class="panel panel-default">';
echo '<div class="panel-body '.$alert_class.'">';
require 'includes/html/device-header.inc.php';
echo '</div>';
echo '</div>';
if (device_permitted($device['device_id'])) {
echo '<ul class="nav nav-tabs">';
if (Config::get('show_overview_tab')) {
echo '
<li role="presentation" '.$select['overview'].'>
<a href="'.generate_device_url($device, array('tab' => 'overview')).'">
<i class="fa fa-lightbulb-o fa-lg icon-theme" aria-hidden="true"></i> Overview
</a>
</li>';
}
echo '<li role="presentation" '.$select['graphs'].'>
<a href="'.generate_device_url($device, array('tab' => 'graphs')).'">
<i class="fa fa-area-chart fa-lg icon-theme" aria-hidden="true"></i> Graphs
</a>
</li>';
$health = dbFetchCell("SELECT COUNT(*) FROM storage WHERE device_id = ?", array($device['device_id'])) +
dbFetchCell("SELECT COUNT(*) FROM sensors WHERE device_id = ?", array($device['device_id'])) +
dbFetchCell("SELECT COUNT(*) FROM mempools WHERE device_id = ?", array($device['device_id'])) +
dbFetchCell("SELECT COUNT(*) FROM processors WHERE device_id = ?", array($device['device_id'])) +
count_mib_health($device);
if ($health) {
echo '<li role="presentation" '.$select['health'].'>
<a href="'.generate_device_url($device, array('tab' => 'health')).'">
<i class="fa fa-heartbeat fa-lg icon-theme" aria-hidden="true"></i> Health
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM applications WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['apps'].'>
<a href="'.generate_device_url($device, array('tab' => 'apps')).'">
<i class="fa fa-cubes fa-lg icon-theme" aria-hidden="true"></i> Apps
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM processes WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['processes'].'>
<a href="'.generate_device_url($device, array('tab' => 'processes')).'">
<i class="fa fa-microchip fa-lg icon-theme" aria-hidden="true"></i> Processes
</a>
</li>';
}
if (Config::has('collectd_dir') && is_dir(Config::get('collectd_dir') . '/' . $device['hostname'] . '/')) {
echo '<li role="presentation" '.$select['collectd'].'>
<a href="'.generate_device_url($device, array('tab' => 'collectd')).'">
<i class="fa fa-pie-chart fa-lg icon-theme" aria-hidden="true"></i> CollectD
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM munin_plugins WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['munin'].'>
<a href="'.generate_device_url($device, array('tab' => 'munin')).'">
<i class="fa fa-pie-chart fa-lg icon-theme" aria-hidden="true"></i> Munin
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM ports WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['ports'].$select['port'].'">
<a href="'.generate_device_url($device, array('tab' => 'ports')).'">
<i class="fa fa-link fa-lg icon-theme" aria-hidden="true"></i> Ports
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM slas WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['slas'].$select['sla'].'>
<a href="'.generate_device_url($device, array('tab' => 'slas')).'">
<i class="fa fa-flag fa-lg icon-theme" aria-hidden="true"></i> SLAs
</a>
</li>';
}
if (dbFetchCell('SELECT 1 FROM `wireless_sensors` WHERE `device_id`=?', array($device['device_id']))) {
echo '<li role="presentation" '.$select['wireless'].'>
<a href="'.generate_device_url($device, array('tab' => 'wireless')).'">
<i class="fa fa-wifi fa-lg icon-theme" aria-hidden="true"></i> Wireless
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM access_points WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['accesspoints'].'>
<a href="'.generate_device_url($device, array('tab' => 'accesspoints')).'">
<i class="fa fa-wifi fa-lg icon-theme" aria-hidden="true"></i> Access Points
</a>
</li>';
}
$smokeping_files = get_smokeping_files($device);
if (count($smokeping_files['in'][$device['hostname']]) || count($smokeping_files['out'][$device['hostname']])) {
echo '<li role="presentation" '.$select['latency'].'>
<a href="'.generate_device_url($device, array('tab' => 'latency')).'">
<i class="fa fa-crosshairs fa-lg icon-theme" aria-hidden="true"></i> Ping
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM vlans WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['vlans'].'>
<a href="'.generate_device_url($device, array('tab' => 'vlans')).'">
<i class="fa fa-tasks fa-lg icon-theme" aria-hidden="true"></i> VLANs
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM vminfo WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['vm'].'>
<a href="'.generate_device_url($device, array('tab' => 'vm')).'">
<i class="fa fa-cog fa-lg icon-theme" aria-hidden="true"></i> Virtual Machines
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM mefinfo WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['mef'].'>
<a href="'.generate_device_url($device, array('tab' => 'mef')).'">
<i class="fa fa-link fa-lg icon-theme" aria-hidden="true"></i> Metro Ethernet
</a>
</li>';
}
if ($device['os'] == 'coriant') {
if (dbFetchCell("SELECT 1 FROM tnmsneinfo WHERE device_id = ?", array($device['device_id']))) {
echo '<li class="'.$select['tnmsne'].'">
<a href="'.generate_device_url($device, array('tab' => 'tnmsne')).'">
<i class="fa fa-link fa-lg icon-theme" aria-hidden="true"></i> Hardware
</a>
</li>';
}
}
// $loadbalancer_tabs is used in device/loadbalancer/ to build the submenu. we do it here to save queries
if ($device['os'] == 'netscaler') {
// Netscaler
$device_loadbalancer_count['netscaler_vsvr'] = dbFetchCell('SELECT COUNT(*) FROM `netscaler_vservers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_loadbalancer_count['netscaler_vsvr']) {
$loadbalancer_tabs[] = 'netscaler_vsvr';
}
}
if ($device['os'] == 'acsw') {
// Cisco ACE
$device_loadbalancer_count['loadbalancer_vservers'] = dbFetchCell('SELECT COUNT(*) FROM `loadbalancer_vservers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_loadbalancer_count['loadbalancer_vservers']) {
$loadbalancer_tabs[] = 'loadbalancer_vservers';
}
}
// F5 LTM
if (isset($component_count['f5-ltm-vs'])) {
$device_loadbalancer_count['ltm_vs'] = $component_count['f5-ltm-vs'];
$loadbalancer_tabs[] = 'ltm_vs';
}
if (isset($component_count['f5-ltm-pool'])) {
$device_loadbalancer_count['ltm_pool'] = $component_count['f5-ltm-pool'];
$loadbalancer_tabs[] = 'ltm_pool';
}
if (isset($component_count['f5-gtm-wide'])) {
$device_loadbalancer_count['gtm_wide'] = $component_count['f5-gtm-wide'];
$loadbalancer_tabs[] = 'gtm_wide';
}
if (isset($component_count['f5-gtm-pool'])) {
$device_loadbalancer_count['gtm_pool'] = $component_count['f5-gtm-pool'];
$loadbalancer_tabs[] = 'gtm_pool';
}
if (is_array($loadbalancer_tabs)) {
echo '<li role="presentation" '.$select['loadbalancer'].'>
<a href="'.generate_device_url($device, array('tab' => 'loadbalancer')).'">
<i class="fa fa-balance-scale fa-lg icon-theme" aria-hidden="true"></i> Load Balancer
</a>
</li>';
}
// $routing_tabs is used in device/routing/ to build the tabs menu. we built it here to save some queries
$device_routing_count['loadbalancer_rservers'] = dbFetchCell('SELECT COUNT(*) FROM `loadbalancer_rservers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['loadbalancer_rservers']) {
$routing_tabs[] = 'loadbalancer_rservers';
}
$device_routing_count['ipsec_tunnels'] = dbFetchCell('SELECT COUNT(*) FROM `ipsec_tunnels` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['ipsec_tunnels']) {
$routing_tabs[] = 'ipsec_tunnels';
}
$device_routing_count['bgp'] = dbFetchCell('SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['bgp']) {
$routing_tabs[] = 'bgp';
}
$device_routing_count['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
if ($device_routing_count['ospf']) {
$routing_tabs[] = 'ospf';
}
$device_routing_count['cef'] = dbFetchCell('SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['cef']) {
$routing_tabs[] = 'cef';
}
$device_routing_count['vrf'] = @dbFetchCell('SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['vrf']) {
$routing_tabs[] = 'vrf';
}
$device_routing_count['mpls'] = @dbFetchCell('SELECT COUNT(*) FROM `mpls_lsps` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['mpls']) {
$routing_tabs[] = 'mpls';
}
$device_routing_count['cisco-otv'] = $component_count['Cisco-OTV'];
if ($device_routing_count['cisco-otv'] > 0) {
$routing_tabs[] = 'cisco-otv';
}
$device_routing_count['routes'] = dbFetchCell('SELECT COUNT(*) FROM `route` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['routes']) {
$routing_tabs[] = 'routes';
}
if (is_array($routing_tabs)) {
echo '<li role="presentation" '.$select['routing'].'>
<a href="'.generate_device_url($device, array('tab' => 'routing')).'">
<i class="fa fa-random fa-lg icon-theme" aria-hidden="true"></i> Routing
</a>
</li>';
}
if (dbFetchCell('SELECT 1 FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']))) {
echo '<li role="presentation" '.$select['pseudowires'].'>
<a href="'.generate_device_url($device, array('tab' => 'pseudowires')).'">
<i class="fa fa-arrows-alt fa-lg icon-theme" aria-hidden="true"></i> Pseudowires
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM `links` where `local_device_id`=?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['neighbours'].'>
<a href="'.generate_device_url($device, array('tab' => 'neighbours')).'">
<i class="fa fa-sitemap fa-lg icon-theme" aria-hidden="true"></i> Neighbours
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM stp WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['stp'].'>
<a href="'.generate_device_url($device, array('tab' => 'stp')).'">
<i class="fa fa-sitemap fa-lg icon-theme" aria-hidden="true"></i> STP
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM `packages` WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['packages'].'>
<a href="'.generate_device_url($device, array('tab' => 'packages')).'">
<i class="fa fa-folder fa-lg icon-theme" aria-hidden="true"></i> Pkgs
</a>
</li>';
}
if (Config::get('enable_inventory')) {
if (dbFetchCell("SELECT 1 FROM `entPhysical` WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" ' . $select['entphysical'] . '>
<a href="' . generate_device_url($device, array('tab' => 'entphysical')) . '">
<i class="fa fa-cube fa-lg icon-theme" aria-hidden="true"></i> Inventory
</a>
</li>';
} elseif (@dbFetchCell("SELECT 1 FROM `hrDevice` WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" ' . $select['hrdevice'] . '>
<a href="' . generate_device_url($device, array('tab' => 'hrdevice')) . '">
<i class="fa fa-cube fa-lg icon-theme" aria-hidden="true"></i> Inventory
</a>
</li>';
}
}
if (Config::get('show_services')) {
echo '<li role="presentation" '.$select['services'].'>
<a href="'.generate_device_url($device, array('tab' => 'services')).'">
<i class="fa fa-cogs fa-lg icon-theme" aria-hidden="true"></i> Services
</a>
</li>';
}
if (dbFetchCell("SELECT 1 FROM toner WHERE device_id = ?", array($device['device_id']))) {
echo '<li role="presentation" '.$select['toner'].'>
<a href="'.generate_device_url($device, array('tab' => 'toner')).'">
<i class="fa fa-print fa-lg icon-theme" aria-hidden="true"></i> Toner
</a>
</li>';
}
echo '<li role="presentation" '.$select['logs'].'>
<a href="'.generate_device_url($device, array('tab' => 'logs')).'">
<i class="fa fa-sticky-note fa-lg icon-theme" aria-hidden="true"></i> Logs
</a>
</li>';
echo '<li role="presentation" '.$select['alerts'].'>
<a href="'.generate_device_url($device, array('tab' => 'alert')).'">
<i class="fa fa-exclamation-circle fa-lg icon-theme" aria-hidden="true"></i> Alerts
</a>
</li>';
echo '<li role="presentation" '.$select['alert-stats'].'>
<a href="'.generate_device_url($device, array('tab' => 'alert-stats')).'">
<i class="fa fa-bar-chart fa-lg icon-theme" aria-hidden="true"></i> Alert Stats
</a>
</li>';
if (Auth::user()->hasGlobalAdmin()) {
foreach ((array)Config::get('rancid_configs', []) as $configs) {
if ($configs[(strlen($configs) - 1)] != '/') {
$configs .= '/';
}
if (is_file($configs.$device['hostname'])) {
$device_config_file = $configs.$device['hostname'];
} elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain
$device_config_file = $configs.strtok($device['hostname'], '.');
} else {
if (!empty(Config::get('mydomain'))) { // Try with domain name if set
if (is_file($configs . $device['hostname'] . '.' . Config::get('mydomain'))) {
$device_config_file = $configs . $device['hostname'] . '.' . Config::get('mydomain');
}
}
} // end if
}
if (Config::get('oxidized.enabled') === true && !in_array($device['type'], Config::get('oxidized.ignore_types')) && Config::has('oxidized.url')) {
$device_config_file = true;
}
}
if ($device_config_file) {
if (!get_dev_attrib($device, 'override_Oxidized_disable') == 'true') {
echo '<li class="'.$select['showconfig'].'">
<a href="'.generate_device_url($device, array('tab' => 'showconfig')).'">
<i class="fa fa-align-justify fa-lg icon-theme" aria-hidden="true"></i> Config
</a>
</li>';
}
}
if (Config::get('nfsen_enable')) {
foreach ((array)Config::get('nfsen_rrds', []) as $nfsenrrds) {
if ($nfsenrrds[(strlen($nfsenrrds) - 1)] != '/') {
$nfsenrrds .= '/';
}
$nfsensuffix = Config::get('nfsen_suffix', '');
if (Config::get('nfsen_split_char')) {
$basefilename_underscored = preg_replace('/\./', Config::get('nfsen_split_char'), $device['hostname']);
} else {
$basefilename_underscored = $device['hostname'];
}
$nfsen_filename = preg_replace('/'.$nfsensuffix.'/', '', $basefilename_underscored);
if (is_file($nfsenrrds.$nfsen_filename.'.rrd')) {
$nfsen_rrd_file = $nfsenrrds.$nfsen_filename.'.rrd';
}
}
}//end if
if ($nfsen_rrd_file) {
echo '<li role="presentation" '.$select['nfsen'].'>
<a href="'.generate_device_url($device, array('tab' => 'nfsen')).'">
<i class="fa fa-tint fa-lg icon-theme" aria-hidden="true"></i> Netflow
</a>
</li>';
}
if (can_ping_device($attribs) === true) {
echo '<li role="presentation" '.$select['performance'].'>
<a href="'.generate_device_url($device, array('tab' => 'performance')).'">
<i class="fa fa-line-chart fa-lg icon-theme" aria-hidden="true"></i> Performance
</a>
</li>';
}
if (PortsNac::where('device_id', $device['device_id'])->exists()) {
echo '<li role="presentation" '.$select['nac'].'>
<a href="'.generate_device_url($device, array('tab' => 'nac')).'">
<i class="fa fa-lock fa-lg icon-theme" aria-hidden="true"></i> NAC
</a>
</li>';
}
echo '<li role="presentation" '.$select['notes'].'>
<a href="'.generate_device_url($device, array('tab' => 'notes')).'">
<i class="fa fa-file-text-o fa-lg icon-theme" aria-hidden="true"></i> Notes
</a>
</li>';
if (is_mib_poller_enabled($device)) {
echo '<li role="presentation" '.$select['mib'].'>
<a href="'.generate_device_url($device, array('tab' => 'mib')).'">
<i class="fa fa-file-text-o fa-lg icon-theme" aria-hidden="true"></i> MIB
</a>
</li>';
}
echo '<div class="dropdown pull-right">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog fa-lg icon-theme" aria-hidden="true"></i>
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="https://'.$device['hostname'].'" onclick="http_fallback(this); return false;" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" aria-hidden="true"></i> Web</a></li>';
foreach (Config::get('html.device.links') as $links) {
$html_link = view(['template' => $links['url']], ['device' => $device])->__toString();
echo '<li><a href="'.$html_link.'" onclick="http_fallback(this); return false;" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" aria-hidden="true"></i> '.$links['title'].'</a></li>';
}
if (Config::has('gateone.server')) {
if (Config::get('gateone.use_librenms_user') == true) {
echo '<li><a href="' . Config::get('gateone.server') . '?ssh=ssh://' . Auth::user()->username . '@' . $device['hostname'] . '&location=' . $device['hostname'] . '" target="_blank" rel="noopener"><i class="fa fa-lock fa-lg icon-theme" aria-hidden="true"></i> SSH</a></li>';
} else {
echo '<li><a href="' . Config::get('gateone.server') . '?ssh=ssh://' . $device['hostname'] . '&location=' . $device['hostname'] . '" target="_blank" rel="noopener"><i class="fa fa-lock fa-lg icon-theme" aria-hidden="true"></i> SSH</a></li>';
}
} else {
echo '<li><a href="ssh://'.$device['hostname'].'" target="_blank" rel="noopener"><i class="fa fa-lock fa-lg icon-theme" aria-hidden="true"></i> SSH</a></li>
';
}
echo '<li><a href="telnet://'.$device['hostname'].'" target="_blank" rel="noopener"><i class="fa fa-terminal fa-lg icon-theme" aria-hidden="true"></i> Telnet</a></li>';
if (Auth::user()->hasGlobalAdmin()) {
echo '<li>
<a href="'.generate_device_url($device, array('tab' => 'edit')).'">
<i class="fa fa-pencil fa-lg icon-theme" aria-hidden="true"></i> Edit </a>
</li>';
echo '<li><a href="'.generate_device_url($device, array('tab' => 'capture')).'">
<i class="fa fa-bug fa-lg icon-theme" aria-hidden="true"></i> Capture
</a></li>';
}
echo '</ul>
</div>';
echo '</ul>';
}//end if device_permitted
// include the tabcontent
echo '<div class="tabcontent">';
require 'includes/html/pages/device/'.filter_var(basename($tab), FILTER_SANITIZE_URL).'.inc.php';
echo '</div>';
} else {
// no device permissions
require 'includes/html/error-no-perm.inc.php';
}

View File

@ -1,130 +0,0 @@
<?php
print_optionbar_start();
echo "<span style='font-weight: bold;'>Latency</span> &#187; ";
if (count($smokeping_files['in'][$device['hostname']])) {
$menu_options['incoming'] = 'Incoming';
}
if (count($smokeping_files['out'][$device['hostname']])) {
$menu_options['outgoing'] = 'Outgoing';
}
$sep = '';
foreach ($menu_options as $option => $text) {
if (!$vars['view']) {
$vars['view'] = $option;
}
echo $sep;
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link($text, $vars, array('view' => $option));
if ($vars['view'] == $option) {
echo '</span>';
}
$sep = ' | ';
}
unset($sep);
print_optionbar_end();
echo '<table>';
if ($vars['view'] == 'incoming') {
if (count($smokeping_files['in'][$device['hostname']])) {
$graph_array['type'] = 'device_smokeping_in_all_avg';
$graph_array['device'] = $device['device_id'];
echo '<tr><td>';
echo '<h3>Average</h3>';
include 'includes/html/print-graphrow.inc.php';
echo '</td></tr>';
$graph_array['type'] = 'device_smokeping_in_all';
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
echo '<tr><td>';
echo '<h3>Aggregate</h3>';
include 'includes/html/print-graphrow.inc.php';
echo '</td></tr>';
unset($graph_array['legend']);
ksort($smokeping_files['in'][$device['hostname']]);
foreach ($smokeping_files['in'][$device['hostname']] as $src => $host) {
$hostname = str_replace('.rrd', '', $host);
$host = device_by_name($src);
if (\LibreNMS\Config::get('smokeping.integration') === true) {
$dest = device_by_name(str_replace("_", ".", $hostname));
} else {
$dest = $host;
}
if (is_numeric($host['device_id'])) {
echo '<tr><td>';
echo '<h3>'.generate_device_link($dest).'</h3>';
$graph_array['type'] = 'smokeping_in';
$graph_array['device'] = $device['device_id'];
$graph_array['src'] = $host['device_id'];
include 'includes/html/print-graphrow.inc.php';
echo '</td></tr>';
}
}
}//end if
} elseif ($vars['view'] == 'outgoing') {
if (count($smokeping_files['out'][$device['hostname']])) {
$graph_array['type'] = 'device_smokeping_out_all_avg';
$graph_array['device'] = $device['device_id'];
echo '<tr><td>';
echo '<h3>Average</h3>';
include 'includes/html/print-graphrow.inc.php';
echo '</td></tr>';
$graph_array['type'] = 'device_smokeping_out_all';
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
echo '<tr><td>';
echo '<h3>Aggregate</h3>';
include 'includes/html/print-graphrow.inc.php';
echo '</td></tr>';
unset($graph_array['legend']);
asort($smokeping_files['out'][$device['hostname']]);
foreach ($smokeping_files['out'][$device['hostname']] as $host) {
$hostname = str_replace('_', '.', str_replace('.rrd', '', $host));
list($hostname) = explode('~', $hostname);
$host = device_by_name($hostname);
if (is_numeric($host['device_id'])) {
echo '<tr><td>';
echo '<h3>'.generate_device_link($host).'</h3>';
$graph_array['type'] = 'smokeping_out';
$graph_array['device'] = $device['device_id'];
$graph_array['dest'] = $host['device_id'];
include 'includes/html/print-graphrow.inc.php';
echo '</td></tr>';
}
}
}//end if
}//end if
echo '</table>';
$pagetitle[] = 'Latency';

View File

@ -1,213 +0,0 @@
<?php
/*
* LibreNMS
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2017 LibreNMS
* @author LibreNMS Contributors
*/
if (!isset($vars['section'])) {
$vars['section'] = "performance";
}
if (empty($vars['dtpickerfrom'])) {
$vars['dtpickerfrom'] = date(\LibreNMS\Config::get('dateformat.byminute'), time() - 3600 * 24 * 2);
}
if (empty($vars['dtpickerto'])) {
$vars['dtpickerto'] = date(\LibreNMS\Config::get('dateformat.byminute'));
}
?>
<br>
<div class="panel panel-default">
<div class="panel-heading">
<form method="post" role="form" id="map" class="form-inline">
<?php echo csrf_field() ?>
<div class="form-group">
<label for="dtpickerfrom">From</label>
<input type="text" class="form-control" id="dtpickerfrom" name="dtpickerfrom" maxlength="16"
value="<?php echo $vars['dtpickerfrom']; ?>" data-date-format="YYYY-MM-DD HH:mm">
</div>
<div class="form-group">
<label for="dtpickerto">To</label>
<input type="text" class="form-control" id="dtpickerto" name="dtpickerto" maxlength=16
value="<?php echo $vars['dtpickerto']; ?>" data-date-format="YYYY-MM-DD HH:mm">
</div>
<input type="submit" class="btn btn-default" id="submit" value="Update">
</form>
</div>
<br>
<div style="margin:0 auto;width:99%;">
<script type="text/javascript">
$(function () {
$("#dtpickerfrom").datetimepicker({
useCurrent: true,
sideBySide: true,
useStrict: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#dtpickerto").datetimepicker({
useCurrent: true,
sideBySide: true,
useStrict: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
});
</script>
<?php
if (Auth::user()->hasGlobalRead()) {
$query = "SELECT DATE_FORMAT(timestamp, '" . \LibreNMS\Config::get('alert_graph_date_format') . "') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?";
$param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']);
} else {
$query = "SELECT DATE_FORMAT(timestamp, '" . \LibreNMS\Config::get('alert_graph_date_format') . "') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_perf`.`device_id` = ? AND `device_perf`.`device_id` = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?";
$param = array($device['device_id'], Auth::id(), $vars['dtpickerfrom'], $vars['dtpickerto']);
}
?>
<script src="js/vis.min.js"></script>
<div id="visualization" style="margin-bottom:-120px;"></div>
<script type="text/javascript">
var container = document.getElementById('visualization');
<?php
$groups = array();
$max_val = 0;
foreach (dbFetchRows($query, $param) as $return_value) {
$date = $return_value['Date'];
$loss = $return_value['loss'];
$min = $return_value['min'];
$max = $return_value['max'];
$avg = $return_value['avg'];
if ($max > $max_val) {
$max_val = $max;
}
$data[] = array('x' => $date, 'y' => $loss, 'group' => 0);
$data[] = array('x' => $date, 'y' => $min, 'group' => 1);
$data[] = array('x' => $date, 'y' => $max, 'group' => 2);
$data[] = array('x' => $date, 'y' => $avg, 'group' => 3);
}
$graph_data = _json_encode($data);
?>
var names = ['Loss', 'Min latency', 'Max latency', 'Avg latency'];
var groups = new vis.DataSet();
groups.add({
id: 0,
content: names[0],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
groups.add({
id: 1,
content: names[1],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
groups.add({
id: 2,
content: names[2],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
groups.add({
id: 3,
content: names[3],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
<?php
?>
var items =
<?php
echo $graph_data; ?>
;
var dataset = new vis.DataSet(items);
var options = {
barChart: {width: 50, align: 'right'}, // align: left, center, right
drawPoints: false,
legend: {left: {position: "bottom-left"}},
dataAxis: {
icons: true,
showMajorLabels: true,
showMinorLabels: true,
},
zoomMin: 86400, //24hrs
zoomMax: <?php
$first_date = reset($data);
$last_date = end($data);
$milisec_diff = abs(strtotime($first_date['x']) - strtotime($last_date['x'])) * 1000;
echo $milisec_diff;
?>,
orientation: 'top'
};
var graph2d = new vis.Graph2d(container, dataset, groups, options);
</script>

View File

@ -5,32 +5,7 @@ use LibreNMS\Config;
use Symfony\Component\Process\Process;
if (Auth::user()->hasGlobalAdmin()) {
if (Config::has('rancid_configs') && !is_array(Config::get('rancid_configs'))) {
Config::set('rancid_configs', (array)Config::get('rancid_configs', []));
}
if (Config::has('rancid_configs.0')) {
foreach (Config::get('rancid_configs') as $configs) {
if ($configs[(strlen($configs) - 1)] != '/') {
$configs .= '/';
}
if (is_file($configs.$device['hostname'])) {
$file = $configs.$device['hostname'];
break;
} elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain
$file = $configs.strtok($device['hostname'], '.');
break;
} else {
if (!empty(Config::get('mydomain'))) { // Try with domain name if set
if (is_file($configs.$device['hostname'].'.'.Config::get('mydomain'))) {
$file = $configs.$device['hostname'].'.'.Config::get('mydomain');
break;
}
}
} // end if
}
if (!empty($rancid_file)) {
echo '<div style="clear: both;">';
print_optionbar_start('', '');
@ -47,7 +22,7 @@ if (Auth::user()->hasGlobalAdmin()) {
if (Config::get('rancid_repo_type') == 'svn' && function_exists('svn_log')) {
$sep = ' | ';
$svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8);
$svnlogs = svn_log($rancid_file, SVN_REVISION_HEAD, null, 8);
$revlist = array();
foreach ($svnlogs as $svnlog) {
@ -71,7 +46,7 @@ if (Auth::user()->hasGlobalAdmin()) {
if (Config::get('rancid_repo_type') == 'git') {
$sep = ' | ';
$process = new Process(array('git', 'log', '-n 8', '--pretty=format:%h;%ct', $file), $configs);
$process = new Process(array('git', 'log', '-n 8', '--pretty=format:%h;%ct', $rancid_file), $configs);
$process->run();
$gitlogs_raw = explode(PHP_EOL, $process->getOutput());
$gitlogs = array();
@ -106,7 +81,7 @@ if (Auth::user()->hasGlobalAdmin()) {
if (Config::get('rancid_repo_type') == 'svn') {
if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) {
list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']);
list($diff, $errors) = svn_diff($rancid_file, ($vars['rev'] - 1), $rancid_file, $vars['rev']);
if (!$diff) {
$text = 'No Difference';
} else {
@ -119,13 +94,13 @@ if (Auth::user()->hasGlobalAdmin()) {
fclose($errors);
}
} else {
$fh = fopen($file, 'r') or die("Can't open file");
$text = fread($fh, filesize($file));
$fh = fopen($rancid_file, 'r') or die("Can't open file");
$text = fread($fh, filesize($rancid_file));
fclose($fh);
}
} elseif (Config::get('rancid_repo_type') == 'git') {
if (in_array($vars['rev'], $revlist)) {
$process = new Process(array('git', 'diff', $vars['rev'] . '^', $vars['rev'], $file), $configs);
$process = new Process(array('git', 'diff', $vars['rev'] . '^', $vars['rev'], $rancid_file), $configs);
$process->run();
$diff = $process->getOutput();
if (!$diff) {
@ -135,8 +110,8 @@ if (Auth::user()->hasGlobalAdmin()) {
$previous_config = $vars['rev'] . '^';
}
} else {
$fh = fopen($file, 'r') or die("Can't open file");
$text = fread($fh, filesize($file));
$fh = fopen($rancid_file, 'r') or die("Can't open file");
$text = fread($fh, filesize($rancid_file));
fclose($fh);
}
}

View File

@ -23,12 +23,17 @@ if (isset($base_url['path']) && strlen($base_url['path']) > 1) {
foreach ($segments as $pos => $segment) {
$segment = urldecode($segment);
if ($pos == '0') {
if ($pos === 0) {
$vars['page'] = $segment;
} else {
list($name, $value) = explode('=', $segment);
if ($value == '' || !isset($value)) {
$vars[$name] = 'yes';
if ($vars['page'] == 'device' && $pos < 3) {
// translate laravel device routes properly
$vars[$pos === 1 ? 'device' : 'tab'] = $name;
} else {
$vars[$name] = 'yes';
}
} else {
$vars[$name] = $value;
}

View File

@ -3221,6 +3221,28 @@
"new": "New"
}
},
"html.device.primary_link": {
"group": "webui",
"section": "device",
"order": 3,
"type": "select",
"default": "edit",
"options": {
"edit": "Edit",
"web": "Web",
"ssh": "SSH",
"telnet": "Telnet",
"capture": "Capture",
"custom1": "Custom 1",
"custom2": "Custom 2",
"custom3": "Custom 3",
"custom4": "Custom 4",
"custom5": "Custom 5",
"custom6": "Custom 6",
"custom7": "Custom 7",
"custom8": "Custom 8"
}
},
"html_dir": {
"type": "text"
},
@ -4503,10 +4525,6 @@
"default": true,
"type": "boolean"
},
"show_overview_tab": {
"default": true,
"type": "boolean"
},
"show_services": {
"default": false,
"type": "boolean"

View File

@ -675,6 +675,14 @@ return [
'help' => 'This is used to automatically create the base_uri for the Graylog API. If you have modified the API uri from the default, set this to other and specify your base_uri.'
]
],
'html' => [
'device' => [
'primary_link' => [
'description' => 'Primary Dropdown Link',
'help' => 'Sets the primary link in the device dropdown menu'
]
],
],
'http_proxy' => [
'description' => 'HTTP(S) Proxy',
'help' => 'Set this as a fallback if http_proxy or https_proxy environment variable is not available.'

View File

@ -0,0 +1,5 @@
<?php
return [
'in' => 'Incoming',
'out' => 'Outgoing',
];

View File

@ -0,0 +1,24 @@
<div class="panel panel-default">
<div class="panel-body {{ $alert_class }}">
<img src="{{ url($device->logo()) }}" title="{{ $device->logo() }}" class="device-icon-header pull-left" style="max-height: 100px">
<div class="pull-left" style="margin-top: 5px;">
@if($parent_id)
<a href="{{ route('device', $parent_id) }}" title="@lang('VM Host')"><i class="fa fa-server fa-fw fa-lg"></i></a>
@endif
@if(\LibreNMS\Alert\AlertUtil::isMaintenance($device_id))
<span title="@lang('Scheduled Maintenance')" class="fa fa-wrench fa-fw fa-lg"></span>
@endif
<span style="font-size: 20px;">@deviceLink($device)</span><br/>
<a href="{{ url('/devices/location=' . $device->location) }}">{{ $device->location }}</a>
</div>
<div class="pull-right">
@foreach($overview_graphs as $graph)
<div style='float: right; text-align: center; padding: 1px 5px; margin: 0 1px; ' class='rounded-5px'>
<div style="width: {{ $graph['width'] }}px; height: {{ $graph['height'] }}px;">{!! \LibreNMS\Util\Url::graphPopup($graph) !!}</div>
<div style='font-weight: bold; font-size: 7pt; margin: -3px;'>{{ $graph['popup_title'] }}</div>
</div>
@endforeach
<br style="clear: both;"/>
</div>
</div>
</div>

View File

@ -0,0 +1,58 @@
@extends('layouts.librenmsv1')
@section('title', $device->displayName() . ' ' . $title)
@section('content')
<div class="container-fluid">
@include('device.header')
<ul class="nav nav-tabs">
@foreach($tabs as $tab)
@if($tab->visible($device))
<li role="presentation" @if( $current_tab == $tab->slug() ) class="active" @endif>
<a href="{{ route('device', [$device_id, $tab->slug()]) }}">
<i class="fa {{ $tab->icon() }} fa-lg icon-theme" aria-hidden="true"></i>&nbsp;{{ $tab->name() }}&nbsp;</a>
</li>
@endif
@endforeach
<div class="btn-group pull-right" role="group">
<a href="{{ $primary_device_link['url'] }}"
class="btn btn-default"
type="button"
@if(isset($primary_device_link['onclick']))onclick="{{ $primary_device_link['onclick'] }}" @endif
@if($primary_device_link['external'])target="_blank" rel="noopener" @endif
title="{{ $primary_device_link['title'] }}"
> <i class="fa {{ $primary_device_link['icon'] }} fa-lg icon-theme"></i>
</a>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
&nbsp;<i class="fa fa-ellipsis-v fa-lg icon-theme"></i>&nbsp;
</button>
<ul class="dropdown-menu dropdown-menu-right">
@foreach($device_links as $link)
<li><a href="{{ $link['url'] }}"
@if(isset($link['onclick']))onclick="{{ $link['onclick'] }}" @endif
@if($link['external'])target="_blank" rel="noopener" @endif
><i class="fa {{ $link['icon'] }} fa-lg fa-fw icon-theme" aria-hidden="true"></i> {{ $link['title'] }}</a></li>
@endforeach
</ul>
</div>
</div>
</ul>
<div class="tab-content">
<div class="tab-pane active">
@yield('tab')
</div>
</div>
</div>
@endsection
@section('css')
<style>
.tab-content {
margin-top: 8px;
}
</style>
@endsection

View File

@ -0,0 +1,222 @@
@extends('device.index')
@section('tab')
@if($data['smokeping']->hasGraphs())
<div class="panel with-nav-tabs panel-default">
<div class="panel-heading">
<span class="panel-title">@lang('Smokeping')</span>
<ul class="nav nav-tabs" style="display: inline-block">
@foreach($data['smokeping_tabs'] as $tab)
<li @if($loop->first) class="active" @endif><a href="#{{ $tab }}" data-toggle="tab">@lang('smokeping.' . $tab)</a></li>
@endforeach
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
@foreach($data['smokeping_tabs'] as $direction)
<div class="tab-pane fade in @if($loop->first) active @endif" id="{{ $direction }}">
<div class="row">
<div class="col-md-12">
<h3>Average</h3>
</div>
</div>
<div class="row">
@foreach(\LibreNMS\Util\Html::graphRow(['type' => "device_smokeping_{$direction}_all_avg", 'device' => $device->device_id]) as $graph)
<div class='col-md-3'>{!! $graph !!}</div>
@endforeach
</div>
<div class="row">
<div class="col-md-12">
<h3>Aggregate</h3>
</div>
</div>
<div class="row">
@foreach(\LibreNMS\Util\Html::graphRow(['type' => "device_smokeping_{$direction}_all", 'device' => $device->device_id, 'legend' => 'no']) as $graph)
<div class='col-md-3'>{!! $graph !!}</div>
@endforeach
</div>
@foreach($data['smokeping']->otherGraphs($direction) as $info)
<div class="row">
<div class="col-md-12">
<h3>@deviceLink($info['device'])</h3>
</div>
</div>
<div class="row">
@foreach(\LibreNMS\Util\Html::graphRow($info['graph']) as $graph)
<div class='col-md-3'>{!! $graph !!}</div>
@endforeach
</div>
@endforeach
</div>
@endforeach
</div>
</div>
</div>
@endif
<div class="panel panel-default">
<div class="panel-heading">
@csrf
<span class="panel-title" style="line-height: 34px">@lang('Performance')</span>
<span class="pull-right">
<form method="post" role="form" id="map" class="form-inline">
<div class="form-group">
<label for="dtpickerfrom">@lang('From')</label>
<input type="text" class="form-control" id="dtpickerfrom" name="dtpickerfrom" maxlength="16"
value="{{ $data['dtpickerfrom'] }}" data-date-format="YYYY-MM-DD HH:mm">
</div>
<div class="form-group">
<label for="dtpickerto">@lang('To')</label>
<input type="text" class="form-control" id="dtpickerto" name="dtpickerto" maxlength=16
value="{{ $data['dtpickerto'] }} " data-date-format="YYYY-MM-DD HH:mm">
</div>
<input type="submit" class="btn btn-default" id="submit" value="Update">
</form>
</span>
</div>
<div class="panel-body">
<div id="performance"></div>
</div>
</div>
@endsection
@section('javascript')
<script src="{{ url('js/vis.min.js') }}"></script>
@endsection
@push('scripts')
<script type="text/javascript">
var container = document.getElementById('performance');
var names = ['Loss', 'Min latency', 'Max latency', 'Avg latency'];
var groups = new vis.DataSet();
groups.add({
id: 0,
content: names[0],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
groups.add({
id: 1,
content: names[1],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
groups.add({
id: 2,
content: names[2],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
groups.add({
id: 3,
content: names[3],
options: {
drawPoints: {
style: 'circle'
},
shaded: {
orientation: 'bottom'
}
}
});
var items = @json($data['perfdata']);
var dataset = new vis.DataSet(items);
var options = {
barChart: {width: 50, align: 'right'}, // align: left, center, right
drawPoints: false,
legend: {left: {position: "bottom-left"}},
dataAxis: {
icons: true,
showMajorLabels: true,
showMinorLabels: true,
},
zoomMin: 86400, //24hrs
zoomMax: {{ $data['duration'] }},
orientation: 'top'
};
var graph2d = new vis.Graph2d(container, dataset, groups, options);
$(function () {
$("#dtpickerfrom").datetimepicker({
useCurrent: true,
sideBySide: true,
useStrict: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
$("#dtpickerto").datetimepicker({
useCurrent: true,
sideBySide: true,
useStrict: false,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-trash-o',
close: 'fa fa-close'
}
});
});
</script>
@endpush
@push('styles')
<style>
.panel.with-nav-tabs .panel-title {
vertical-align: top; /* otherwise pushes tabs off bottom */
margin: 10px;
display: inline-block;
}
.panel.with-nav-tabs .panel-heading {
padding: 5px 5px 0 5px;
}
.panel.with-nav-tabs .nav-tabs {
border-bottom: none;
margin-bottom: -5px;
}
.panel.with-nav-tabs .nav-tabs > li > a {
padding-right: 10px;
}
.panel.with-nav-tabs .nav-justified {
margin-bottom: -1px;
}
</style>
@endpush

View File

@ -0,0 +1,5 @@
@extends('device.index')
@section('tab')
{!! $tab_content !!}
@endsection

View File

@ -34,6 +34,8 @@ Route::group(['middleware' => ['auth', '2fa'], 'guard' => 'auth'], function () {
Route::get('authlog', 'UserController@authlog');
Route::get('overview', 'OverviewController@index')->name('overview');
Route::get('/', 'OverviewController@index');
Route::match(['get', 'post'], 'device/{device_id}/{tab?}/{vars?}', 'DeviceController@index')
->name('device')->where(['device_id' => '(device=)?[0-9]+', 'vars' => '.*']);
// Maps
Route::group(['prefix' => 'maps', 'namespace' => 'Maps'], function () {