Replace legacy menu with new Blade generated one (#10173)

* Remove legacy index php file

* fix routing page missing data

* WIP

* fix $navbar global usage

* remove global use of $locations

* ObjectCache again...

* move vars.inc.php to init.php for legacy ajax

* navbar is more local than I thought before.  Fix it.

* Fix some sensors tables escaping

* restore custom menu functionality, but with blade
and docs

* cleanup

* tidy menu @if checks

* Fix up the rest of the global variables and remove print-menubar.php

* consolidate some counting in the menu

* filter out empty custom port descr types

* Fix up custom port groups

* Fix up apps menu

* Fix services menu when all are ok

* Limit cached data to the user it is for

* Fix style

* A few clean ups

* fix pseudowire bug
This commit is contained in:
Tony Murray 2019-05-10 11:02:39 -05:00 committed by GitHub
parent 966ce85c19
commit 9ede688d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 597 additions and 1513 deletions

View File

@ -0,0 +1,214 @@
<?php
/**
* ObjectCache.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 2019 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Util;
use App\Models\Application;
use App\Models\BgpPeer;
use App\Models\CefSwitching;
use App\Models\Component;
use App\Models\Device;
use App\Models\OspfInstance;
use App\Models\Port;
use App\Models\Pseudowire;
use App\Models\Sensor;
use App\Models\Service;
use App\Models\User;
use App\Models\Vrf;
use Cache;
class ObjectCache
{
private static $cache_time = 5;
public static function applications()
{
return Cache::remember('ObjectCache:applications_list:' . auth()->id(), self::$cache_time, function () {
return Application::hasAccess(auth()->user())
->select('app_type', 'app_instance')
->groupBy('app_type', 'app_instance')
->orderBy('app_type')
->get()
->groupBy('app_type');
});
}
public static function routing()
{
return Cache::remember('ObjectCache:routing_counts:' . auth()->id(), self::$cache_time, function () {
$user = auth()->user();
return [
'vrf' => Vrf::hasAccess($user)->count(),
'ospf' => OspfInstance::hasAccess($user)->count(),
'cisco-otv' => Component::hasAccess($user)->where('type', 'Cisco-OTV')->count(),
'bgp' => BgpPeer::hasAccess($user)->count(),
'cef' => CefSwitching::hasAccess($user)->count(),
];
});
}
public static function sensors()
{
return Cache::remember('ObjectCache:sensor_list:' . auth()->id(), self::$cache_time, function () {
$sensor_classes = Sensor::hasAccess(auth()->user())->select('sensor_class')->groupBy('sensor_class')->orderBy('sensor_class')->get();
$sensor_menu = [];
foreach ($sensor_classes as $sensor_model) {
/** @var Sensor $sensor_model */
$class = $sensor_model->sensor_class;
if (in_array($class, ['fanspeed', 'humidity', 'temperature', 'signal'])) {
// First group
$group = 0;
} elseif (in_array($class, ['current', 'frequency', 'power', 'voltage', 'power_factor', 'power_consumed'])) {
// Second group
$group = 1;
} else {
// anything else
$group = 2;
}
$sensor_menu[$group][] = [
'class' => $class,
'icon' => $sensor_model->icon(),
'descr' => $sensor_model->classDescr()
];
}
ksort($sensor_menu); // ensure menu order
return $sensor_menu;
});
}
/**
* @param int $device_id device id of the device to get counts for, 0 means all
* @param array $fields array of counts to get. Valid options: total, up, down, ignored, shutdown, disabled, deleted, errored, pseudowire
* @return mixed
*/
public static function portCounts($fields = ['total'], $device_id = 0)
{
$result = [];
foreach ($fields as $field) {
$result[$field] = self::getPortCount($field, $device_id);
}
return $result;
}
private static function getPortCount($field, $device_id)
{
return Cache::remember("ObjectCache:port_{$field}_count:$device_id:" . auth()->id(), self::$cache_time, function () use ($field, $device_id) {
$query = Port::hasAccess(auth()->user())->when($device_id, function ($query) use ($device_id) {
$query->where('device_id', $device_id);
});
switch ($field) {
case 'down':
return $query->isNotDeleted()->isDown()->count();
case 'up':
return $query->isNotDeleted()->isUp()->count();
case 'ignored':
return $query->isNotDeleted()->isIgnored()->count();
case 'shutdown':
return $query->isNotDeleted()->isShutdown()->count();
case 'disabled':
return $query->isNotDeleted()->isDisabled()->count();
case 'deleted':
return $query->isDeleted()->count();
case 'errored':
return $query->isNotDeleted()->hasErrors()->count();
case 'pseudowire':
return Pseudowire::hasAccess(auth()->user())->count();
case 'total':
default:
return $query->isNotDeleted()->count();
}
});
}
/**
* @param array $fields array of counts to get. Valid options: total, up, down, ignored, disabled
* @return array
*/
public static function deviceCounts($fields = ['total'])
{
$result = [];
foreach ($fields as $field) {
$result[$field] = self::getDeviceCount($field);
}
return $result;
}
private static function getDeviceCount($field)
{
return Cache::remember("ObjectCache:device_{$field}_count:" . auth()->id(), self::$cache_time, function () use ($field) {
$query = Device::hasAccess(auth()->user());
switch ($field) {
case 'down':
return $query->isDown()->count();
case 'up':
return $query->isUp()->count();
case 'ignored':
return $query->isIgnored()->count();
case 'disabled':
return $query->isDisabled()->count();
case 'total':
default:
return $query->count();
}
});
}
/**
* @param array $fields array of counts to get. Valid options: total, ok, warning, critical, ignored, disabled
* @return array
*/
public static function serviceCounts($fields = ['total'])
{
$result = [];
foreach ($fields as $field) {
$result[$field] = self::getServiceCount($field);
}
return $result;
}
private static function getServiceCount($field)
{
return Cache::remember("ObjectCache:service_{$field}_count:" . auth()->id(), self::$cache_time, function () use ($field) {
$query = Service::hasAccess(auth()->user());
switch ($field) {
case 'ok':
return $query->isOk()->count();
case 'warning':
return $query->isWarning()->count();
case 'critical':
return $query->isCritical()->count();
case 'ignored':
return $query->isIgnored()->count();
case 'disabled':
return $query->isDisabled()->count();
case 'total':
default:
return $query->count();
}
});
}
}

View File

@ -3,32 +3,84 @@
namespace App\Http\Controllers;
use App\Checks;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use LibreNMS\Config;
class LegacyController extends Controller
{
public function index($path = '')
public function index(Request $request, Session $session)
{
Checks::postAuth();
ob_start();
include base_path('html/legacy_index.php');
$html = ob_get_clean();
// Set variables
$no_refresh = false;
$init_modules = ['web', 'auth'];
require base_path('/includes/init.php');
return response($html);
set_debug(str_contains($request->path(), 'debug'));
\LibreNMS\Plugins::start();
if (str_contains($request->path(), 'widescreen=yes')) {
$session->put('widescreen', 1);
}
if (str_contains($request->path(), 'widescreen=no')) {
$session->forget('widescreen');
}
# Load the settings for Multi-Tenancy.
if (Config::has('branding') && is_array(Config::get('branding'))) {
$branding = Arr::dot(Config::get('branding.' . $request->server('SERVER_NAME'), Config::get('branding.default')));
foreach ($branding as $key => $value) {
Config::set($key, $value);
}
}
# page_title_prefix is displayed, unless page_title is set FIXME: NEEDED?
if (Config::has('page_title')) {
Config::set('page_title_prefix', Config::get('page_title'));
}
// render page
ob_start();
$vars['page'] = basename($vars['page'] ?? '');
if ($vars['page'] && is_file("includes/html/pages/" . $vars['page'] . ".inc.php")) {
require "includes/html/pages/" . $vars['page'] . ".inc.php";
} elseif (Config::has('front_page') && is_file('includes/html/' . Config::get('front_page'))) {
require 'includes/html/' . Config::get('front_page');
} else {
require 'includes/html/pages/front/default.php';
}
$html = ob_get_clean();
ob_end_clean();
if (isset($pagetitle) && is_array($pagetitle)) {
# if prefix is set, put it in front
if (Config::get('page_title_prefix')) {
array_unshift($pagetitle, Config::get('page_title_prefix'));
}
# if suffix is set, put it in the back
if (Config::get('page_title_suffix')) {
$pagetitle[] = Config::get('page_title_suffix');
}
# create and set the title
$title = join(" - ", $pagetitle);
$html .= "<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>";
}
return response()->view('layouts.legacy_page', [
'content' => $html,
'refresh' => $no_refresh ? 0 : Config::get('page_refresh'),
]);
}
public function api($path = '')
{
include base_path('html/legacy_api_v0.php');
}
public function dash()
{
ob_start();
include base_path('html/legacy/ajax_dash.php');
$output = ob_get_contents();
ob_end_clean();
return response($output, 200, ['Content-Type' => 'application/json']);
include base_path('includes/html/legacy_api_v0.php');
}
}

View File

