diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php
index 6a94719f1..48295cd3e 100644
--- a/html/includes/functions.inc.php
+++ b/html/includes/functions.inc.php
@@ -122,7 +122,7 @@ function generate_device_url($device, $vars=array())
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;
@@ -168,7 +168,11 @@ function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end
}
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']))
{
@@ -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;
@@ -429,17 +433,21 @@ function generate_port_link($port, $text = NULL, $type = NULL)
$graph_array['from'] = $config['time']['day'];
$graph_array['id'] = $port['port_id'];
$content .= generate_graph_tag($graph_array);
- $graph_array['from'] = $config['time']['week'];
- $content .= generate_graph_tag($graph_array);
- $graph_array['from'] = $config['time']['month'];
- $content .= generate_graph_tag($graph_array);
- $graph_array['from'] = $config['time']['year'];
- $content .= generate_graph_tag($graph_array);
+ if ($single_graph == 0) {
+ $graph_array['from'] = $config['time']['week'];
+ $content .= generate_graph_tag($graph_array);
+ $graph_array['from'] = $config['time']['month'];
+ $content .= generate_graph_tag($graph_array);
+ $graph_array['from'] = $config['time']['year'];
+ $content .= generate_graph_tag($graph_array);
+ }
$content .= "";
$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);
} else {
return fixifName($text);
diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php
index 97ca4a7e2..297bac1b6 100644
--- a/html/includes/print-map.inc.php
+++ b/html/includes/print-map.inc.php
@@ -25,12 +25,12 @@ $sql .= ' AND `local_device_id` != 0 AND `remote_device_id` != 0';
$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) {
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']));
- $tmp_devices[] = array('id'=>$link_devices['local_device_id'],'label'=>$link_dev['hostname'],'title'=>$link_dev['hostname'],'group'=>$link_dev['location']);
+ $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'=>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'])) {
- $link_dev = dbFetchRow("SELECT `hostname`,`location` 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']);
+ $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'=>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['remote_device_id']);
@@ -42,11 +42,12 @@ $nodes = json_encode($tmp_devices);
if (is_array($tmp_devices[0])) {
$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) {
if ($v['id'] == $link_devices['local_device_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']) {
$to = $v['id'];
@@ -67,7 +68,20 @@ if (is_array($tmp_devices[0])) {
} else {
$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, "
",'',1,1),'width'=>$width,'color'=>$link_color);
}
$edges = json_encode($tmp_links);
@@ -97,9 +111,26 @@ echo $edges;
var data = {
nodes: nodes,
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);
network.on("resize", function(params) {console.log(params.width,params.height)});
network.on('click', function (properties) {
diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php
index c9cc3d4c2..b22b0957b 100644
--- a/includes/defaults.inc.php
+++ b/includes/defaults.inc.php
@@ -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']['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
$config['show_overview_tab'] = TRUE;