mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-27 08:02:51 +02:00
move from port_id to interface_id. make ports discovery only discover. add some cleaner functions. add a tiny bit of alerting infrastructure.
git-svn-id: http://www.observium.org/svn/observer/trunk@3195 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+25
-25
@@ -70,7 +70,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
{
|
||||
if ($device)
|
||||
{
|
||||
$links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname", array($device['device_id']));
|
||||
$links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", array($device['device_id']));
|
||||
if (count($links))
|
||||
{
|
||||
if ($anon) { $device['hostname'] = md5($device['hostname']); }
|
||||
@@ -82,15 +82,15 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
foreach ($links as $link)
|
||||
{
|
||||
$local_interface_id = $link['local_interface_id'];
|
||||
$remote_interface_id = $link['remote_interface_id'];
|
||||
$local_port_id = $link['local_port_id'];
|
||||
$remote_port_id = $link['remote_port_id'];
|
||||
|
||||
$i = 0; $done = 0;
|
||||
if ($linkdone[$remote_interface_id][$local_interface_id]) { $done = 1; }
|
||||
if ($linkdone[$remote_port_id][$local_port_id]) { $done = 1; }
|
||||
|
||||
if (!$done)
|
||||
{
|
||||
$linkdone[$local_interface_id][$remote_interface_id] = TRUE;
|
||||
$linkdone[$local_port_id][$remote_port_id] = TRUE;
|
||||
|
||||
$links++;
|
||||
|
||||
@@ -109,10 +109,10 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
$src = $device['hostname'];
|
||||
if ($anon) { $src = md5($src); }
|
||||
if ($remote_interface_id)
|
||||
if ($remote_port_id)
|
||||
{
|
||||
$dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id));
|
||||
$dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id));
|
||||
$dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id));
|
||||
$dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id));
|
||||
} else {
|
||||
unset($dst_host);
|
||||
$dst = $link['remote_hostname'];
|
||||
@@ -120,28 +120,28 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
if ($anon) { $dst = md5($dst); $src = md5($src);}
|
||||
|
||||
$sif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `interface_id` = ?", array($link['local_interface_id'])),$device);
|
||||
if ($remote_interface_id)
|
||||
$sif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", array($link['local_port_id'])),$device);
|
||||
if ($remote_port_id)
|
||||
{
|
||||
$dif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `interface_id` = ?", array($link['remote_interface_id'])));
|
||||
$dif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `port_id` = ?", array($link['remote_port_id'])));
|
||||
} else {
|
||||
$dif['label'] = $link['remote_port'];
|
||||
$dif['interface_id'] = $link['remote_hostname'] . '/' . $link['remote_port'];
|
||||
$dif['port_id'] = $link['remote_hostname'] . '/' . $link['remote_port'];
|
||||
}
|
||||
|
||||
if ($where == "")
|
||||
{
|
||||
if (!$ifdone[$dst][$dif['interface_id']] && !$ifdone[$src][$sif['interface_id']])
|
||||
if (!$ifdone[$dst][$dif['port_id']] && !$ifdone[$src][$sif['port_id']])
|
||||
{
|
||||
$map .= "\"$src\" -> \"" . $dst . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
}
|
||||
$ifdone[$src][$sif['interface_id']] = 1;
|
||||
$ifdone[$src][$sif['port_id']] = 1;
|
||||
} else {
|
||||
$map .= "\"" . $sif['interface_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=port/port=$local_interface_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['interface_id']])
|
||||
$map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=port/port=$local_port_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['port_id']])
|
||||
{
|
||||
$map .= "\"$src\" -> \"" . $sif['interface_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$src][$sif['interface_id']] = 1;
|
||||
$map .= "\"$src\" -> \"" . $sif['port_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$src][$sif['port_id']] = 1;
|
||||
}
|
||||
|
||||
if ($dst_host)
|
||||
@@ -153,22 +153,22 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
|
||||
if ($dst_host == $device['device_id'] || $where == '')
|
||||
{
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_interface_id/\"]\n";
|
||||
$map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\"]\n";
|
||||
} else {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray";
|
||||
$map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray";
|
||||
if ($dst_host)
|
||||
{
|
||||
$map .= ", URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_interface_id/\"";
|
||||
$map .= ", URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\"";
|
||||
}
|
||||
$map .= "]\n";
|
||||
}
|
||||
|
||||
if (!$ifdone[$dst][$dif['interface_id']])
|
||||
if (!$ifdone[$dst][$dif['port_id']])
|
||||
{
|
||||
$map .= "\"" . $dif['interface_id'] . "\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$dst][$dif['interface_id']] = 1;
|
||||
$map .= "\"" . $dif['port_id'] . "\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$dst][$dif['port_id']] = 1;
|
||||
}
|
||||
$map .= "\"" . $sif['interface_id'] . "\" -> \"" . $dif['interface_id'] . "\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, $info] \n";
|
||||
$map .= "\"" . $sif['port_id'] . "\" -> \"" . $dif['port_id'] . "\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, $info] \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user