@ -30,6 +30,7 @@ use App\Models\Port;
use App\Models\Service;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Util\ObjectCache;
abstract class DeviceSummaryController extends WidgetController
{
@ -54,33 +55,15 @@ abstract class DeviceSummaryController extends WidgetController
protected function getData(Request $request)
{
$data = $this->getSettings();
$user = $request->user();
$data['devices'] = [
'count' => Device::hasAccess($user)->count(),
'up' => Device::hasAccess($user)->isUp()->count(),
'down' => Device::hasAccess($user)->isDown()->count(),
'ignored' => Device::hasAccess($user)->isIgnored()->count(),
'disabled' => Device::hasAccess($user)->isDisabled()->count(),
];
$data['devices'] = ObjectCache::deviceCounts(['total', 'up', 'down', 'ignored', 'disabled']);
$data['ports'] = [
'count' => Port::hasAccess($user)->isNotDeleted()->count(),
'up' => Port::hasAccess($user)->isNotDeleted()->isUp()->count(),
'down' => Port::hasAccess($user)->isNotDeleted()->isDown()->count(),
'ignored' => Port::hasAccess($user)->isNotDeleted()->isIgnored()->count(),
'shutdown' => Port::hasAccess($user)->isNotDeleted()->isShutdown()->count(),
'errored' => $data['summary_errors'] ? Port::hasAccess($user)->isNotDeleted()->hasErrors()->count() : -1,
];
$data['ports'] = $data['summary_errors'] ?
ObjectCache::portCounts(['total', 'up', 'down', 'ignored', 'shutdown', 'errored']) :
ObjectCache::portCounts(['total', 'up', 'down', 'ignored', 'shutdown']);
if ($data['show_services']) {
$data['services'] = [
'count' => Service::hasAccess($user)->count(),
'up' => Service::hasAccess($user)->isUp()->count(),
'down' => Service::hasAccess($user)->isDown()->count(),
'ignored' => Service::hasAccess($user)->isIgnored()->count(),
'disabled' => Service::hasAccess($user)->isDisabled()->count(),
];
$data['services'] = ObjectCache::serviceCounts(['total', 'ok', 'critical', 'ignored', 'disabled']);
}
return $data;

View File

@ -26,27 +26,18 @@
namespace App\Http\ViewComposers;
use App\Models\AlertRule;
use App\Models\Application;
use App\Models\BgpPeer;
use App\Models\CefSwitching;
use App\Models\Component;
use App\Models\Device;
use App\Models\DeviceGroup;
use App\Models\Location;
use App\Models\Notification;
use App\Models\OspfInstance;
use App\Models\Package;
use App\Models\Port;
use App\Models\Pseudowire;
use App\Models\Sensor;
use App\Models\Service;
use App\Models\User;
use App\Models\Vrf;
use App\Models\WirelessSensor;
use Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;
use LibreNMS\Config;
use LibreNMS\Util\ObjectCache;
class MenuComposer
{
@ -65,7 +56,8 @@ class MenuComposer
$vars['navbar'] = in_array(Config::get('site_style'), ['mono', 'dark']) ? 'navbar-inverse' : '';
$vars['project_name'] = Config::get('project_name', 'LibreNMS');
$vars['title_image'] = asset(Config::get('title_image', 'images/librenms_logo_light.svg'));
$site_style = Config::get('site_style', 'light');
$vars['title_image'] = Config::get('title_image', "images/librenms_logo_$site_style.svg");
// Device menu
$vars['device_groups'] = DeviceGroup::hasAccess($user)->select('device_groups.id', 'name', 'desc')->get();
@ -73,61 +65,34 @@ class MenuComposer
$vars['device_types'] = Device::hasAccess($user)->select('type')->distinct()->get()->pluck('type')->filter();
if (Config::get('show_locations') && Config::get('show_locations_dropdown')) {
$vars['locations'] = Location::hasAccess($user)->select('location')->get()->map->display()->filter();
} else {
$vars['locations'] = [];
}
$vars['locations'] = Config::get('show_locations') && Config::get('show_locations_dropdown') ?
Location::hasAccess($user)->select('location')->get()->map->display()->filter() :
collect();
// Service menu
if (Config::get('show_services')) {
$vars['service_status'] = Service::hasAccess($user)->groupBy('service_status')
->select('service_status', DB::raw('count(*) as count'))
->whereIn('service_status', [1, 2])
->get()
->keyBy('service_status');
$warning = $vars['service_status']->get(1);
$vars['service_warning'] = $warning ? $warning->count : 0;
$critical = $vars['service_status']->get(2);
$vars['service_critical'] = $critical ? $critical->count : 0;
$vars['service_counts'] = ObjectCache::serviceCounts(['warning', 'critical']);
}
// Port menu
$vars['port_counts'] = [
'count' => Port::hasAccess($user)->count(),
'up' => Port::hasAccess($user)->isUp()->count(),
'down' => Port::hasAccess($user)->isDown()->count(),
'shutdown' => Port::hasAccess($user)->isDisabled()->count(),
'errored' => Port::hasAccess($user)->hasErrors()->count(),
'ignored' => Port::hasAccess($user)->isIgnored()->count(),
'deleted' => Port::hasAccess($user)->isDeleted()->count(),
'pseudowire' => Config::get('enable_pseudowires') ? Pseudowire::hasAccess($user)->count() : 0,
'alerted' => 0, // not actually supported on old...
];
$vars['port_counts'] = ObjectCache::portCounts(['errored', 'ignored', 'deleted', 'shutdown', 'down']);
$vars['port_counts']['pseudowire'] = Config::get('enable_pseudowires') ? ObjectCache::portCounts(['pseudowire'])['pseudowire'] : 0;
$vars['port_counts']['alerted'] = 0; // not actually supported on old...
$vars['custom_port_descr'] = collect(\LibreNMS\Config::get('custom_descr', []))
->filter()
->map(function ($descr) {
return strtolower($descr);
});
$vars['port_groups_exist'] = Config::get('int_customers') ||
Config::get('int_transit') ||
Config::get('int_peering') ||
Config::get('int_core') ||
Config::get('int_l2tp') ||
$vars['custom_port_descr']->isNotEmpty();
// Sensor menu
$sensor_menu = [];
$sensor_classes = Sensor::hasAccess($user)->select('sensor_class')->groupBy('sensor_class')->orderBy('sensor_class')->get();
foreach ($sensor_classes as $sensor_model) {
/** @var Sensor $sensor_model */
$class = $sensor_model->sensor_class;
if (in_array($class, ['fanspeed', 'humidity', 'temperature', 'signal'])) {
// First group
$group = 0;
} elseif (in_array($class, ['current', 'frequency', 'power', 'voltage', 'power_factor', 'power_consumed'])) {
// Second group
$group = 1;
} else {
// anything else
$group = 2;
}
$sensor_menu[$group][] = $sensor_model;
}
ksort($sensor_menu); // ensure menu order
$vars['sensor_menu'] = $sensor_menu;
$vars['sensor_menu'] = ObjectCache::sensors();
// Wireless menu
$wireless_menu_order = array_keys(\LibreNMS\Device\WirelessSensor::getTypes());
@ -140,18 +105,15 @@ class MenuComposer
});
// Application menu
$vars['app_menu'] = Application::hasAccess($user)
->select('app_type', 'app_instance')
->groupBy('app_type', 'app_instance')
->orderBy('app_type')
->get()
->groupBy('app_type');
$vars['app_menu'] = ObjectCache::applications();
// Routing menu
// FIXME queries use relationships to user
$routing_menu = [];
if ($user->hasGlobalRead()) {
if (Vrf::hasAccess($user)->count()) {
$routing_count = ObjectCache::routing();
if ($routing_count['vrf']) {
$routing_menu[] = [
[
'url' => 'vrf',
@ -161,7 +123,7 @@ class MenuComposer
];
}
if (OspfInstance::hasAccess($user)->count()) {
if ($routing_count['ospf']) {
$routing_menu[] = [
[
'url' => 'ospf',
@ -171,7 +133,7 @@ class MenuComposer
];
}
if (Component::hasAccess($user)->where('type', 'Cisco-OTV')->count()) {
if ($routing_count['cisco-otv']) {
$routing_menu[] = [
[
'url' => 'cisco-otv',
@ -181,7 +143,7 @@ class MenuComposer
];
}
if (BgpPeer::hasAccess($user)->count()) {
if ($routing_count['bgp']) {
$vars['show_peeringdb'] = Config::get('peeringdb.enabled', false);
$vars['bgp_alerts'] = BgpPeer::hasAccess($user)->inAlarm()->count();
$routing_menu[] = [
@ -206,7 +168,7 @@ class MenuComposer
$vars['bgp_alerts'] = [];
}
if (CefSwitching::hasAccess($user)->count()) {
if ($routing_count['cef']) {
$routing_menu[] = [
[
'url' => 'cef',

View File

@ -15,7 +15,7 @@ class Service extends DeviceRelatedModel
* @param Builder $query
* @return Builder
*/
public function scopeIsUp($query)
public function scopeIsOk($query)
{
return $query->where([
['service_ignore', '=', 0],
@ -28,7 +28,7 @@ class Service extends DeviceRelatedModel
* @param Builder $query
* @return Builder
*/
public function scopeIsDown($query)
public function scopeIsCritical($query)
{
return $query->where([
['service_ignore', '=', 0],
@ -37,6 +37,19 @@ class Service extends DeviceRelatedModel
]);
}
/**
* @param Builder $query
* @return Builder
*/
public function scopeIsWarning($query)
{
return $query->where([
['service_ignore', '=', 0],
['service_disabled', '=', 0],
['service_status', '=', 1],
]);
}
/**
* @param Builder $query
* @return Builder

View File

@ -25,7 +25,7 @@ return [
|
*/
'default' => env('CACHE_DRIVER', 'file'),
'default' => env('CACHE_DRIVER', 'array'),
/*
|--------------------------------------------------------------------------

View File

@ -0,0 +1,30 @@
source: Extensions/Customizing-the-Web-UI.md
path: blob/master/doc/
# Customizing the Web UI
## Custom menu entry
Create the file `resources/views/menu/custom.blade.php`
Example contents:
```blade
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-star fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i>
<span class="hidden-sm">Custom Menu</span></a>
<ul class="dropdown-menu">
@admin
<li><a href="plugins/Weathermap/output/history/index.html"><i class="fa fa-film fa-fw fa-lg" aria-hidden="true"></i> Weathermap Animation</a></li>
<li role="presentation" class="divider"></li>
<li><a href="#"><i class="fa fa-database fa-fw fa-lg" aria-hidden="true"></i> Item 1</a></li>
<li><a href="#"><i class="fa fa-smile-o fa-fw fa-lg" aria-hidden="true"></i> Item 2</a></li>
<li><a href="#"><i class="fa fa-anchor fa-fw fa-lg" aria-hidden="true"></i> Item 3</a></li>
<li><a href="#"><i class="fa fa-plug fa-fw fa-lg" aria-hidden="true"></i> Item 4</a></li>
<li><a href="#"><i class="fa fa-code-fork fa-fw fa-lg" aria-hidden="true"></i> Item 5</a></li>
<li><a href="#"><i class="fa fa-truck fa-fw fa-lg" aria-hidden="true"></i> Item 63</a></li>
@else
<li><a href="#">You need admin rights to see this</a></li>
@endadmin
</ul>
</li>
```

View File

@ -1,348 +0,0 @@
<?php
/**
* LibreNMS
*
* This file is part of LibreNMS.
*
* @package librenms
* @subpackage webinterface
* @copyright (C) 2006 - 2012 Adam Armstrong
*
*/
use LibreNMS\Config;
if (empty($_SERVER['PATH_INFO'])) {
if (strstr($_SERVER['SERVER_SOFTWARE'], "nginx") && isset($_SERVER['PATH_TRANSLATED']) && isset($_SERVER['ORIG_SCRIPT_FILENAME'])) {
$_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'] . $_SERVER['PHP_SELF'], "", $_SERVER['ORIG_SCRIPT_FILENAME']);
} else {
$_SERVER['PATH_INFO'] = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '';
}
}
// Set variables
$msg_box = array();
$init_modules = array('web', 'auth');
require realpath(__DIR__ . '/..') . '/includes/init.php';
if (!Auth::check()) {
die('Unauthorized');
}
set_debug(str_contains($_SERVER['REQUEST_URI'], 'debug'));
LibreNMS\Plugins::start();
$runtime_start = microtime(true);
ob_start();
ini_set('allow_url_fopen', 0);
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) {
$_SESSION['widescreen'] = 1;
}
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) {
unset($_SESSION['widescreen']);
}
# Load the settings for Multi-Tenancy.
if (isset($config['branding']) && is_array($config['branding'])) {
if (isset($config['branding'][$_SERVER['SERVER_NAME']])) {
$config = array_replace_recursive($config, $config['branding'][$_SERVER['SERVER_NAME']]);
} else {
$config = array_replace_recursive($config, $config['branding']['default']);
}
}
# page_title_prefix is displayed, unless page_title is set
if (isset($config['page_title'])) {
$config['page_title_prefix'] = $config['page_title'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title><?php echo($config['page_title_suffix']); ?></title>
<base href="<?php echo($config['base_url']); ?>" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
if (empty($config['favicon'])) {
?>
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="images/manifest.json">
<link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="images/favicon.ico">
<meta name="csrf-token" content="<?php echo csrf_token(); ?>">
<meta name="msapplication-config" content="images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<?php
} else {
echo(' <link rel="shortcut icon" href="'.$config['favicon'].'" />' . "\n");
}
?>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<link href="css/toastr.min.css" rel="stylesheet" type="text/css" />
<link href="css/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.bootgrid.min.css" rel="stylesheet" type="text/css" />
<link href="css/tagmanager.css" rel="stylesheet" type="text/css" />
<link href="css/mktree.css" rel="stylesheet" type="text/css" />
<link href="css/vis.min.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.gridster.min.css" rel="stylesheet" type="text/css" />
<link href="css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="css/MarkerCluster.css" rel="stylesheet" type="text/css" />
<link href="css/MarkerCluster.Default.css" rel="stylesheet" type="text/css" />
<link href="css/L.Control.Locate.min.css" rel="stylesheet" type="text/css" />
<link href="css/leaflet.awesome-markers.css" rel="stylesheet" type="text/css" />
<link href="css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/query-builder.default.min.css" rel="stylesheet" type="text/css" />
<link href="<?php echo($config['stylesheet']); ?>?ver=20190123" rel="stylesheet" type="text/css" />
<link href="css/<?php echo $config['site_style']; ?>.css?ver=632417642" rel="stylesheet" type="text/css" />
<?php
foreach ((array)$config['webui']['custom_css'] as $custom_css) {
echo '<link href="' . $custom_css . '" rel="stylesheet" type="text/css" />';
}
?>
<script src="js/polyfill.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-hover-dropdown.min.js"></script>
<script src="js/bootstrap-switch.min.js"></script>
<script src="js/hogan-2.0.0.js"></script>
<script src="js/jquery.cycle2.min.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/bootstrap-datetimepicker.min.js"></script>
<script src="js/typeahead.bundle.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/tagmanager.js"></script>
<script src="js/mktree.js"></script>
<script src="js/jquery.bootgrid.min.js"></script>
<script src="js/handlebars.min.js"></script>
<script src="js/pace.min.js"></script>
<script src="js/qrcode.min.js"></script>
<?php
if ($config['enable_lazy_load'] === true) {
?>
<script src="js/jquery.lazyload.min.js"></script>
<script src="js/lazyload.js"></script>
<?php
}
?>
<script src="js/select2.min.js"></script>
<script src="js/librenms.js?ver=20190123"></script>
<script type="text/javascript">
<!-- Begin
function popUp(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
}
// End -->
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
</script>
<script type="text/javascript" src="js/overlib_mini.js"></script>
<script type="text/javascript" src="js/toastr.min.js"></script>
</head>
<body>
<?php
if (empty($_SESSION['screen_width']) && empty($_SESSION['screen_height'])) {
echo "<script>updateResolution();</script>";
}
if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) {
if (Auth::check()) {
require 'includes/html/print-menubar.php';
}
} else {
echo "<style>body { padding-top: 0px !important;
padding-bottom: 0px !important; }</style>";
}
?>
<br />
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<?php
// To help debug the new URLs :)
if (isset($devel) || isset($vars['devel'])) {
echo("<pre>");
print_r($_GET);
print_r($vars);
echo("</pre>");
}
$vars['page'] = basename($vars['page'] ?? '');
if ($vars['page'] && is_file("includes/html/pages/" . $vars['page'] . ".inc.php")) {
require "includes/html/pages/" . $vars['page'] . ".inc.php";
} elseif (Config::has('front_page') && is_file('includes/html/' . Config::get('front_page'))) {
require 'includes/html/' . Config::get('front_page');
} else {
require 'includes/html/pages/front/default.php';
}
?>
</div>
</div>
</div>
<?php
$runtime_end = microtime(true);
$runtime = $runtime_end - $runtime_start;
$gentime = substr($runtime, 0, 5);
# FIXME - move this
if ($config['page_gen']) {
echo '<br />';
printStats();
$fullsize = memory_get_usage();
unset($cache);
$cachesize = $fullsize - memory_get_usage();
if ($cachesize < 0) {
$cachesize = 0;
} // Silly PHP!
echo(' <br />Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.');
echo(' <br />Generated in ' . $gentime . ' seconds.');
}
if (isset($pagetitle) && is_array($pagetitle)) {
# if prefix is set, put it in front
if ($config['page_title_prefix']) {
array_unshift($pagetitle, $config['page_title_prefix']);
}
# if suffix is set, put it in the back
if ($config['page_title_suffix']) {
$pagetitle[] = $config['page_title_suffix'];
}
# create and set the title
$title = join(" - ", $pagetitle);
echo("<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>");
}
?>
<?php
if ($config['enable_footer'] == 1 && (isset($vars['bare']) && $vars['bare'] != "yes")) {
?>
<nav class="navbar navbar-default <?php echo $navbar; ?> navbar-fixed-bottom">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<?php
echo('<h5>Powered by <a href="' . $config['project_home'] . '" target="_blank" rel="noopener" class="red">' . $config['project_name'].'</a>.</h5>');
?>
</div>
</div>
</div>
</nav>
<?php
}
if (is_array($msg_box)) {
echo "<script>
toastr.options.timeout = 10;
toastr.options.extendedTimeOut = 20;
</script>
";
foreach ($msg_box as $message) {
Toastr::add($message['type'], $message['message'], $message['title']);
}
}
if ($no_refresh !== true && $config['page_refresh'] != 0) {
$refresh = $config['page_refresh'] * 1000;
echo('<script type="text/javascript">
$(document).ready(function() {
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i> Pause");
var Countdown = {
sec: '. $config['page_refresh'] .',
Start: function() {
var cur = this;
this.interval = setInterval(function() {
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i> Pause");
cur.sec -= 1;
display_time = cur.sec;
if (display_time == 0) {
location.reload();
}
if (display_time % 1 === 0 && display_time <= 300) {
$("#countdown_timer").html("<i class=\"fa fa-clock-o fa-fw fa-lg\"></i> Refresh in " + display_time);
}
}, 1000);
},
Pause: function() {
clearInterval(this.interval);
$("#countdown_timer_status").html("<i class=\"fa fa-play fa-fw fa-lg\"></i> Resume");
delete this.interval;
},
Resume: function() {
if (!this.interval) this.Start();
}
};
Countdown.Start();
$("#countdown_timer_status").click("", function(event) {
event.preventDefault();
if (Countdown.interval) {
Countdown.Pause();
} else {
Countdown.Resume();
}
});
$("#countdown_timer").click("", function(event) {
event.preventDefault();
});
});
</script>');
} else {
echo('<script type="text/javascript">
var no_refresh = ' . var_export((bool)$no_refresh, true) . ';
$(document).ready(function() {
$("#countdown_timer").html("Refresh disabled");
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i>");
$("#countdown_timer_status").click("", function(event) {
event.preventDefault();
});
});
</script>');
}
echo Toastr::render();
?>
</body>
</html>

View File

@ -59,6 +59,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
if (!LegacyAuth::check()) {
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n";
} else {
$locations = getlocations();
$loc_count = 1;
foreach (dbFetch("SELECT *, locations.location FROM devices LEFT JOIN locations ON devices.location_id = locations.id WHERE 1 ".$where, $param) as $device) {
if ($device) {

View File

@ -888,8 +888,8 @@ $config['allow_duplicate_sysName'] = false;// Set to true if you want to allow d
$config['enable_port_relationship'] = true;
// Set this to false to not display neighbour relationships for ports
$config['enable_footer'] = 1;
// Set this to 0 if you want to disable the footer copyright in the web interface
$config['enable_footer'] = false;
// Set this to true if you want to enable the footer in the web interface
$config['api_demo'] = 0;
// Set this to 1 if you want to disable some untrusting features for the API
// Distributed Poller-Settings

View File

@ -287,22 +287,24 @@ $link_array = array(
'device' => $device['device_id'],
'tab' => 'apps',
);
foreach ($app_list as $app) {
$apps = \LibreNMS\Util\ObjectCache::applications()->flatten()->sortBy('app_type');
foreach ($apps as $app) {
echo $sep;
if ($vars['app'] == $app['app_type']) {
if ($vars['app'] == $app->app_type) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type']));
if ($vars['app'] == $app['app_type']) {
echo generate_link($app->displayName(), array('page' => 'apps', 'app' => $app->app_type));
if ($vars['app'] == $app->app_type) {
echo '</span>';
}
$sep = ' | ';
}
echo '</div>';
echo '<div class="panel-body">';
if ($vars['app']) {
if (is_file('includes/html/pages/apps/'.mres($vars['app']).'.inc.php')) {
include 'includes/html/pages/apps/'.mres($vars['app']).'.inc.php';
if (isset($vars['app'])) {
$app = basename($vars['app']);
if (is_file("includes/html/pages/apps/$app.inc.php")) {
include "includes/html/pages/apps/$app.inc.php";
} else {
include 'includes/html/pages/apps/default.inc.php';
}

View File

@ -9,24 +9,24 @@ $graph_array_zoom['height'] = '150';
$graph_array_zoom['width'] = '400';
$graph_array['legend'] = 'no';
foreach ($app_list as $app) {
foreach ($apps as $app) {
echo '<div style="clear: both;">';
echo '<h2>'.generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])).'</h2>';
$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($app['app_type']));
echo '<h2>'.generate_link($app->displayName(), array('page' => 'apps', 'app' => $app->app_type)).'</h2>';
$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($app->app_type));
foreach ($app_devices as $app_device) {
$graph_type = $graphs[$app['app_type']][0];
$graph_type = $graphs[$app->app_type][0];
$graph_array['type'] = 'application_'.$app['app_type'].'_'.$graph_type;
$graph_array['type'] = 'application_'.$app->app_type.'_'.$graph_type;
$graph_array['id'] = $app_device['app_id'];
$graph_array_zoom['type'] = 'application_'.$app['app_type'].'_'.$graph_type;
$graph_array_zoom['type'] = 'application_'.$app->app_type.'_'.$graph_type;
$graph_array_zoom['id'] = $app_device['app_id'];
$link_array = $graph_array;
$link_array['page'] = 'device';
$link_array['device'] = $app_device['device_id'];
$link_array['tab'] = 'apps';
$link_array['app'] = $app['app_type'];
$link_array['app'] = $app->app_type;
unset($link_array['height'], $link_array['width']);
$overlib_url = generate_url($link_array);

View File

@ -2,25 +2,6 @@
$overview = 1;
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `disabled` = 0", array($device['device_id']));
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifOperStatus` = 'up' AND `ifAdminStatus` = 'up' AND `disabled` = 0", array($device['device_id']));
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `disabled` = 0", array($device['device_id']));
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down' AND `disabled` = 0", array($device['device_id']));
$services = get_service_status($device['device_id']);
$services['total'] = array_sum($services);
if ($services[2]) {
$services_colour = $config['warn_colour'];
} else {
$services_colour = $config['list_colour']['even'];
}
if ($ports['down']) {
$ports_colour = $config['warn_colour'];
} else {
$ports_colour = $config['list_colour']['even'];
}
echo('
<div class="container-fluid">
<div class="row">

View File

@ -1,6 +1,6 @@
<?php
if ($ports['total']) {
if (\LibreNMS\Util\ObjectCache::portCounts(['total'])['total'] > 0) {
echo '<div class="row">
<div class="col-md-12">
<div class="panel panel-default panel-condensed">
@ -45,6 +45,7 @@ if ($ports['total']) {
echo ' </td>
</tr>';
$ports = \LibreNMS\Util\ObjectCache::portCounts(['total', 'up', 'down', 'disabled']);
echo '
<tr>
<td><i class="fa fa-link fa-lg" style="color:black" aria-hidden="true"></i> '.$ports['total'].'</td>

View File

@ -1,7 +1,11 @@
<?php
if ($services['total']) {
use LibreNMS\Util\ObjectCache;
if (ObjectCache::serviceCounts()['total'] > 0) {
// Build the string.
$break = '';
$output = '';
foreach (service_get($device['device_id']) as $data) {
if ($data['service_status'] == '0') {
// Ok
@ -16,9 +20,11 @@ if ($services['total']) {
// Unknown
$status = 'grey';
}
$string .= $break . '<a class=' . $status . '>' . strtolower($data['service_type']) . '</a>';
$output .= $break . '<a class=' . $status . '>' . strtolower($data['service_type']) . '</a>';
$break = ', ';
}
$services = ObjectCache::serviceCounts(['total', 'ok', 'warning', 'critical']);
?>
<div class="row">
<div class="col-md-12">
@ -29,12 +35,12 @@ if ($services['total']) {
<table class="table table-hover table-condensed table-striped">
<tr>
<td title="Total"><i class="fa fa-cog" style="color:#0080FF" aria-hidden="true"></i> <?php echo $services['total']?></td>
<td title="Status - Ok"><i class="fa fa-cog" style="color:green" aria-hidden="true"></i> <?php echo $services[0]?></td>
<td title="Status - Warning"><i class="fa fa-cog" style="color:orange" aria-hidden="true"></i> <?php echo $services[1]?></td>
<td title="Status - Critical"><i class="fa fa-cog" style="color:red" aria-hidden="true"></i> <?php echo $services[2]?></td>
<td title="Status - Ok"><i class="fa fa-cog" style="color:green" aria-hidden="true"></i> <?php echo $services['ok']?></td>
<td title="Status - Warning"><i class="fa fa-cog" style="color:orange" aria-hidden="true"></i> <?php echo $services['warning']?></td>
<td title="Status - Critical"><i class="fa fa-cog" style="color:red" aria-hidden="true"></i> <?php echo $services['critical']?></td>
</tr>
<tr>
<td colspan='4'><?php echo $string?></td>
<td colspan='4'><?php echo $output?></td>
</tr>
</table>
</div>

View File

@ -208,7 +208,7 @@ if ($format == "graph") {
if (!$location_filter || $device['location'] == $location_filter) {
$graph_type = "device_" . $subformat;
if ($_SESSION['widescreen']) {
if (session('widescreen')) {
$width = 270;
} else {
$width = 315;

View File

@ -66,9 +66,9 @@ if ($default_dash == 0 && empty($user_dashboards)) {
// $dashboard was requested, but doesn't exist
if (!empty($orig)) {
$msg_box[] = array('type' => 'error', 'message' => 'Dashboard <code>#'.$orig.
'</code> does not exist! Loaded <code>'.$vars['dashboard']['dashboard_name'].
'</code> instead.','title' => 'Requested Dashboard Not Found!');
Toastr::error('Dashboard <code>#' . $orig .
'</code> does not exist! Loaded <code>' . htmlentities($vars['dashboard']['dashboard_name']) .
'</code> instead.', 'Requested Dashboard Not Found!');
}
}
}

View File

@ -6,7 +6,7 @@ unset($vars['page']);
// Setup here
if ($_SESSION['widescreen']) {
if (session('widescreen')) {
$graph_width=1700;
$thumb_width=180;
} else {

View File

@ -17,118 +17,48 @@
$no_refresh = true;
$datas = array('mempool','processor','storage');
if ($used_sensors['temperature']) {
$datas[] = 'temperature';
}
if ($used_sensors['charge']) {
$datas[] = 'charge';
}
if ($used_sensors['humidity']) {
$datas[] = 'humidity';
}
if ($used_sensors['fanspeed']) {
$datas[] = 'fanspeed';
}
if ($used_sensors['voltage']) {
$datas[] = 'voltage';
}
if ($used_sensors['frequency']) {
$datas[] = 'frequency';
}
if ($used_sensors['runtime']) {
$datas[] = 'runtime';
}
if ($used_sensors['current']) {
$datas[] = 'current';
}
if ($used_sensors['power']) {
$datas[] = 'power';
}
if ($used_sensors['power_consumed']) {
$datas[] = 'power_consumed';
}
if ($used_sensors['power_factor']) {
$datas[] = 'power_factor';
}
if ($used_sensors['dbm']) {
$datas[] = 'dbm';
}
if ($used_sensors['load']) {
$datas[] = 'load';
}
if ($used_sensors['state']) {
$datas[] = 'state';
}
if ($used_sensors['count']) {
$datas[] = 'count';
}
if ($used_sensors['signal']) {
$datas[] = 'signal';
}
if ($used_sensors['snr']) {
$datas[] = 'snr';
}
if ($used_sensors['pressure']) {
$datas[] = 'pressure';
}
if ($used_sensors['cooling']) {
$datas[] = 'cooling';
}
if ($used_sensors['toner']) {
$datas[] = 'toner';
}
if ($used_sensors['delay']) {
$datas[] = 'delay';
}
if ($used_sensors['quality_factor']) {
$datas[] = 'quality_factor';
}
if ($used_sensors['chromatic_dispersion']) {
$datas[] = 'chromatic_dispersion';
}
if ($used_sensors['ber']) {
$datas[] = 'ber';
}
if ($used_sensors['eer']) {
$datas[] = 'eer';
}
if ($used_sensors['waterflow']) {
$datas[] = 'waterflow';
$datas = ['mempool','processor','storage'];
$used_sensors = \LibreNMS\Util\ObjectCache::sensors();
foreach ($used_sensors as $group => $types) {
foreach ($types as $entry) {
$datas[] = $entry['class'];
}
}
$type_text['overview'] = "Overview";
$type_text['temperature'] = "Temperature";
$type_text['charge'] = "Battery Charge";
$type_text['humidity'] = "Humidity";
$type_text['mempool'] = "Memory";
$type_text['storage'] = "Storage";
$type_text['diskio'] = "Disk I/O";
$type_text['processor'] = "Processor";
$type_text['voltage'] = "Voltage";
$type_text['fanspeed'] = "Fanspeed";
$type_text['frequency'] = "Frequency";
$type_text['runtime'] = "Runtime";
$type_text['current'] = "Current";
$type_text['power'] = "Power";
$type_text['power_consumed'] = "Power Consumed";
$type_text['power_factor'] = "Power Factor";
$type_text['toner'] = "Toner";
$type_text['dbm'] = "dBm";
$type_text['load'] = "Load";
$type_text['state'] = "State";
$type_text['count'] = "Count";
$type_text['signal'] = "Signal";
$type_text['snr'] = "SNR";
$type_text['pressure'] = "Pressure";
$type_text['cooling'] = "Cooling";
$type_text['toner'] = 'Toner';
$type_text['delay'] = 'Delay';
$type_text['quality_factor'] = 'Quality factor';
$type_text['chromatic_dispersion'] = 'Chromatic Dispersion';
$type_text['ber'] = 'Bit Error Rate';
$type_text['eer'] = 'Energy Efficiency Ratio';
$type_text['waterflow'] = 'Water Flow Rate';
$type_text = [
'overview' => "Overview",
'temperature' => "Temperature",
'charge' => "Battery Charge",
'humidity' => "Humidity",
'mempool' => "Memory",
'storage' => "Storage",
'diskio' => "Disk I/O",
'processor' => "Processor",
'voltage' => "Voltage",
'fanspeed' => "Fanspeed",
'frequency' => "Frequency",
'runtime' => "Runtime",
'current' => "Current",
'power' => "Power",
'power_consumed' => "Power Consumed",
'power_factor' => "Power Factor",
'dbm' => "dBm",
'load' => "Load",
'state' => "State",
'count' => "Count",
'signal' => "Signal",
'snr' => "SNR",
'pressure' => "Pressure",
'cooling' => "Cooling",
'toner' => 'Toner',
'delay' => 'Delay',
'quality_factor' => 'Quality factor',
'chromatic_dispersion' => 'Chromatic Dispersion',
'ber' => 'Bit Error Rate',
'eer' => 'Energy Efficiency Ratio',
'waterflow' => 'Water Flow Rate',
];
$active_metric = basename($vars['metric'] ?? 'processor');
@ -136,7 +66,7 @@ if (!$vars['view']) {
$vars['view'] = "detail";
}
$link_array = array('page' => 'health');
$link_array = ['page' => 'health'];
$navbar = '<span style="font-weight: bold;">Health</span> &#187; ';
$sep = "";
@ -176,14 +106,7 @@ if ($vars['view'] != "graphs") {
$displayoptions .= '</span>';
}
$valid_metrics = array_merge(array_keys($used_sensors), [
'processor',
'storage',
'toner',
'mempool',
]);
if (in_array($active_metric, $valid_metrics)) {
if (in_array($active_metric, $datas)) {
include("includes/html/pages/health/$active_metric.inc.php");
} else {
echo("No sensors of type $active_metric found.");

View File

@ -24,13 +24,13 @@ foreach ($ports as $port) {
$graph_type = 'port_'.$subformat;
if ($_SESSION['widescreen']) {
if (session('widescreen')) {
$width = 357;
} else {
$width = 315;
}
if ($_SESSION['widescreen']) {
if (session('widescreen')) {
$width_div = 438;
} else {
$width_div = 393;

View File

@ -1,5 +1,11 @@
<?php
use App\Models\BgpPeer;
use App\Models\CefSwitching;
use App\Models\Component;
use App\Models\OspfInstance;
use App\Models\Vrf;
$pagetitle[] = 'Routing';
if ($_GET['optb'] == 'graphs' || $_GET['optc'] == 'graphs') {
@ -8,6 +14,8 @@ if ($_GET['optb'] == 'graphs' || $_GET['optc'] == 'graphs') {
$graphs = 'nographs';
}
$user = Auth::user();
$routing_count = \LibreNMS\Util\ObjectCache::routing();
// $datas[] = 'overview';
// $routing_count is populated by print-menubar.inc.php
// $type_text['overview'] = "Overview";
@ -22,7 +30,8 @@ print_optionbar_start();
// if (!$vars['protocol']) { $vars['protocol'] = "overview"; }
echo "<span style='font-weight: bold;'>Routing</span> &#187; ";
unset($sep);
$vars['protocol'] = basename($vars['protocol']);
$sep = '';
foreach ($routing_count as $type => $value) {
if (!$vars['protocol']) {
$vars['protocol'] = $type;

View File

@ -1,835 +0,0 @@
<?php
// FIXME - this could do with some performance improvements, i think. possible rearranging some tables and setting flags at poller time (nothing changes outside of then anyways)
use LibreNMS\Authentication\LegacyAuth;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\ObjectCache;
$service_status = get_service_status();
$typeahead_limit = $config['webui']['global_search_result_limit'];
$if_alerts = dbFetchCell("SELECT COUNT(port_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
if (Auth::user()->hasGlobalRead()) {
$links['count'] = dbFetchCell("SELECT COUNT(*) FROM `links`");
} else {
$links['count'] = dbFetchCell("SELECT COUNT(*) FROM `links` AS `L`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `L`.`local_device_id` = `D`.`device_id`", array(Auth::id()));
}
if (isset($config['enable_bgp']) && $config['enable_bgp']) {
$bgp_alerts = dbFetchCell("SELECT COUNT(bgpPeer_id) FROM bgpPeers AS B where (bgpPeerAdminStatus = 'start' OR bgpPeerAdminStatus = 'running') AND bgpPeerState != 'established'");
}
if (isset($config['site_style']) && ($config['site_style'] == 'dark' || $config['site_style'] == 'mono')) {
$navbar = 'navbar-inverse';
} else {
$navbar = '';
}
?>
<nav class="navbar navbar-default <?php echo $navbar; ?> navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navHeaderCollapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?php
if ($config['title_image']) {
echo('<a class="hidden-md hidden-sm navbar-brand" href=""><img src="' . $config['title_image'] . '" /></a>');
} else {
echo('<a class="hidden-md hidden-sm navbar-brand" href="">'.$config['project_name'].'</a>');
}
?>
</div>
<div class="collapse navbar-collapse" id="navHeaderCollapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-home fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Overview</span></a>
<ul class="dropdown-menu multi-level" role="menu">
<li><a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-tv fa-fw fa-lg" aria-hidden="true"></i> Dashboard</a></li>
<li class="dropdown-submenu">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-map fa-fw fa-lg" aria-hidden="true"></i> Maps</a>
<ul class="dropdown-menu">
<li><a href="<?php echo(generate_url(array('page'=>'availability-map'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg" aria-hidden="true"></i> Availability</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'map'))); ?>"><i class="fa fa-sitemap fa-fw fa-lg" aria-hidden="true"></i> Network</a></li>
<?php
$devices_groups = GetDeviceGroups();
if (count($devices_groups) > 0) {
echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups Maps</a><ul class="dropdown-menu scrollable-menu">';
foreach ($devices_groups as $group) {
echo '<li><a href="'.generate_url(array('page'=>'map','group'=>$group['id'])).'" title="'.$group['desc'].'"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> '.ucfirst($group['name']).'</a></li>';
}
unset($group);
echo '</ul></li>';
}
?>
<li><a href="<?php echo(generate_url(array('page'=>'fullscreenmap'))); ?>"><i class="fa fa-expand fa-fw fa-lg" aria-hidden="true"></i> Geographical</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a><i class="fa fa-plug fa-fw fa-lg" aria-hidden="true"></i> Plugins</a>
<ul class="dropdown-menu">
<?php
\LibreNMS\Plugins::call('menu');
if (Auth::user()->hasGlobalAdmin()) {
if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) {
echo('<li role="presentation" class="divider"></li>');
}
echo('<li><a href="plugin/view=admin"> <i class="fa fa-lock fa-fw fa-lg" aria-hidden="true"></i>Plugin Admin</a></li>');
}
?>
</ul>
</li>
<li class="dropdown-submenu">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg" aria-hidden="true"></i> Tools</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="<?php echo(generate_url(array('page'=>'ripenccapi'))); ?>"><i class="fa fa-star fa-fw fa-lg" aria-hidden="true"></i> RIPE NCC API</a></li>
<?php
if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
echo '<li><a href="'.generate_url(array('page'=>'oxidized')).'"><i class="fa fa-stack-overflow fa-fw fa-lg" aria-hidden="true"></i> Oxidized</a></li>';
}
?>
</ul>
</li>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'eventlog'))); ?>"><i class="fa fa-bookmark fa-fw fa-lg" aria-hidden="true"></i> Eventlog</a></li>
<?php
if (isset($config['enable_syslog']) && $config['enable_syslog']) {
echo ' <li><a href="'.generate_url(array('page'=>'syslog')).'"><i class="fa fa-clone fa-fw fa-lg" aria-hidden="true"></i> Syslog</a></li>';
}
if (isset($config['graylog']['server']) && isset($config['graylog']['port'])) {
echo ' <li><a href="'.generate_url(array('page'=>'graylog')).'"><i class="fa fa-clone fa-fw fa-lg" aria-hidden="true"></i> Graylog</a></li>';
}
?>
<li><a href="<?php echo(generate_url(array('page'=>'inventory'))); ?>"><i class="fa fa-cube fa-fw fa-lg" aria-hidden="true"></i> Inventory</a></li>
<?php
if (dbFetchCell("SELECT 1 from `packages` LIMIT 1")) {
?>
<li>
<a href="<?php echo(generate_url(array('page'=>'search','search'=>'packages'))); ?>"><i class="fa fa-archive fa-fw fa-lg" aria-hidden="true"></i> Packages</a>
</li>
<?php
} # if ($packages)
?>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv4'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> IPv4 Address</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv6'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> IPv6 Address</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'mac'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> MAC Address</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'arp'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> ARP Tables</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'fdb'))); ?>"><i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i> FDB Tables</a></li>
<?php
if (is_module_enabled('poller', 'mib')) {
?>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'mibs'))); ?>"><i class="fa fa-file-text-o fa-fw fa-lg" aria-hidden="true"></i> MIB definitions</a></li>
<?php
}
?>
</ul>
</li>
<li class="dropdown">
<a href="devices/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Devices</span></a>
<ul class="dropdown-menu">
<?php
$param = array();
if (Auth::user()->hasGlobalRead()) {
$sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`";
} else {
$sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`";
$param[] = Auth::id();
}
$device_types = dbFetchRows($sql, $param);
if (count($device_types) > 0) {
?>
<li class="dropdown-submenu">
<a href="devices/"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> All Devices</a>
<ul class="dropdown-menu scrollable-menu">
<?php
foreach ($device_types as $devtype) {
if (empty($devtype['type'])) {
$devtype['type'] = 'generic';
}
echo(' <li><a href="devices/type=' . $devtype['type'] . '/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> ' . ucfirst($devtype['type']) . '</a></li>');
}
echo ('</ul></li>');
} else {
echo '<li class="dropdown-submenu"><a href="#">No devices</a></li>';
}
if (count($devices_groups) > 0) {
echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups</a><ul class="dropdown-menu scrollable-menu">';
foreach ($devices_groups as $group) {
echo '<li><a href="'.generate_url(array('page'=>'devices','group'=>$group['id'])).'" title="'.$group['desc'].'"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> '.ucfirst($group['name']).'</a></li>';
}
unset($group);
echo '</ul></li>';
}
if ($config['show_locations']) {
if ($config['show_locations_dropdown']) {
$locations = getlocations();
if (count($locations) > 0) {
echo('
<li role="presentation" class="divider"></li>
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-map-marker fa-fw fa-lg" aria-hidden="true"></i> Geo Locations</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="locations"><i class="fa fa-map-marker fa-fw fa-lg" aria-hidden="true"></i> All Locations</a></li>
');
foreach ($locations as $location) {
echo(' <li><a href="devices/location=' . $location['id'] . '/"><i class="fa fa-building fa-fw fa-lg" aria-hidden="true"></i> ' . htmlentities($location['location']) . ' </a></li>');
}
echo('
</ul>
</li>
');
}
}
}
if (Auth::user()->hasGlobalAdmin()) {
echo '
<li role="presentation" class="divider"></li>';
if (is_module_enabled('poller', 'mib')) {
echo '
<li><a href='.generate_url(array('page'=>'mib_assoc')).'><i class="fa fa-file-text-o fa-fw fa-lg" aria-hidden="true"></i> MIB associations</a></li>
<li role="presentation" class="divider"></li>
';
}
if ($config['navbar']['manage_groups']['hide'] === 0) {
echo '<li><a href="'.generate_url(array('page'=>'device-groups')).'"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Manage Groups</a></li>';
}
echo '<li><a href="'.generate_url(array('page'=>'device-dependencies')).'"><i class="fa fa-group fa-fw fa-lg"></i> Device Dependencies</a></li>';
$vm_count = dbFetchCell('SELECT COUNT(id) from `vminfo`');
if ($vm_count > 0) {
echo '<li><a href="'.generate_url(array('page'=>'vminfo')).'"><i class="fa fa-cog fa-fw fa-lg"></i> Virtual Machines</a></li>';
}
echo '
<li role="presentation" class="divider"></li>
<li><a href="addhost/"><i class="fa fa-plus fa-fw fa-lg" aria-hidden="true"></i> Add Device</a></li>
<li><a href="delhost/"><i class="fa fa-trash fa-fw fa-lg" aria-hidden="true"></i> Delete Device</a></li>';
}
?>
</ul>
</li>
<?php
if ($config['show_services']) {
?>
<li class="dropdown">
<a href="services/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Services</span></a>
<ul class="dropdown-menu">
<li><a href="services/"><i class="fa fa-cogs fa-fw fa-lg" aria-hidden="true"></i> All Services </a></li>
<?php
if (($service_status[1] > 0) || ($service_status[2] > 0)) {
echo ' <li role="presentation" class="divider"></li>';
if ($service_status[1] > 0) {
echo ' <li><a href="services/state=warning/"><i class="fa fa-bell fa-col-warning fa-fw fa-lg" aria-hidden="true"></i> Warning ('.$service_status[1].')</a></li>';
}
if ($service_status[2] > 0) {
echo ' <li><a href="services/state=critical/"><i class="fa fa-bell fa-col-danger fa-fw fa-lg" aria-hidden="true"></i> Critical ('.$service_status[2].')</a></li>';
}
}
if (Auth::user()->hasGlobalAdmin()) {
echo('
<li role="presentation" class="divider"></li>
<li><a href="addsrv/"><i class="fa fa-plus fa-fw fa-lg" aria-hidden="true"></i> Add Service</a></li>');
}
?>
</ul>
</li>
<?php
}
?>
<!-- PORTS -->
<li class="dropdown">
<a href="ports/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-link fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Ports</span></a>
<ul class="dropdown-menu">
<li><a href="ports/"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> All Ports</a></li>
<?php
$ports = new ObjectCache('ports');
if ($ports['errored'] > 0) {
echo(' <li><a href="ports/errors=1/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> Errored ('.$ports['errored'].')</a></li>');
}
if ($ports['ignored'] > 0) {
echo(' <li><a href="ports/ignore=1/"><i class="fa fa-question-circle fa-fw fa-lg" aria-hidden="true"></i> Ignored ('.$ports['ignored'].')</a></li>');
}
if ($config['enable_billing']) {
echo(' <li><a href="bills/"><i class="fa fa-money fa-fw fa-lg" aria-hidden="true"></i> Traffic Bills</a></li>');
$ifbreak = 1;
}
if ($config['enable_pseudowires']) {
echo(' <li><a href="pseudowires/"><i class="fa fa-arrows-alt fa-fw fa-lg" aria-hidden="true"></i> Pseudowires</a></li>');
$ifbreak = 1;
}
?>
<?php
if (Auth::user()->hasGlobalRead()) {
echo(' <li role="presentation" class="divider"></li>');
if ($config['int_customers']) {
echo(' <li><a href="customers/"><i class="fa fa-users fa-fw fa-lg" aria-hidden="true"></i> Customers</a></li>');
$ifbreak = 1;
}
if ($config['int_l2tp']) {
echo(' <li><a href="iftype/type=l2tp/"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> L2TP</a></li>');
$ifbreak = 1;
}
if ($config['int_transit']) {
echo(' <li><a href="iftype/type=transit/"><i class="fa fa-truck fa-fw fa-lg" aria-hidden="true"></i> Transit</a></li>');
$ifbreak = 1;
}
if ($config['int_peering']) {
echo(' <li><a href="iftype/type=peering/"><i class="fa fa-handshake-o fa-fw fa-lg" aria-hidden="true"></i> Peering</a></li>');
$ifbreak = 1;
}
if ($config['int_peering'] && $config['int_transit']) {
echo(' <li><a href="iftype/type=peering,transit/"><i class="fa fa-rocket fa-fw fa-lg" aria-hidden="true"></i> Peering + Transit</a></li>');
$ifbreak = 1;
}
if ($config['int_core']) {
echo(' <li><a href="iftype/type=core/"><i class="fa fa-code-fork fa-fw fa-lg" aria-hidden="true"></i> Core</a></li>');
$ifbreak = 1;
}
if (is_array($config['custom_descr']) === false) {
$config['custom_descr'] = array($config['custom_descr']);
}
foreach ($config['custom_descr'] as $custom_type) {
if (!empty($custom_type)) {
echo ' <li><a href="iftype/type=' . urlencode(strtolower($custom_type)) . '"><i class="fa fa-connectdevelop fa-fw fa-lg" aria-hidden="true"></i> ' . ucfirst($custom_type) . '</a></li>';
$ifbreak = 1;
}
}
}
if ($ifbreak) {
echo(' <li role="presentation" class="divider"></li>');
}
if (isset($interface_alerts)) {
echo(' <li><a href="ports/alerted=yes/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> Alerts ('.$interface_alerts.')</a></li>');
}
$deleted_ports = 0;
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) {
if (port_permitted($interface['port_id'], $interface['device_id'])) {
$deleted_ports++;
}
}
?>
<li><a href="ports/state=down/"><i class="fa fa-arrow-circle-down fa-fw fa-lg" aria-hidden="true"></i> Down</a></li>
<li><a href="ports/state=admindown/"><i class="fa fa-arrow-circle-o-down fa-fw fa-lg" aria-hidden="true"></i> Disabled</a></li>
<?php
if ($deleted_ports) {
echo(' <li><a href="ports/deleted=yes/"><i class="fa fa-minus-circle fa-fw fa-lg" aria-hidden="true"></i> Deleted ('.$deleted_ports.')</a></li>');
}
?>
</ul>
</li>
<?php
// FIXME does not check user permissions...
foreach (dbFetchRows("SELECT sensor_class,COUNT(sensor_id) AS c FROM sensors GROUP BY sensor_class ORDER BY sensor_class ") as $row) {
$used_sensors[$row['sensor_class']] = $row['c'];
}
# Copy the variable so we can use $used_sensors later in other parts of the code
$menu_sensors = $used_sensors;
?>
<li class="dropdown">
<a href="health/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-heartbeat fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Health</span></a>
<ul class="dropdown-menu">
<li><a href="health/metric=mempool/"><i class="fa fa-braille fa-fw fa-lg" aria-hidden="true"></i> Memory</a></li>
<li><a href="health/metric=processor/"><i class="fa fa-microchip fa-fw fa-lg" aria-hidden="true"></i> Processor</a></li>
<li><a href="health/metric=storage/"><i class="fa fa-database fa-fw fa-lg" aria-hidden="true"></i> Storage</a></li>
<?php
if ($menu_sensors) {
$sep = 0;
echo(' <li role="presentation" class="divider"></li>');
}
$icons = \App\Models\Sensor::getIconMap();
foreach (array('fanspeed','humidity','temperature','signal') as $item) {
if (isset($menu_sensors[$item])) {
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);
$sep++;
}
}
if ($sep && array_keys($menu_sensors)) {
echo(' <li role="presentation" class="divider"></li>');
$sep = 0;
}
foreach (array('current','frequency','power','voltage','power_consumed','power_factor') as $item) {
if (isset($menu_sensors[$item])) {
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);
$sep++;
}
}
if ($sep && array_keys($menu_sensors)) {
echo(' <li role="presentation" class="divider"></li>');
$sep = 0;
}
foreach (array_keys($menu_sensors) as $item) {
echo(' <li><a href="health/metric='.$item.'/"><i class="fa fa-'.$icons[$item].' fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($item).'</a></li>');
unset($menu_sensors[$item]);
$sep++;
}
$toner = new ObjectCache('toner');
if ($toner) {
echo '<li role="presentation" class="divider"></li>';
echo '<li><a href="health/metric=toner/"><i class="fa fa-print fa-fw fa-lg"></i> Toner</a></li>';
$used_sensors['toner'] = $toner;
}
?>
</ul>
</li>
<?php
$valid_wireless_types = WirelessSensor::getTypes(true);
if (!empty($valid_wireless_types)) {
echo '<li class="dropdown">
<a href="wireless/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">
<i class="fa fa-wifi fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Wireless</span></a>
<ul class="dropdown-menu">';
foreach ($valid_wireless_types as $type => $meta) {
echo '<li><a href="wireless/metric='.$type.'/">';
echo '<i class="fa fa-'.$meta['icon'].' fa-fw fa-lg" aria-hidden="true"></i> ';
echo $meta['short'];
echo '</a></li>';
}
echo '</ul></li>';
}
$app_list = dbFetchRows("SELECT DISTINCT(`app_type`) AS `app_type` FROM `applications` ORDER BY `app_type`");
if (Auth::user()->hasGlobalRead() && count($app_list) > "0") {
?>
<li class="dropdown">
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Apps</span></a>
<ul class="dropdown-menu">
<li><a href="apps/"><i class="fa fa-object-group fa-fw fa-lg" aria-hidden="true"></i> Overview</a></li>
<?php
foreach ($app_list as $app) {
if (isset($app['app_type'])) {
$app_i_list = dbFetchRows("SELECT DISTINCT(`app_instance`) FROM `applications` WHERE `app_type` = ? ORDER BY `app_instance`", array($app['app_type']));
if (count($app_i_list) > 1) {
echo '<li class="dropdown-submenu">';
echo '<a href="apps/app='.$app['app_type'].'/"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($app['app_type']).' </a>';
echo '<ul class="dropdown-menu scrollable-menu">';
foreach ($app_i_list as $instance) {
echo ' <li><a href="apps/app='.$app['app_type'].'/instance='.$instance['app_instance'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> ' . nicecase($instance['app_instance']) . '</a></li>';
}
echo '</ul></li>';
} else {
echo('<li><a href="apps/app='.$app['app_type'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> '.nicecase($app['app_type']).' </a></li>');
}
}
}
?>
</ul>
</li>
<?php
}
$routing_count['bgp'] = dbFetchCell("SELECT COUNT(bgpPeer_id) from `bgpPeers` LEFT JOIN devices AS D ON bgpPeers.device_id=D.device_id WHERE D.device_id IS NOT NULL");
$routing_count['ospf'] = dbFetchCell("SELECT COUNT(ospf_instance_id) FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled'");
$routing_count['cef'] = dbFetchCell("SELECT COUNT(cef_switching_id) from `cef_switching`");
$routing_count['vrf'] = dbFetchCell("SELECT COUNT(vrf_id) from `vrfs`");
$component = new LibreNMS\Component();
$options['type'] = 'Cisco-OTV';
$otv = $component->getComponents(null, $options);
$routing_count['cisco-otv'] = count($otv);
if (Auth::user()->hasGlobalRead() && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']+$routing_count['cisco-otv']) > "0") {
?>
<li class="dropdown">
<a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-random fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Routing</span></a>
<ul class="dropdown-menu">
<?php
$separator = 0;
if (Auth::user()->hasGlobalRead() && $routing_count['vrf']) {
echo(' <li><a href="routing/protocol=vrf/"><i class="fa fa-arrows fa-fw fa-lg" aria-hidden="true"></i> VRFs</a></li>');
$separator++;
}
if (Auth::user()->hasGlobalRead() && $routing_count['ospf']) {
if ($separator) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=ospf/"><i class="fa fa-circle-o-notch fa-rotate-180 fa-fw fa-lg" aria-hidden="true"></i> OSPF Devices </a></li>');
$separator++;
}
// Cisco OTV Links
if (Auth::user()->hasGlobalRead() && $routing_count['cisco-otv']) {
if ($separator) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=cisco-otv/"><i class="fa fa-exchange fa-fw fa-lg" aria-hidden="true"></i> Cisco OTV </a></li>');
$separator++;
}
// BGP Sessions
if (Auth::user()->hasGlobalRead() && $routing_count['bgp']) {
if ($separator) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=bgp/type=all/graph=NULL/"><i class="fa fa-circle-o fa-fw fa-lg" aria-hidden="true"></i> BGP All Sessions </a></li>
<li><a href="routing/protocol=bgp/type=external/graph=NULL/"><i class="fa fa-external-link fa-fw fa-lg" aria-hidden="true"></i> BGP External</a></li>
<li><a href="routing/protocol=bgp/type=internal/graph=NULL/"><i class="fa fa-external-link fa-rotate-180 fa-fw fa-lg" aria-hidden="true"></i> BGP Internal</a></li>');
}
// CEF info
if (Auth::user()->hasGlobalRead() && $routing_count['cef']) {
if ($separator) {
echo(' <li role="presentation" class="divider"></li>');
$separator = 0;
}
echo('<li><a href="routing/protocol=cef/"><i class="fa fa-exchange fa-fw fa-lg" aria-hidden="true"></i> Cisco CEF </a></li>');
$separator++;
}
// Do Alerts at the bottom
if ($bgp_alerts) {
echo('
<li role="presentation" class="divider"></li>
<li><a href="routing/protocol=bgp/adminstatus=start/state=down/"><i class="fa fa-exclamation-circle fa-fw fa-lg" aria-hidden="true"></i> Alerted BGP (' . $bgp_alerts . ')</a></li>');
}
if (Auth::user()->hasGlobalAdmin() && $routing_count['bgp'] && $config['peeringdb']['enabled'] === true) {
echo '
<li role="presentation" class="divider"></li>
<li><a href="peering/"><i class="fa fa-hand-o-right fa-fw fa-lg" aria-hidden="true"></i> PeeringDB</a></li>';
}
echo(' </ul>');
?>
</li><!-- End 4 columns container -->
<?php
}
$alerts = new ObjectCache('alerts');
if ($alerts['active_count'] > 0) {
$alert_colour = "danger";
} else {
$alert_colour = "success";
}
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-exclamation-circle fa-col-<?php echo $alert_colour;?> fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Alerts</span></a>
<ul class="dropdown-menu">
<li><a href="<?php echo(generate_url(array('page'=>'alerts'))); ?>"><i class="fa fa-bell fa-fw fa-lg" aria-hidden="true"></i> Notifications</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-log'))); ?>"><i class="fa fa-file-text fa-fw fa-lg" aria-hidden="true"></i> Alert History</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-stats'))); ?>"><i class="fa fa-bar-chart fa-fw fa-lg" aria-hidden="true"></i> Statistics</a></li>
<?php if (Auth::user()->hasGlobalAdmin()) { ?>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-rules'))); ?>"><i class="fa fa-list fa-fw fa-lg" aria-hidden="true"></i> Alert Rules</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-schedule'))); ?>"><i class="fa fa-calendar fa-fw fa-lg" aria-hidden="true"></i> Scheduled Maintenance</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'templates'))); ?>"><i class="fa fa-file fa-fw fa-lg" aria-hidden="true"></i> Alert Templates</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-transports'))); ?>"><i class="fa fa-bus fa-fw fa-lg" aria-hidden="true"></i> Alert Transports</a></li>
<?php } ?>
</ul>
</li>
<?php
// Custom menubar entries.
if (is_file("includes/html/print-menubar-custom.inc.php")) {
require 'includes/html/print-menubar-custom.inc.php';
}
?>
</ul>
<form role="search" class="navbar-form navbar-right global-search">
<div class="form-group">
<input class="form-control typeahead" type="search" id="gsearch" name="gsearch" placeholder="Global Search">
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<?php
$notifications = new ObjectCache('notifications');
$style = '';
if (empty($notifications['count']) && empty($notifications['sticky_count'])) {
$class = 'badge-default';
} else {
$class = 'badge-danger';
}
echo('<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-user fa-fw fa-lg fa-nav-icons" aria-hidden="true"></i> <span class="visible-xs-inline-block">User</span><span class="badge badge-navbar-user count-notif '.$class.'">'.($notifications['sticky_count']+$notifications['count']).'</span></a>');
?>
<ul class="dropdown-menu">
<li><a href="preferences/"><i class="fa fa-cog fa-fw fa-lg" aria-hidden="true"></i> My Settings</a></li>
<?php
$notifications = new ObjectCache('notifications');
echo ('<li><a href="notifications/"><span class="badge count-notif">'.($notifications['sticky_count']+$notifications['count']).'</span> Notifications</a></li>');
?>
<li role="presentation" class="divider"></li>
<?php
if (Auth::check()) {
echo '<li><a href="';
echo route('logout');
echo '" onclick="event.preventDefault(); document.getElementById(\'logout-form\').submit();">';
echo ' <i class="fa fa-sign-out fa-fw fa-lg" aria-hidden="true"></i> ';
echo __('Logout');
echo '</a><form id="logout-form" action="';
echo route('logout');
echo '" method="POST" style="display: none;">';
echo csrf_field();
echo '</form></li>';
}
?>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown" style="margin-left:5px"><i class="fa fa-cog fa-fw fa-lg fa-nav-icons" aria-hidden="true"></i> <span class="visible-xs-inline-block">Settings</span></a>
<ul class="dropdown-menu">
<?php
if (Auth::user()->hasGlobalAdmin()) {
echo('<li><a href="settings/"><i class="fa fa-cogs fa-fw fa-lg" aria-hidden="true"></i> Global Settings</a></li>');
echo('<li><a href="validate/"><i class="fa fa-check-circle fa-fw fa-lg" aria-hidden="true"></i> Validate Config</a></li>');
}
?>
<li role="presentation" class="divider"></li>
<?php if (Auth::user()->hasGlobalAdmin()) {
echo('
<li><a href="' . route('users.index') . '"><i class="fa fa-user-circle-o fa-fw fa-lg" aria-hidden="true"></i> Manage Users</a></li>
<li><a href="authlog/"><i class="fa fa-shield fa-fw fa-lg" aria-hidden="true"></i> Auth History</a></li>
<li role="presentation" class="divider"></li> ');
echo('
<li class="dropdown-submenu">
<a href="pollers"><i class="fa fa-th-large fa-fw fa-lg" aria-hidden="true"></i> Pollers</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="pollers/tab=pollers/"><i class="fa fa-th-large fa-fw fa-lg" aria-hidden="true"></i> Pollers</a></li>');
if ($config['distributed_poller'] === true) {
echo ('
<li><a href="pollers/tab=groups/"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Groups</a></li>');
}
echo ' <li><a href="pollers/tab=performance/"><i class="fa fa-line-chart fa-fw fa-lg" aria-hidden="true"></i> Performance</a></li>';
echo ' <li><a href="pollers/tab=log/"><i class="fa fa-file-text fa-fw fa-lg" aria-hidden="true"></i> History</a></li>';
echo ('
</ul>
</li>
<li role="presentation" class="divider"></li>');
echo('
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-code fa-fw fa-lg" aria-hidden="true"></i> API</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="api-access/"><i class="fa fa-cog fa-fw fa-lg" aria-hidden="true"></i> API Settings</a></li>
<li><a href="https://docs.librenms.org/API/" target="_blank" rel="noopener"><i class="fa fa-book fa-fw fa-lg" aria-hidden="true"></i> API Docs</a></li>
</ul>
</li>
<li role="presentation" class="divider"></li>');
}
if (Auth::check()) {
echo('
<li class="dropdown-submenu">
<a href="#"><span class="countdown_timer" id="countdown_timer"></span></a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="#"><span class="countdown_timer_status" id="countdown_timer_status"></span></a></li>
</ul>
</li>');
}
?>
<li role="presentation" class="divider"></li>
<li><a href="about/"><i class="fa fa-info-circle fa-fw fa-lg" aria-hidden="true"></i> About&nbsp;<?php echo($config['project_name']); ?></a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<script>
var devices = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=device",
filter: function (devices) {
return $.map(devices, function (device) {
return {
device_id: device.device_id,
device_image: device.device_image,
url: device.url,
name: device.name,
device_os: device.device_os,
version: device.version,
device_hardware: device.device_hardware,
device_ports: device.device_ports,
location: device.location
};
});
},
wildcard: "%QUERY"
}
});
var ports = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=ports",
filter: function (ports) {
return $.map(ports, function (port) {
return {
count: port.count,
url: port.url,
name: port.name,
description: port.description,
colours: port.colours,
hostname: port.hostname
};
});
},
wildcard: "%QUERY"
}
});
var bgp = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=bgp",
filter: function (bgp_sessions) {
return $.map(bgp_sessions, function (bgp) {
return {
count: bgp.count,
url: bgp.url,
name: bgp.name,
description: bgp.description,
localas: bgp.localas,
bgp_image: bgp.bgp_image,
remoteas: bgp.remoteas,
colours: bgp.colours,
hostname: bgp.hostname
};
});
},
wildcard: "%QUERY"
}
});
if ($(window).width() < 768) {
var cssMenu = 'typeahead-left';
} else {
var cssMenu = '';
}
devices.initialize();
ports.initialize();
bgp.initialize();
$('#gsearch').typeahead({
hint: true,
highlight: true,
minLength: 1,
classNames: {
menu: cssMenu
}
},
{
source: devices.ttAdapter(),
limit: '<?php echo($typeahead_limit); ?>',
async: true,
display: 'name',
valueKey: 'name',
templates: {
header: '<h5><strong>&nbsp;Devices</strong></h5>',
suggestion: Handlebars.compile('<p><a href="{{url}}"><img src="{{device_image}}" border="0"> <small><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</small></a></p>')
}
},
{
source: ports.ttAdapter(),
limit: '<?php echo($typeahead_limit); ?>',
async: true,
display: 'name',
valueKey: 'name',
templates: {
header: '<h5><strong>&nbsp;Ports</strong></h5>',
suggestion: Handlebars.compile('<p><a href="{{url}}"><small><i class="fa fa-link fa-sm icon-theme" aria-hidden="true"></i> <strong>{{name}}</strong> {{hostname}}<br /><i>{{description}}</i></small></a></p>')
}
},
{
source: bgp.ttAdapter(),
limit: '<?php echo($typeahead_limit); ?>',
async: true,
display: 'name',
valueKey: 'name',
templates: {
header: '<h5><strong>&nbsp;BGP Sessions</strong></h5>',
suggestion: Handlebars.compile('<p><a href="{{url}}"><small>{{{bgp_image}}} {{name}} - {{hostname}}<br />AS{{localas}} -> AS{{remoteas}}</small></a></p>')
}
}).on('typeahead:select', function(ev, suggestion) {
window.location.href = suggestion.url;
}).on('keyup', function(e) {
// on enter go to the first selection
if(e.which === 13) {
$('.tt-selectable').first().click();
}
});
</script>

View File

@ -147,10 +147,6 @@ if (module_selected('discovery', $init_modules) && !update_os_cache()) {
}
if (module_selected('web', $init_modules)) {
umask(0002);
if (!isset($config['title_image'])) {
$config['title_image'] = 'images/librenms_logo_'.$config['site_style'].'.svg';
}
require $install_dir . '/includes/html/vars.inc.php';
}

View File

@ -76,6 +76,7 @@ nav:
- Extensions/IRC-Bot-Extensions.md
- Extensions/SNMP-Proxy.md
- Extensions/SNMP-Trap-Handler.md
- Extensions/Customizing-the-Web-UI.md
- Support/Cleanup-options.md
- 6. 3rd Party Integration:
- Extensions/Gateone.md

View File

@ -0,0 +1,81 @@
@extends('layouts.librenmsv1')
@section('content')
{!! $content !!}
@if($refresh)
<script type="text/javascript">
$(document).ready(function () {
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i> Pause");
var Countdown = {
sec: {{ (int)$refresh }},
Start: function () {
var cur = this;
this.interval = setInterval(function () {
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i> Pause");
cur.sec -= 1;
display_time = cur.sec;
if (display_time == 0) {
location.reload();
}
if (display_time % 1 === 0 && display_time <= 300) {
$("#countdown_timer").html("<i class=\"fa fa-clock-o fa-fw fa-lg\"></i> Refresh in " + display_time);
}
}, 1000);
},
Pause: function () {
clearInterval(this.interval);
$("#countdown_timer_status").html("<i class=\"fa fa-play fa-fw fa-lg\"></i> Resume");
delete this.interval;
},
Resume: function () {
if (!this.interval) this.Start();
}
};
Countdown.Start();
$("#countdown_timer_status").click("", function (event) {
event.preventDefault();
if (Countdown.interval) {
Countdown.Pause();
} else {
Countdown.Resume();
}
});
$("#countdown_timer").click("", function (event) {
event.preventDefault();
});
});
</script>
@else
<script type="text/javascript">
var no_refresh = true;
$(document).ready(function () {
$("#countdown_timer").html("Refresh disabled");
$("#countdown_timer_status").html("<i class=\"fa fa-pause fa-fw fa-lg\"></i>");
$("#countdown_timer_status").click("", function (event) {
event.preventDefault();
});
});
</script>
@endif
@config('enable_footer')
<nav class="navbar navbar-default {{ $navbar }} navbar-fixed-bottom">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h5>Powered by <a href="{{ \LibreNMS\Config::get('project_home') }}" target="_blank" rel="noopener" class="red">{{ \LibreNMS\Config::get('project_name') }}</a>.</h5>
</div>
</div>
</div>
</nav>
@endconfig
@endsection

View File

@ -9,7 +9,7 @@
</button>
<a class="hidden-md hidden-sm navbar-brand" href>
@if($title_image)
<img src="{{ $title_image }}" alt="{{ $project_name }}">
<img src="{{ asset($title_image) }}" alt="{{ $project_name }}">
@else
{{ $project_name }}
@endif
@ -28,7 +28,7 @@
<ul class="dropdown-menu">
<li><a href="{{ url('availability-map') }}"><i class="fa fa-arrow-circle-up fa-fw fa-lg" aria-hidden="true"></i> Availability</a></li>
<li><a href="{{ url('map') }}"><i class="fa fa-sitemap fa-fw fa-lg" aria-hidden="true"></i> Network</a></li>
@if($device_groups)
@if($device_groups->isNotEmpty())
<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups Maps</a><ul class="dropdown-menu scrollable-menu">
@foreach($device_groups as $group)
<li><a href="{{ url('map', [$group->id]) }}" title="{{ $group->desc }}"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i>
@ -93,7 +93,7 @@
<li class="dropdown">
<a href="{{ url('devices/') }}" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Devices</span></a>
<ul class="dropdown-menu">
@if($device_types)
@if($device_types->isNotEmpty())
<li class="dropdown-submenu">
<a href="{{ url('devices') }}"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> All Devices</a>
<ul class="dropdown-menu scrollable-menu">
@ -105,7 +105,7 @@
<li class="dropdown-submenu"><a href="#">No devices</a></li>
@endif
@if($device_groups)
@if($device_groups->isNotEmpty())
<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups</a>
<ul class="dropdown-menu scrollable-menu">
@foreach($device_groups as $group)
@ -115,7 +115,7 @@
</li>
@endif
@if($locations)
@if($locations->isNotEmpty())
<li role="presentation" class="divider"></li>
<li class="dropdown-submenu">
<a href="#"><i class="fa fa-map-marker fa-fw fa-lg" aria-hidden="true"></i> @lang('Geo Locations')</a>
@ -151,13 +151,13 @@
<a href="{{ url('services') }}" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-cogs fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Services</span></a>
<ul class="dropdown-menu">
<li><a href="{{ url('services') }}"><i class="fa fa-cogs fa-fw fa-lg" aria-hidden="true"></i> All Services </a></li>
@if($service_status)
@if($service_counts['warning'] || $service_counts['critical'])
<li role="presentation" class="divider"></li>
@if($service_warning)
<li><a href="{{ url('services/state=warning') }}"><i class="fa fa-bell fa-col-warning fa-fw fa-lg" aria-hidden="true"></i> Warning ({{ $service_warning }})</a></li>
@if($service_counts['warning'])
<li><a href="{{ url('services/state=warning') }}"><i class="fa fa-bell fa-col-warning fa-fw fa-lg" aria-hidden="true"></i> Warning ({{ $service_counts['warning'] }})</a></li>
@endif
@if($service_critical)
<li><a href="{{ url('services/state=critical') }}"><i class="fa fa-bell fa-col-danger fa-fw fa-lg" aria-hidden="true"></i> Critical ({{ $service_critical }})</a></li>
@if($service_counts['critical'])
<li><a href="{{ url('services/state=critical') }}"><i class="fa fa-bell fa-col-danger fa-fw fa-lg" aria-hidden="true"></i> Critical ({{ $service_counts['critical'] }})</a></li>
@endif
@endif
@admin
@ -185,33 +185,35 @@
<li><a href="{{ url('bills') }}"><i class="fa fa-money fa-fw fa-lg" aria-hidden="true"></i> Traffic Bills</a></li>
@endconfig
@if($port_counts['pseudowire'] > 0))
@if($port_counts['pseudowire'] > 0)
<li><a href="{{ url('pseudowires') }}"><i class="fa fa-arrows-alt fa-fw fa-lg" aria-hidden="true"></i> Pseudowires</a></li>
@endif
@if(auth()->user()->hasGlobalRead())
<li role="presentation" class="divider"></li>
@config('int_customers')
<li><a href="{{ url('customers') }}"><i class="fa fa-users fa-fw fa-lg" aria-hidden="true"></i> Customers</a></li>
@endconfig
@config('int_l2tp')
<li><a href="{{ url('iftype/type=l2tp') }}"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> L2TP</a></li>
@endconfig
@config('int_transit')
<li><a href="{{ url('iftype/type=transit') }}"><i class="fa fa-truck fa-fw fa-lg" aria-hidden="true"></i> Transit</a></li>
@endconfig
@config('int_peering')
<li><a href="{{ url('iftype/type=peering') }}"><i class="fa fa-handshake-o fa-fw fa-lg" aria-hidden="true"></i> Peering</a></li>
@endconfig
@if(\LibreNMS\Config::get('int_peering') && \LibreNMS\Config::get('int_transit'))
<li><a href="{{ url('iftype/type=peering,transit') }}"><i class="fa fa-rocket fa-fw fa-lg" aria-hidden="true"></i> Peering + Transit</a></li>
@if($port_groups_exist)
<li role="presentation" class="divider"></li>
@config('int_customers')
<li><a href="{{ url('customers') }}"><i class="fa fa-users fa-fw fa-lg" aria-hidden="true"></i> Customers</a></li>
@endconfig
@config('int_l2tp')
<li><a href="{{ url('iftype/type=l2tp') }}"><i class="fa fa-link fa-fw fa-lg" aria-hidden="true"></i> L2TP</a></li>
@endconfig
@config('int_transit')
<li><a href="{{ url('iftype/type=transit') }}"><i class="fa fa-truck fa-fw fa-lg" aria-hidden="true"></i> Transit</a></li>
@endconfig
@config('int_peering')
<li><a href="{{ url('iftype/type=peering') }}"><i class="fa fa-handshake-o fa-fw fa-lg" aria-hidden="true"></i> Peering</a></li>
@endconfig
@if(\LibreNMS\Config::get('int_peering') && \LibreNMS\Config::get('int_transit'))
<li><a href="{{ url('iftype/type=peering,transit') }}"><i class="fa fa-rocket fa-fw fa-lg" aria-hidden="true"></i> Peering + Transit</a></li>
@endif
@config('int_core')
<li><a href="{{ url('iftype/type=core') }}"><i class="fa fa-code-fork fa-fw fa-lg" aria-hidden="true"></i> Core</a></li>
@endconfig
@foreach($custom_port_descr as $custom_descr)
<li><a href="{{ url('iftype/type=' . urlencode($custom_descr)) }}"><i class="fa fa-connectdevelop fa-fw fa-lg" aria-hidden="true"></i> {{ ucwords($custom_descr) }}</a></li>
@endforeach
@endif
@config('int_core')
<li><a href="{{ url('iftype/type=core') }}"><i class="fa fa-code-fork fa-fw fa-lg" aria-hidden="true"></i> Core</a></li>
@endconfig
@foreach((array)\LibreNMS\Config::get('custom_descr', []) as $custom_type)
<li><a href="{{ url('iftype/type=' . urlencode(strtolower($custom_type))) }}"><i class="fa fa-connectdevelop fa-fw fa-lg" aria-hidden="true"></i> {{ ucfirst($custom_type) }}</a></li>
@endforeach
<li role="presentation" class="divider"></li>
@ -241,14 +243,14 @@
@if($loop->first)
<li role="presentation" class="divider"></li>
@endif
<li><a href="{{ url('health/metric=' . $sensor_menu_entry->sensor_class) }}"><i class="fa fa-{{ $sensor_menu_entry->icon() }} fa-fw fa-lg" aria-hidden="true"></i> {{ $sensor_menu_entry->classDescr() }}</a></li>
<li><a href="{{ url('health/metric=' . $sensor_menu_entry['class']) }}"><i class="fa fa-{{ $sensor_menu_entry['icon'] }} fa-fw fa-lg" aria-hidden="true"></i> {{ $sensor_menu_entry['descr'] }}</a></li>
@endforeach
@endforeach
</ul>
</li>
{{-- Wireless --}}
@if($wireless_menu->count())
@if($wireless_menu->isNotEmpty())
<li class="dropdown">
<a href="{{ url('wireless') }}" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-wifi fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Wireless</span></a>
<ul class="dropdown-menu">
@ -259,13 +261,13 @@
</li>
@endif
{{-- App --}}
@if($app_menu->count())
@if($app_menu->isNotEmpty())
<li class="dropdown">
<a href="{{ url('apps') }}" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Apps</span></a>
<ul class="dropdown-menu">
<li><a href="{{ url('apps') }}"><i class="fa fa-object-group fa-fw fa-lg" aria-hidden="true"></i> Overview</a></li>
@foreach($app_menu as $app_type => $app_instances)
@if($app_instances->filter->app_instance->count() > 0)
@if($app_instances->filter->app_instance->isNotEmpty())
<li class="dropdown-submenu">
<a href="{{ url('apps/app=' . $app_type) }}"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> {{ $app_instances->first()->displayName() }}</a>
<ul class="dropdown-menu scrollable-menu">
@ -324,6 +326,7 @@
@endadmin
</ul>
</li>
@includeIf('menu.custom')
</ul>
{{-- User --}}
@ -382,6 +385,15 @@
</li>
<li role="presentation" class="divider"></li>
@endadmin
@if (isset($refresh))
<li class="dropdown-submenu">
<a href="#"><span class="countdown_timer" id="countdown_timer"></span></a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="#"><span class="countdown_timer_status" id="countdown_timer_status"></span></a></li>
</ul>
</li>
<li role="presentation" class="divider"></li>
@endif
<li><a href="{{ url('about') }}"><i class="fa fa-info-circle fa-fw fa-lg" aria-hidden="true"></i> About&nbsp;{{ \LibreNMS\Config::get('project_name') }}</a></li>
</ul>
</li>

View File

@ -16,7 +16,7 @@
<tbody>
<tr>
<td><a href="{{ url('devices') }}">@lang('Devices')</a></td>
<td><a href="{{ url('devices') }}"><span> {{ $devices['count'] }}</span></a></td>
<td><a href="{{ url('devices') }}"><span> {{ $devices['total'] }}</span></a></td>
<td><a href="{{ url('devices/state=up/format=list_detail') }}"><span class="green"> {{ $devices['up'] }}</span></a></td>
<td><a href="{{ url('devices/state=down/format=list_detail') }}"><span class="red"> {{ $devices['down'] }}</span></a></td>
<td><a href="{{ url('devices/ignore=1/format=list_detail') }}"><span class="grey"> {{ $devices['ignored'] }}</span></a></td>
@ -27,7 +27,7 @@
</tr>
<tr>
<td><a href="{{ url('ports') }}">@lang('Ports')</a></td>
<td><a href="{{ url('ports') }}"><span>{{ $ports['count'] }}</span></a></td>
<td><a href="{{ url('ports') }}"><span>{{ $ports['total'] }}</span></a></td>
<td><a href="{{ url('ports/format=list_detail/state=up') }}"><span class="green"> {{ $ports['up'] }}</span></a></td>
<td><a href="{{ url('ports/format=list_detail/state=down') }}"><span class="red"> {{ $ports['down'] }}</span></a></td>
<td><a href="{{ url('ports/format=list_detail/ignore=1') }}"><span class="grey"> {{ $ports['ignored'] }}</span></a></td>
@ -39,9 +39,9 @@
@if($show_services)
<tr>
<td><a href="{{ url('services') }}">@lang('Services')</a></td>
<td><a href="{{ url('services') }}"><span>{{ $services['count'] }}</span></a></td>
<td><a href="{{ url('services/state=ok/view=details') }}"><span class="green">{{ $services['up'] }}</span></a></td>
<td><a href="{{ url('services/state=critical/view=details') }}"><span class="red"> {{ $services['down'] }}</span></a></td>
<td><a href="{{ url('services') }}"><span>{{ $services['total'] }}</span></a></td>
<td><a href="{{ url('services/state=ok/view=details') }}"><span class="green">{{ $services['ok'] }}</span></a></td>
<td><a href="{{ url('services/state=critical/view=details') }}"><span class="red"> {{ $services['critical'] }}</span></a></td>
<td><a href="{{ url('services/ignore=1/view=details') }}"><span class="grey"> {{ $services['ignored'] }}</span></a></td>
<td><a href="{{ url('services/disabled=1/view=details') }}"><span class="black"> {{ $services['disabled'] }}</span></a></td>
@if($summary_errors)

View File

@ -16,7 +16,7 @@
<td><a href="{{ url('devices/format=list_detail/state=up') }}"><span class="green"> {{ $devices['up'] }}</span></a></td>
<td><a href="{{ url('ports/format=list_detail/state=up') }}"><span class="green"> {{ $ports['up'] }}</span></a></td>
@if($show_services)
<td><a href="{{ url('services/view=details/state=ok') }}"><span class="green"> {{ $services['up'] }}</span></a></td>
<td><a href="{{ url('services/view=details/state=ok') }}"><span class="green"> {{ $services['ok'] }}</span></a></td>
@endif
</tr>
<tr>
@ -24,7 +24,7 @@
<td><a href="{{ url('devices/format=list_detail/state=down') }}"><span class="red"> {{ $devices['down'] }}</span></a></td>
<td><a href="{{ url('ports/format=list_detail/state=down') }}"><span class="red"> {{ $ports['down'] }}</span></a></td>
@if($show_services)
<td><a href="{{ url('services/view=details/state=critical') }}"><span class="red"> {{ $services['down'] }}</span></a></td>
<td><a href="{{ url('services/view=details/state=critical') }}"><span class="red"> {{ $services['critical'] }}</span></a></td>
@endif
</tr>
<tr>
@ -55,10 +55,10 @@
@endif
<tr>
<th><span class="grey">@lang('Total')</span></th>
<td><a href="{{ url('devices') }}"><span> {{ $devices['count'] }}</span></a></td>
<td><a href="{{ url('ports') }}"><span> {{ $ports['count'] }}</span></a></td>
<td><a href="{{ url('devices') }}"><span> {{ $devices['total'] }}</span></a></td>
<td><a href="{{ url('ports') }}"><span> {{ $ports['total'] }}</span></a></td>
@if($show_services)
<td><a href="{{ url('services') }}"><span> {{ $services['count'] }}</span></a></td>
<td><a href="{{ url('services') }}"><span> {{ $services['total'] }}</span></a></td>
@endif
</tr>
</tbody>