mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixed widgets from updated dbFacile changes (#9033)
* Fixed widgets from updated dbFacile changes * Updated top interfaces
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
use LibreNMS\Authentication\Auth;
|
use LibreNMS\Authentication\Auth;
|
||||||
|
|
||||||
$top_query = $widget_settings['top_query'];
|
$top_query = $widget_settings['top_query'] ?: 'traffic';
|
||||||
$sort_order = $widget_settings['sort_order'];
|
$sort_order = $widget_settings['sort_order'];
|
||||||
|
|
||||||
$selected_sort_asc = '';
|
$selected_sort_asc = '';
|
||||||
@@ -155,8 +155,10 @@ if (defined('SHOW_SETTINGS') || empty($widget_settings)) {
|
|||||||
|
|
||||||
$common_output[] = '<h4>Top ' . $device_count . ' devices (last ' . $interval . ' minutes)</h4>';
|
$common_output[] = '<h4>Top ' . $device_count . ' devices (last ' . $interval . ' minutes)</h4>';
|
||||||
|
|
||||||
$params = array('user' => Auth::id(), 'interval' => array($interval_seconds), 'count' => array($device_count));
|
$params = ['interval' => $interval_seconds, 'count' => $device_count];
|
||||||
|
if (!Auth::user()->hasGlobalRead()) {
|
||||||
|
$params['user'] = Auth::id();
|
||||||
|
}
|
||||||
if ($top_query === 'traffic') {
|
if ($top_query === 'traffic') {
|
||||||
if (Auth::user()->hasGlobalRead()) {
|
if (Auth::user()->hasGlobalRead()) {
|
||||||
$query = '
|
$query = '
|
||||||
|
|||||||
@@ -99,16 +99,19 @@ $(function() {
|
|||||||
';
|
';
|
||||||
} else {
|
} else {
|
||||||
$interval = $widget_settings['time_interval'];
|
$interval = $widget_settings['time_interval'];
|
||||||
(integer) $lastpoll_seconds = ($interval * 60);
|
(integer) $lastpoll_seconds = ($interval * 60) ?: 300;
|
||||||
(integer) $interface_count = $widget_settings['interface_count'];
|
(integer) $interface_count = $widget_settings['interface_count'] ?: 5;
|
||||||
$params = array('user' => Auth::id(), 'lastpoll' => array($lastpoll_seconds), 'count' => array($interface_count), 'filter' => ($widget_settings['interface_filter']?:(int)1));
|
$params = ['lastpoll' => $lastpoll_seconds, 'count' => $interface_count, 'filter1' => ($widget_settings['interface_filter']?:(int)1), 'filter2' => ($widget_settings['interface_filter']?:(int)1)];
|
||||||
|
if (!Auth::user()->hasGlobalRead()) {
|
||||||
|
$params['user'] = Auth::id();
|
||||||
|
}
|
||||||
if (Auth::user()->hasGlobalRead()) {
|
if (Auth::user()->hasGlobalRead()) {
|
||||||
$query = '
|
$query = '
|
||||||
SELECT p.*, devices.*, p.ifInOctets_rate + p.ifOutOctets_rate as total
|
SELECT p.*, devices.*, p.ifInOctets_rate + p.ifOutOctets_rate as total
|
||||||
FROM ports as p
|
FROM ports as p
|
||||||
INNER JOIN devices ON p.device_id = devices.device_id
|
INNER JOIN devices ON p.device_id = devices.device_id
|
||||||
AND unix_timestamp() - p.poll_time <= :lastpoll
|
AND unix_timestamp() - p.poll_time <= :lastpoll
|
||||||
AND ( p.ifType = :filter || 1 = :filter )
|
AND ( p.ifType = :filter1 || 1 = :filter2 )
|
||||||
AND ( p.ifInOctets_rate > 0 || p.ifOutOctets_rate > 0 )
|
AND ( p.ifInOctets_rate > 0 || p.ifOutOctets_rate > 0 )
|
||||||
ORDER BY total DESC
|
ORDER BY total DESC
|
||||||
LIMIT :count
|
LIMIT :count
|
||||||
@@ -122,7 +125,7 @@ $(function() {
|
|||||||
LEFT JOIN devices_perms ON devices.device_id = devices_perms.device_id
|
LEFT JOIN devices_perms ON devices.device_id = devices_perms.device_id
|
||||||
WHERE ( ports_perms.user_id = :user || devices_perms.user_id = :user )
|
WHERE ( ports_perms.user_id = :user || devices_perms.user_id = :user )
|
||||||
AND unix_timestamp() - ports.poll_time <= :lastpoll
|
AND unix_timestamp() - ports.poll_time <= :lastpoll
|
||||||
AND ( ports.ifType = :filter || 1 = :filter )
|
AND ( ports.ifType = :filter1 || 1 = :filter2 )
|
||||||
AND ( ports.ifInOctets_rate > 0 || ports.ifOutOctets_rate > 0 )
|
AND ( ports.ifInOctets_rate > 0 || ports.ifOutOctets_rate > 0 )
|
||||||
GROUP BY ports.port_id
|
GROUP BY ports.port_id
|
||||||
ORDER BY total DESC
|
ORDER BY total DESC
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ var greenMarker = L.AwesomeMarkers.icon({
|
|||||||
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
|
WHERE `disabled`=0 AND `ignore`=0 AND ((`lat` != '' AND `lng` != '') OR (`devices`.`location` REGEXP '\[[0-9\.\, ]+\]'))
|
||||||
AND `status` IN (".$widget_settings['status'].")
|
AND `status` IN (".$widget_settings['status'].")
|
||||||
ORDER BY `status` ASC, `hostname`";
|
ORDER BY `status` ASC, `hostname`";
|
||||||
|
$param = [];
|
||||||
} else {
|
} else {
|
||||||
// Normal user - grab devices that user has permissions to
|
// Normal user - grab devices that user has permissions to
|
||||||
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`devices`.`location`,`sysName`,`hostname`,`os`,`status`,`lat`,`lng`
|
$sql = "SELECT DISTINCT(`devices`.`device_id`) as `device_id`,`devices`.`location`,`sysName`,`hostname`,`os`,`status`,`lat`,`lng`
|
||||||
@@ -187,6 +188,7 @@ var greenMarker = L.AwesomeMarkers.icon({
|
|||||||
ORDER BY `status` ASC, `hostname`";
|
ORDER BY `status` ASC, `hostname`";
|
||||||
$param[] = Auth::id();
|
$param[] = Auth::id();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (dbFetchRows($sql, $param) as $map_devices) {
|
foreach (dbFetchRows($sql, $param) as $map_devices) {
|
||||||
$icon = 'greenMarker';
|
$icon = 'greenMarker';
|
||||||
$z_offset = 0;
|
$z_offset = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user