mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-02 00:32:09 +02:00
Merge branch 'master' of git://github.com/librenms/librenms
This commit is contained in:
@@ -122,7 +122,7 @@ function generate_device_url($device, $vars=array())
|
|||||||
return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars);
|
return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end=0, $escape_text=1)
|
function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end=0, $escape_text=1, $overlib=1)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@@ -168,7 +168,11 @@ function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($escape_text) { $text = htmlentities($text); }
|
if ($escape_text) { $text = htmlentities($text); }
|
||||||
$link = overlib_link($url, $text, escape_quotes($contents), $class);
|
if ($overlib == 0) {
|
||||||
|
$link = $contents;
|
||||||
|
} else {
|
||||||
|
$link = overlib_link($url, $text, escape_quotes($contents), $class);
|
||||||
|
}
|
||||||
|
|
||||||
if (device_permitted($device['device_id']))
|
if (device_permitted($device['device_id']))
|
||||||
{
|
{
|
||||||
@@ -404,7 +408,7 @@ function generate_entity_link($type, $entity, $text = NULL, $graph_type=NULL)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_port_link($port, $text = NULL, $type = NULL)
|
function generate_port_link($port, $text = NULL, $type = NULL, $overlib = 1, $single_graph = 0)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@@ -429,17 +433,21 @@ function generate_port_link($port, $text = NULL, $type = NULL)
|
|||||||
$graph_array['from'] = $config['time']['day'];
|
$graph_array['from'] = $config['time']['day'];
|
||||||
$graph_array['id'] = $port['port_id'];
|
$graph_array['id'] = $port['port_id'];
|
||||||
$content .= generate_graph_tag($graph_array);
|
$content .= generate_graph_tag($graph_array);
|
||||||
$graph_array['from'] = $config['time']['week'];
|
if ($single_graph == 0) {
|
||||||
$content .= generate_graph_tag($graph_array);
|
$graph_array['from'] = $config['time']['week'];
|
||||||
$graph_array['from'] = $config['time']['month'];
|
$content .= generate_graph_tag($graph_array);
|
||||||
$content .= generate_graph_tag($graph_array);
|
$graph_array['from'] = $config['time']['month'];
|
||||||
$graph_array['from'] = $config['time']['year'];
|
$content .= generate_graph_tag($graph_array);
|
||||||
$content .= generate_graph_tag($graph_array);
|
$graph_array['from'] = $config['time']['year'];
|
||||||
|
$content .= generate_graph_tag($graph_array);
|
||||||
|
}
|
||||||
$content .= "</div>";
|
$content .= "</div>";
|
||||||
|
|
||||||
$url = generate_port_url($port);
|
$url = generate_port_url($port);
|
||||||
|
|
||||||
if (port_permitted($port['port_id'], $port['device_id'])) {
|
if ($overlib == 0) {
|
||||||
|
return $content;
|
||||||
|
} elseif (port_permitted($port['port_id'], $port['device_id'])) {
|
||||||
return overlib_link($url, $text, $content, $class);
|
return overlib_link($url, $text, $content, $class);
|
||||||
} else {
|
} else {
|
||||||
return fixifName($text);
|
return fixifName($text);
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ $sql .= ' AND `local_device_id` != 0 AND `remote_device_id` != 0';
|
|||||||
$tmp_ids = array();
|
$tmp_ids = array();
|
||||||
foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_device_id`) AS `remote_device_id`, GREATEST(`remote_device_id`,`devices`.`device_id`) AS `local_device_id` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` $sql", $sql_array) as $link_devices) {
|
foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_device_id`) AS `remote_device_id`, GREATEST(`remote_device_id`,`devices`.`device_id`) AS `local_device_id` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` $sql", $sql_array) as $link_devices) {
|
||||||
if (!in_array($link_devices['local_device_id'], $tmp_ids) && device_permitted($link_devices['local_device_id'])) {
|
if (!in_array($link_devices['local_device_id'], $tmp_ids) && device_permitted($link_devices['local_device_id'])) {
|
||||||
$link_dev = dbFetchRow("SELECT `hostname`,`location` FROM `devices` WHERE `device_id`=?",array($link_devices['local_device_id']));
|
$link_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?",array($link_devices['local_device_id']));
|
||||||
$tmp_devices[] = array('id'=>$link_devices['local_device_id'],'label'=>$link_dev['hostname'],'title'=>$link_dev['hostname'],'group'=>$link_dev['location']);
|
$tmp_devices[] = array('id'=>$link_devices['local_device_id'],'label'=>$link_dev['hostname'],'title'=>generate_device_link($link_dev,'',array(),'','','',1),'group'=>$link_dev['location'],'shape'=>'box');
|
||||||
}
|
}
|
||||||
if (!in_array($link_devices['remote_device_id'], $tmp_ids) && device_permitted($link_devices['remote_device_id'])) {
|
if (!in_array($link_devices['remote_device_id'], $tmp_ids) && device_permitted($link_devices['remote_device_id'])) {
|
||||||
$link_dev = dbFetchRow("SELECT `hostname`,`location` FROM `devices` WHERE `device_id`=?",array($link_devices['remote_device_id']));
|
$link_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?",array($link_devices['remote_device_id']));
|
||||||
$tmp_devices[] = array('id'=>$link_devices['remote_device_id'],'label'=>$link_dev['hostname'],'title'=>$link_dev['hostname'],'group'=>$link_dev['location']);
|
$tmp_devices[] = array('id'=>$link_devices['remote_device_id'],'label'=>$link_dev['hostname'],'title'=>generate_device_link($link_dev,'',array(),'','','',1),'group'=>$link_dev['location'],'shape'=>'box');
|
||||||
}
|
}
|
||||||
array_push($tmp_ids,$link_devices['local_device_id']);
|
array_push($tmp_ids,$link_devices['local_device_id']);
|
||||||
array_push($tmp_ids,$link_devices['remote_device_id']);
|
array_push($tmp_ids,$link_devices['remote_device_id']);
|
||||||
@@ -42,11 +42,12 @@ $nodes = json_encode($tmp_devices);
|
|||||||
|
|
||||||
if (is_array($tmp_devices[0])) {
|
if (is_array($tmp_devices[0])) {
|
||||||
$tmp_links = array();
|
$tmp_links = array();
|
||||||
foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.`ifName` AS `local_port`, `remote_port`,`ports`.`ifSpeed` AS ifSpeed FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_ids) AND `remote_device_id` IN ($tmp_ids))") as $link_devices) {
|
foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_ids) AND `remote_device_id` IN ($tmp_ids))") as $link_devices) {
|
||||||
foreach ($tmp_devices as $k=>$v) {
|
foreach ($tmp_devices as $k=>$v) {
|
||||||
if ($v['id'] == $link_devices['local_device_id']) {
|
if ($v['id'] == $link_devices['local_device_id']) {
|
||||||
$from = $v['id'];
|
$from = $v['id'];
|
||||||
$port = shorten_interface_type($link_devices['local_port']);
|
$port = shorten_interface_type($link_devices['ifName']);
|
||||||
|
$port_data = $link_devices;
|
||||||
}
|
}
|
||||||
if ($v['id'] == $link_devices['remote_device_id']) {
|
if ($v['id'] == $link_devices['remote_device_id']) {
|
||||||
$to = $v['id'];
|
$to = $v['id'];
|
||||||
@@ -67,7 +68,20 @@ if (is_array($tmp_devices[0])) {
|
|||||||
} else {
|
} else {
|
||||||
$width = 1;
|
$width = 1;
|
||||||
}
|
}
|
||||||
$tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>$port,'width'=>$width);
|
$link_in_used = ($link_devices['ifInOctets_rate'] * 8) / $link_devices['ifSpeed'] * 100;
|
||||||
|
$link_out_used = ($link_devices['ifOutOctets_rate'] * 8) / $link_devices['ifSpeed'] * 100;
|
||||||
|
if ($link_in_used > $link_out_used) {
|
||||||
|
$link_used = $link_in_used;
|
||||||
|
} else {
|
||||||
|
$link_used = $link_out_used;
|
||||||
|
}
|
||||||
|
$link_used = round($link_used, -1);
|
||||||
|
if ($link_used > 100) {
|
||||||
|
$link_used = 100;
|
||||||
|
}
|
||||||
|
$link_color = $config['map_legend'][$link_used];
|
||||||
|
|
||||||
|
$tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "<img src='graph.php?type=port_bits&id=".$port['port_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>",'',1,1),'width'=>$width,'color'=>$link_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
$edges = json_encode($tmp_links);
|
$edges = json_encode($tmp_links);
|
||||||
@@ -97,9 +111,26 @@ echo $edges;
|
|||||||
var data = {
|
var data = {
|
||||||
nodes: nodes,
|
nodes: nodes,
|
||||||
edges: edges,
|
edges: edges,
|
||||||
stabilize: true
|
stabilize: false
|
||||||
|
};
|
||||||
|
var options = {
|
||||||
|
physics: {
|
||||||
|
barnesHut: {
|
||||||
|
gravitationalConstant: -80000, springConstant: 0.001, springLength: 200
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
color: {
|
||||||
|
background: '#ffffff'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
smoothCurves: {dynamic:false, type: "continuous"},
|
||||||
|
edges: {
|
||||||
|
color: {
|
||||||
|
color: '#000000'
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
var options = {physics: {barnesHut: {gravitationalConstant: -11900, centralGravity: 1.4, springLength: 203, springConstant: 0.05, damping: 0.3}}, smoothCurves: false};
|
|
||||||
var network = new vis.Network(container, data, options);
|
var network = new vis.Network(container, data, options);
|
||||||
network.on("resize", function(params) {console.log(params.width,params.height)});
|
network.on("resize", function(params) {console.log(params.width,params.height)});
|
||||||
network.on('click', function (properties) {
|
network.on('click', function (properties) {
|
||||||
|
|||||||
@@ -252,6 +252,9 @@ $config['graph_colours']['blues'] = array('A0A0E5','8080BD','606096','40406F',
|
|||||||
$config['graph_colours']['purples'] = array('CC7CCC','AF63AF','934A93','773177','5B185B','3F003F');
|
$config['graph_colours']['purples'] = array('CC7CCC','AF63AF','934A93','773177','5B185B','3F003F');
|
||||||
$config['graph_colours']['default'] = $config['graph_colours']['blues'];
|
$config['graph_colours']['default'] = $config['graph_colours']['blues'];
|
||||||
|
|
||||||
|
// Map colors
|
||||||
|
$config['map_legend'] = array('0'=> '#aeaeae', '10' => '#79847e', '20' => '#97ffca', '30' => '#a800ff', '40' => '#6c00ff', '50' => '#00d2ff', '60' => '#0090ff', '70' => '#ffe400', '80' => '#ffa200', '90' => '#ff6600', '100' => '#ff0000');
|
||||||
|
|
||||||
// Device page options
|
// Device page options
|
||||||
|
|
||||||
$config['show_overview_tab'] = TRUE;
|
$config['show_overview_tab'] = TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user