mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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';
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
echo "<span style='font-weight: bold;'>Latency</span> » ";
|
||||
|
||||
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';
|
@@ -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>
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user