Changed vis settings and added link utilisation

This commit is contained in:
laf
2015-04-17 19:56:46 +01:00
parent c9f086484a
commit d26e282834
2 changed files with 38 additions and 5 deletions

View File

@ -14,8 +14,8 @@
$tmp_devices = array(); $tmp_devices = array();
if (!empty($device['hostname'])) { if (!empty($device['hostname'])) {
$sql = ' WHERE `devices`.`hostname`=?'; $sql = ' WHERE `devices`.`hostname`=? OR `remote_hostname`=?';
$sql_array = array($device['hostname']); $sql_array = array($device['hostname'],$device['hostname']);
} else { } else {
$sql = ' WHERE 1'; $sql = ' WHERE 1';
} }
@ -68,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'=>generate_port_link($port_data, "<img src='graph.php?type=port_bits&amp;id=".$port['port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>",'',1,1),'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&amp;id=".$port['port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>",'',1,1),'width'=>$width,'color'=>$link_color);
} }
$edges = json_encode($tmp_links); $edges = json_encode($tmp_links);
@ -98,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) {

View File

@ -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'=> '#ffffff', '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;