mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 19:08:15 +00:00
i win. fucking graphviz.
git-svn-id: http://www.observium.org/svn/observer/trunk@2673 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
parent
6983a94792
commit
e87e9b5a02
35
html/map.php
35
html/map.php
@ -39,14 +39,16 @@ if (isset($_GET['device'])) { $where = "WHERE device_id = ".mres($_GET['device']
|
||||
|
||||
if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
{
|
||||
$map = "digraph G { sep=0.01; size=\"12,5.5\"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
|
||||
node [ fontname=\"helvetica\", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false;];
|
||||
edge [ bgcolor=white; fontname=\"helvetica\"; fontstyle=bold; arrowhead=dot; arrowtail=dot];
|
||||
graph [bgcolor=transparent;];\n\n";
|
||||
$map = 'digraph G { sep=0.01; size="12,5.5"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
|
||||
node [ fontname="helvetica", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false];
|
||||
edge [ bgcolor=white, fontname="helvetica", fontstyle=bold, arrowhead=dot, arrowtail=dot];
|
||||
graph [bgcolor=transparent];
|
||||
|
||||
';
|
||||
|
||||
if (!$_SESSION['authenticated'])
|
||||
{
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\" URL=\"/\" shape=box3d]\n";
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -58,7 +60,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
if (count($links))
|
||||
{
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20 fillcolor=\"lightblue\" URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=map/\" shape=box3d]\n";
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20, fillcolor=\"lightblue\", URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=map/\" shape=box3d]\n";
|
||||
}
|
||||
|
||||
foreach ($links as $link)
|
||||
@ -107,7 +109,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
$dif['interface_id'] = $link['remote_hostname'] . $link['remote_port'];
|
||||
}
|
||||
|
||||
$map .= "\"" . $sif['interface_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue URL=\"{$config['base_url']}/device/device=".$device['device_id']."/port/$local_interface_id/\"]\n";
|
||||
$map .= "\"" . $sif['interface_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=".$device['device_id']."/port/$local_interface_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['interface_id']])
|
||||
{
|
||||
$map .= "\"$src\" -> \"" . $sif['interface_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
@ -115,7 +117,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
}
|
||||
|
||||
if ($dst_host) {
|
||||
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/device=$dst_host/tab=map/\" fontsize=20 shape=box3d]\n";
|
||||
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/device=$dst_host/tab=map/\", fontsize=20, shape=box3d]\n";
|
||||
} else {
|
||||
$map .= "\"$dst\" [ fontsize=20 shape=box3d]\n";
|
||||
}
|
||||
@ -143,7 +145,10 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
$map .= "
|
||||
};";
|
||||
|
||||
if ($_GET['debug'] == 1) { echo("<pre>$map</pre>");exit(); }
|
||||
# if ($_GET['debug'] == 1)
|
||||
# {
|
||||
# echo("<pre>$map</pre>");exit();
|
||||
# }
|
||||
|
||||
switch ($_GET['format'])
|
||||
{
|
||||
@ -163,7 +168,17 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
if ($where == '') { $maptool = $config['sdfp'] . ' -Gpack -Gcharset=latin1 -Gsize=200,200'; }
|
||||
|
||||
$img = shell_exec("echo \"".addslashes($map)."\" | $maptool -T".$_GET['format']."");
|
||||
$descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w") );
|
||||
$process = proc_open('/usr/bin/dot -Tsvg',$descriptorspec,$pipes);
|
||||
|
||||
if (is_resource($process)) {
|
||||
fwrite($pipes[0], "$map");
|
||||
fclose($pipes[0]);
|
||||
while (! feof($pipes[1])) {$img .= fgets($pipes[1]);}
|
||||
fclose($pipes[1]);
|
||||
$return_value = proc_close($process);
|
||||
}
|
||||
|
||||
if ($_GET['format'] == "png")
|
||||
{
|
||||
header("Content-type: image/".$_GET['format']);
|
||||
|
@ -4,7 +4,8 @@ if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs')
|
||||
{
|
||||
if (isset($vars['graph'])) { $graph_type = "port_" . $vars['graph']; } else { $graph_type = "port_bits"; }
|
||||
}
|
||||
if (!$vars['view']) { $vars['view'] = "basic"; }
|
||||
|
||||
if (!$vars['view']) { $vars['view'] = $config['ports_page_default']; }
|
||||
|
||||
$link_array = array('page' => 'device',
|
||||
'device' => $device['device_id'],
|
||||
|
Loading…
Reference in New Issue
Block a user