From 4db1454e924a7240e4ad34ea0ec01f637894bd72 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 16 May 2012 13:25:50 +0000 Subject: [PATCH] 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 --- attic/interfaces.inc.php | 14 +- attic/purgeports.inc.php | 24 +- check-errors.php | 2 +- contrib/generate-dnstext.php | 2 +- contrib/generate-vegadns.php | 2 +- html/ajax_listports.php | 4 +- html/includes/functions.inc.php | 18 +- html/includes/graphs/atmvp/auth.inc.php | 4 +- html/includes/graphs/bill/auth.inc.php | 2 +- .../graphs/macaccounting/auth.inc.php | 6 +- html/includes/graphs/multiport/bits.inc.php | 2 +- .../graphs/multiport/bits_duo.inc.php | 4 +- .../graphs/multiport/bits_separate.inc.php | 2 +- .../graphs/multiport/bits_trio.inc.php | 6 +- .../graphs/port/mac_acc_total.inc.php | 8 +- .../javascript-interfacepicker.inc.php | 4 +- html/includes/port-edit.inc.php | 12 +- html/includes/print-interface-adsl.inc.php | 20 +- html/includes/print-interface-graphs.inc.php | 2 +- html/includes/print-interface.inc.php | 60 +-- html/includes/print-menubar.php | 4 +- html/includes/print-vlan.inc.php | 8 +- html/includes/print-vrf.inc.php | 6 +- html/map.php | 50 +- html/pages/about.inc.php | 2 +- html/pages/bill.inc.php | 2 +- html/pages/bill/actions.inc.php | 4 +- html/pages/bill/edit.inc.php | 14 +- html/pages/bill/pdf_history.inc.php | 2 +- html/pages/bills.inc.php | 4 +- html/pages/deleted-ports.inc.php | 14 +- html/pages/device.inc.php | 6 +- html/pages/device/edit/ports.inc.php | 18 +- html/pages/device/hrdevice.inc.php | 2 +- html/pages/device/port.inc.php | 26 +- html/pages/device/port/arp.inc.php | 6 +- html/pages/device/port/events.inc.php | 2 +- html/pages/device/port/junose-atm-vp.inc.php | 2 +- html/pages/device/port/macaccounting.inc.php | 30 +- html/pages/device/port/pagp.inc.php | 16 +- html/pages/device/port/realtime.inc.php | 4 +- html/pages/device/port/vlans.inc.php | 4 +- html/pages/device/ports.inc.php | 10 +- html/pages/device/ports/adsl.inc.php | 2 +- html/pages/device/ports/arp.inc.php | 6 +- html/pages/device/ports/neighbours.inc.php | 6 +- html/pages/device/pseudowires.inc.php | 12 +- html/pages/device/routing/bgp.inc.php | 6 +- html/pages/device/routing/ospf.inc.php | 6 +- html/pages/edituser.inc.php | 14 +- html/pages/front/default.php | 2 +- html/pages/front/demo.php | 2 +- html/pages/front/example2.php | 6 +- html/pages/front/globe.php | 2 +- html/pages/front/jt.php | 6 +- html/pages/front/traffic.php | 8 +- html/pages/iftype.inc.php | 8 +- html/pages/ports/graph.inc.php | 8 +- html/pages/ports/list.inc.php | 2 +- html/pages/pseudowires.inc.php | 12 +- html/pages/purgeports.inc.php | 4 +- html/pages/routing/bgp.inc.php | 4 +- html/pages/routing/ospf.inc.php | 2 +- html/pages/routing/vrf.inc.php | 2 +- html/pages/search/arp.inc.php | 8 +- html/pages/search/ipv4.inc.php | 4 +- html/pages/search/ipv6.inc.php | 4 +- html/pages/search/mac.inc.php | 2 +- includes/common.php | 54 ++- includes/discovery/arp-table.inc.php | 20 +- .../discovery/cisco-mac-accounting.inc.php | 6 +- includes/discovery/cisco-pw.inc.php | 6 +- includes/discovery/cisco-vrf.inc.php | 8 +- .../discovery/discovery-protocols.inc.php | 36 +- includes/discovery/functions.inc.php | 38 +- includes/discovery/ipv4-addresses.inc.php | 12 +- includes/discovery/ipv6-addresses.inc.php | 6 +- includes/discovery/junose-atm-vp.inc.php | 16 +- includes/discovery/ports-stack.inc.php | 24 +- includes/discovery/ports.inc.php | 428 +----------------- includes/discovery/vlans.inc.php | 4 +- includes/functions.php | 2 +- includes/polling/cisco-cef.inc.php | 7 +- .../polling/cisco-ipsec-flow-monitor.inc.php | 44 +- includes/polling/cisco-mac-accounting.inc.php | 2 +- includes/polling/cisco-vpdn.inc.php | 15 +- includes/polling/junose-atm-vp.inc.php | 2 +- includes/polling/ospf.inc.php | 24 +- includes/polling/port-adsl.inc.php | 6 +- includes/polling/ports.inc.php | 75 ++- includes/polling/ucd-diskio.inc.php | 6 +- includes/rrdtool.inc.php | 9 +- includes/snmp.inc.php | 2 + includes/snmptrap/linkDown.inc.php | 8 +- includes/snmptrap/linkUp.inc.php | 10 +- includes/syslog.php | 4 +- poll-billing.php | 2 +- poller.php | 2 +- snmptrap.php | 2 +- sql-schema/022.sql | 1 + 100 files changed, 525 insertions(+), 928 deletions(-) create mode 100644 sql-schema/022.sql diff --git a/attic/interfaces.inc.php b/attic/interfaces.inc.php index da4513917..e89690512 100644 --- a/attic/interfaces.inc.php +++ b/attic/interfaces.inc.php @@ -89,36 +89,36 @@ while ($interface = mysql_fetch_assoc($interface_query)) { if ($interface['ifDescr'] != $ifDescr && $ifDescr != "" ) { $update .= $seperator . "`ifDescr` = '$ifDescr'"; $seperator = ", "; - eventlog("ifDescr -> $ifDescr", $interface['device_id'], $interface['interface_id']); + eventlog("ifDescr -> $ifDescr", $interface['device_id'], $interface['port_id']); } if ($interface['ifName'] != $ifName && $ifName != "" ) { $update .= $seperator . "`ifName` = '$ifName'"; $seperator = ", "; - eventlog("ifName -> $ifName", $interface['device_id'], $interface['interface_id']); + eventlog("ifName -> $ifName", $interface['device_id'], $interface['port_id']); } if ($interface['ifAlias'] != $ifAlias && $ifAlias != "" ) { $update .= $seperator . "`ifAlias` = '".mres($ifAlias)."'"; $seperator = ", "; - eventlog("ifAlias -> $ifAlias", $interface['device_id'], $interface['interface_id']); + eventlog("ifAlias -> $ifAlias", $interface['device_id'], $interface['port_id']); } if ($interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) { $update .= $seperator . "`ifOperStatus` = '$ifOperStatus'"; $seperator = ", "; - eventlog("Interface went $ifOperStatus", $interface['device_id'], $interface['interface_id']); + eventlog("Interface went $ifOperStatus", $interface['device_id'], $interface['port_id']); } if ($interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) { $update .= $seperator . "`ifAdminStatus` = '$ifAdminStatus'"; $seperator = ", "; if ($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; } - eventlog("Interface $admin", $interface['device_id'], $interface['interface_id']); + eventlog("Interface $admin", $interface['device_id'], $interface['port_id']); } if ($update) { $update_query = "UPDATE `ports` SET "; $update_query .= $update; - $update_query .= " WHERE `interface_id` = '" . $interface['interface_id'] . "'"; + $update_query .= " WHERE `port_id` = '" . $interface['port_id'] . "'"; #echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n"); $update_result = mysql_query($update_query); } else { @@ -153,7 +153,7 @@ while ($interface = mysql_fetch_assoc($interface_query)) { } $rates = interface_rates ($rrdfile); - mysql_query("UPDATE `ports` SET in_rate = '" . $rates['in'] . "', out_rate = '" . $rates['out'] . "' WHERE interface_id= '" . $interface['interface_id'] . "'"); + mysql_query("UPDATE `ports` SET in_rate = '" . $rates['in'] . "', out_rate = '" . $rates['out'] . "' WHERE port_id= '" . $interface['port_id'] . "'"); } diff --git a/attic/purgeports.inc.php b/attic/purgeports.inc.php index 462a17b0a..a7c5b414a 100644 --- a/attic/purgeports.inc.php +++ b/attic/purgeports.inc.php @@ -1,9 +1,9 @@ Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr']); @@ -11,7 +11,7 @@ function delete_port($interface_id) echo(""); } - $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); + $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `port_id` = '$port_id'"); while ($ip6addr = mysql_fetch_assoc($ip6addrs)) { echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); @@ -19,7 +19,7 @@ function delete_port($interface_id) echo("
"); } - $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); + $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `port_id` = '$port_id'"); while ($ip6addr = mysql_fetch_assoc($ip6addrs)) { echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); @@ -27,19 +27,19 @@ function delete_port($interface_id) echo("
"); } - mysql_query("DELETE FROM `pseudowires` WHERE `interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `mac_accounting` WHERE `interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `links` WHERE `local_interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `links` WHERE `remote_interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `ports_perms` WHERE `interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `ports` WHERE `interface_id` = '$interface_id'"); + mysql_query("DELETE FROM `pseudowires` WHERE `port_id` = '$port_id'"); + mysql_query("DELETE FROM `mac_accounting` WHERE `port_id` = '$port_id'"); + mysql_query("DELETE FROM `links` WHERE `local_port_id` = '$port_id'"); + mysql_query("DELETE FROM `links` WHERE `remote_port_id` = '$port_id'"); + mysql_query("DELETE FROM `ports_perms` WHERE `port_id` = '$port_id'"); + mysql_query("DELETE FROM `ports` WHERE `port_id` = '$port_id'"); } $ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'"); while ($port = mysql_fetch_assoc($ports)) { - echo("
Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']); - delete_port($port['interface_id']); + echo("
Deleting port " . $port['port_id'] . " - " . $port['ifDescr']); + delete_port($port['port_id']); echo("
"); } diff --git a/check-errors.php b/check-errors.php index 96849d2db..a4433fa01 100755 --- a/check-errors.php +++ b/check-errors.php @@ -23,7 +23,7 @@ include("html/includes/functions.inc.php"); ## Check all of our interface RRD files for errors -if ($argv[1]) { $where = "AND `interface_id` = ?"; $params = array($argv[1]); } +if ($argv[1]) { $where = "AND `port_id` = ?"; $params = array($argv[1]); } $i = 0; $errored = 0; diff --git a/contrib/generate-dnstext.php b/contrib/generate-dnstext.php index 788f0a10f..08986fdc4 100755 --- a/contrib/generate-dnstext.php +++ b/contrib/generate-dnstext.php @@ -9,7 +9,7 @@ $link = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass'] $db = mysql_select_db($config['db_name'], $link); -$query = "SELECT * FROM ipv4_addresses AS A, ports as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.os = 'ios'"; +$query = "SELECT * FROM ipv4_addresses AS A, ports as I, devices as D WHERE A.port_id = I.port_id AND I.device_id = D.device_id AND D.os = 'ios'"; $data = mysql_query($query, $link); while($ip = mysql_fetch_array($data)) { unset($sub); diff --git a/contrib/generate-vegadns.php b/contrib/generate-vegadns.php index 2b75e6bde..e58d65066 100755 --- a/contrib/generate-vegadns.php +++ b/contrib/generate-vegadns.php @@ -12,7 +12,7 @@ $link = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass'] $db = mysql_select_db($config['db_name'], $link); -$query = "SELECT * FROM ipaddr AS A, ports as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.hostname LIKE '%.vostron.net' AND D.hostname NOT LIKE '%.cust.%' AND D.os = 'ios'"; +$query = "SELECT * FROM ipaddr AS A, ports as I, devices as D WHERE A.port_id = I.port_id AND I.device_id = D.device_id AND D.hostname LIKE '%.vostron.net' AND D.hostname NOT LIKE '%.cust.%' AND D.os = 'ios'"; $data = mysql_query($query, $link); while($ip = mysql_fetch_array($data)) { unset($sub); diff --git a/html/ajax_listports.php b/html/ajax_listports.php index 65abb2302..b9245ebe3 100755 --- a/html/ajax_listports.php +++ b/html/ajax_listports.php @@ -38,8 +38,8 @@ if (is_numeric($_GET['device_id'])) foreach (dbFetch("SELECT * FROM ports WHERE device_id = ?", array($_GET['device_id'])) as $interface) { $string = mres($interface['ifDescr']." - ".$interface['ifAlias']); - echo("obj.options[obj.options.length] = new Option('".$string."','".$interface['interface_id']."');\n"); - #echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['interface_id']."');\n"); + echo("obj.options[obj.options.length] = new Option('".$string."','".$interface['port_id']."');\n"); + #echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['port_id']."');\n"); } } diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index b87909980..fcd76ab1e 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1,5 +1,7 @@ = "5") { $allowed = TRUE; } elseif (device_permitted($device_id)) { $allowed = TRUE; - } elseif ($permissions['port'][$interface_id]) { + } elseif ($permissions['port'][$port_id]) { $allowed = TRUE; } else { $allowed = FALSE; @@ -361,7 +363,7 @@ function generate_port_link($args, $text = NULL, $type = NULL) $graph_array['width'] = "340"; $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; - $graph_array['id'] = $args['interface_id']; + $graph_array['id'] = $args['port_id']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['week']; $content .= generate_graph_tag($graph_array); @@ -373,7 +375,7 @@ function generate_port_link($args, $text = NULL, $type = NULL) $url = generate_port_url($args); - if (port_permitted($args['interface_id'], $args['device_id'])) { + if (port_permitted($args['port_id'], $args['device_id'])) { return overlib_link($url, $text, $content, $class); } else { return fixifName($text); @@ -382,13 +384,13 @@ function generate_port_link($args, $text = NULL, $type = NULL) function generate_port_url($port, $vars=array()) { - return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['interface_id']), $vars); + return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars); } function generate_port_thumbnail($args) { if (!$args['bg']) { $args['bg'] = "FFFFFF"; } - $args['content'] = ""; + $args['content'] = ""; echo(generate_port_link($args, $args['content'])); } diff --git a/html/includes/graphs/atmvp/auth.inc.php b/html/includes/graphs/atmvp/auth.inc.php index 6922beede..b307266b6 100644 --- a/html/includes/graphs/atmvp/auth.inc.php +++ b/html/includes/graphs/atmvp/auth.inc.php @@ -2,9 +2,9 @@ if ($_GET['id'] && is_numeric($_GET['id'])) { $atm_vp_id = $_GET['id']; } -$vp = dbFetchRow("SELECT * FROM `juniAtmVp` as J, `ports` AS I, `devices` AS D WHERE J.juniAtmVp_id = ? AND I.interface_id = J.interface_id AND I.device_id = D.device_id", array($atm_vp_id)); +$vp = dbFetchRow("SELECT * FROM `juniAtmVp` as J, `ports` AS I, `devices` AS D WHERE J.juniAtmVp_id = ? AND I.port_id = J.port_id AND I.device_id = D.device_id", array($atm_vp_id)); -if ($auth || port_permitted($vp['interface_id'])) +if ($auth || port_permitted($vp['port_id'])) { $port = $vp; $device = device_by_id_cache($port['device_id']); diff --git a/html/includes/graphs/bill/auth.inc.php b/html/includes/graphs/bill/auth.inc.php index a2438ae5b..bfb0debca 100644 --- a/html/includes/graphs/bill/auth.inc.php +++ b/html/includes/graphs/bill/auth.inc.php @@ -13,7 +13,7 @@ if (is_numeric($_GET['id']) && ($auth || bill_permitted($_GET['id']))) $rates = getRates($_GET['id'], $datefrom, $dateto); - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D WHERE B.bill_id = ? AND P.interface_id = B.port_id AND D.device_id = P.device_id", array($_GET['id'])); + $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D WHERE B.bill_id = ? AND P.port_id = B.port_id AND D.device_id = P.device_id", array($_GET['id'])); $auth = TRUE; } diff --git a/html/includes/graphs/macaccounting/auth.inc.php b/html/includes/graphs/macaccounting/auth.inc.php index e98dea3b5..dc1a7e84b 100644 --- a/html/includes/graphs/macaccounting/auth.inc.php +++ b/html/includes/graphs/macaccounting/auth.inc.php @@ -3,7 +3,7 @@ if (is_numeric($vars['id'])) { - $acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id", array($vars['id'])); + $acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id", array($vars['id'])); if ($debug) { echo("
");
@@ -14,7 +14,7 @@ if (is_numeric($vars['id']))
   if (is_array($acc))
   {
 
-    if ($auth || port_permitted($acc['interface_id']))
+    if ($auth || port_permitted($acc['port_id']))
     {
       if ($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); }
 
@@ -22,7 +22,7 @@ if (is_numeric($vars['id']))
       {
         if ($debug) { echo("exists"); }
         $rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
-        $port   = get_port_by_id($acc['interface_id']);
+        $port   = get_port_by_id($acc['port_id']);
         $device = device_by_id_cache($port['device_id']);
         $title  = generate_device_link($device);
         $title .= " :: Port  ".generate_port_link($port);
diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php
index 7d9245039..907bd06ad 100644
--- a/html/includes/graphs/multiport/bits.inc.php
+++ b/html/includes/graphs/multiport/bits.inc.php
@@ -10,7 +10,7 @@ foreach (explode(",", $vars['id']) as $ifid)
     $ifid = str_replace("!", "", $ifid);
   }
 
-  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd")))
   {
     $rrd_filenames[$i] = $config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd");
diff --git a/html/includes/graphs/multiport/bits_duo.inc.php b/html/includes/graphs/multiport/bits_duo.inc.php
index 3f1169e72..8393ece82 100644
--- a/html/includes/graphs/multiport/bits_duo.inc.php
+++ b/html/includes/graphs/multiport/bits_duo.inc.php
@@ -9,7 +9,7 @@ $i = 1;
 
 foreach (explode(",", $_GET['id']) as $ifid)
 {
-  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd"))
   {
     $rrd_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd:INOCTETS:AVERAGE";
@@ -26,7 +26,7 @@ unset($seperator); unset($plus);
 
 foreach (explode(",", $_GET['idb']) as $ifid)
 {
-  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd"))
   {
     $rrd_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd:INOCTETS:AVERAGE";
diff --git a/html/includes/graphs/multiport/bits_separate.inc.php b/html/includes/graphs/multiport/bits_separate.inc.php
index 114e9c722..3419078ad 100644
--- a/html/includes/graphs/multiport/bits_separate.inc.php
+++ b/html/includes/graphs/multiport/bits_separate.inc.php
@@ -4,7 +4,7 @@ $i = 0;
 
 foreach (explode(",", $vars['id']) as $ifid)
 {
-  $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")))
   {
     $port = ifLabel($port);
diff --git a/html/includes/graphs/multiport/bits_trio.inc.php b/html/includes/graphs/multiport/bits_trio.inc.php
index 354c97661..4506c67b2 100644
--- a/html/includes/graphs/multiport/bits_trio.inc.php
+++ b/html/includes/graphs/multiport/bits_trio.inc.php
@@ -10,7 +10,7 @@ $i = 1;
 
 foreach (explode(",", $_GET['id']) as $ifid)
 {
-  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd"))
   {
     if (strstr($inverse, "a")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; }
@@ -29,7 +29,7 @@ unset($seperator); unset($plus);
 
 foreach (explode(",", $_GET['idb']) as $ifid)
 {
-  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd"))
   {
     if (strstr($inverse, "b")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; }
@@ -48,7 +48,7 @@ unset($seperator); unset($plus);
 
 foreach (explode(",", $_GET['idc']) as $ifid)
 {
-  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid));
+  $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
   if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . $int['ifIndex'] . ".rrd"))
   {
     if (strstr($inverse, "c")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; }
diff --git a/html/includes/graphs/port/mac_acc_total.inc.php b/html/includes/graphs/port/mac_acc_total.inc.php
index 79a520cee..b5d76a038 100644
--- a/html/includes/graphs/port/mac_acc_total.inc.php
+++ b/html/includes/graphs/port/mac_acc_total.inc.php
@@ -36,8 +36,8 @@ if ($stat == "pkts")
 
 $accs = dbFetchRows("SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps,
         (M.cipMacHCSwitchedPkts_input_rate + M.cipMacHCSwitchedPkts_output_rate) AS pps
-        FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.interface_id = ?
-        AND I.interface_id = M.interface_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn, array($port));
+        FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.port_id = ?
+        AND I.port_id = M.port_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn, array($port));
 
 $pluses = ""; $iter = '0';
 $rrd_options .= " COMMENT:'                                     In\: Current     Maximum      Total      Out\: Current     Maximum     Total\\\\n'";
@@ -49,13 +49,13 @@ foreach ($accs as $acc)
   {
     $mac = formatmac($acc['mac']);
     $name = $mac;
-    $addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ? AND interface_id = ?", array($acc['mac'], $acc['interface_id']));
+    $addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ? AND port_id = ?", array($acc['mac'], $acc['port_id']));
 
     if ($addy)
     {
       $name = $addy['ipv4_address'] . " (".$mac.")";
       $peer = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D
-              WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($addy['ipv4_address']));
+              WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($addy['ipv4_address']));
       if ($peer)
       {
         $name = $peer['hostname'] . " " . makeshortif($peer['ifDescr']) . " (".$mac.")";
diff --git a/html/includes/javascript-interfacepicker.inc.php b/html/includes/javascript-interfacepicker.inc.php
index 9cc33fc4a..7fcdf11a9 100644
--- a/html/includes/javascript-interfacepicker.inc.php
+++ b/html/includes/javascript-interfacepicker.inc.php
@@ -6,7 +6,7 @@ var ajax = new Array();
 function getInterfaceList(sel)
 {
         var deviceId = sel.options[sel.selectedIndex].value;
-        document.getElementById('interface_id').options.length = 0;     // Empty city select box
+        document.getElementById('port_id').options.length = 0;     // Empty city select box
         if (deviceId.length>0) {
                 var index = ajax.length;
                 ajax[index] = new sack();
@@ -19,7 +19,7 @@ function getInterfaceList(sel)
 
 function createInterfaces(index)
 {
-        var obj = document.getElementById('interface_id');
+        var obj = document.getElementById('port_id');
         eval(ajax[index].response);     // Executing the response from Ajax as Javascript code
 }
 
diff --git a/html/includes/port-edit.inc.php b/html/includes/port-edit.inc.php
index 87c38a167..a0348c785 100644
--- a/html/includes/port-edit.inc.php
+++ b/html/includes/port-edit.inc.php
@@ -11,10 +11,10 @@ foreach ($_POST as $key => $val)
   {
     # Interface identifier passed as part of the field name
 
-    $interface_id = intval(substr($key,7));
+    $port_id = intval(substr($key,7));
 
     $oldign = intval($val) ? 1 : 0;
-    $newign = $_POST['ignore_'.$interface_id] ? 1 : 0;
+    $newign = $_POST['ignore_'.$port_id] ? 1 : 0;
 
     # As checkboxes are not posted when unset - we effectively need to do a diff to work
     # out a set->unset case.
@@ -24,7 +24,7 @@ foreach ($_POST as $key => $val)
       continue;
     }
 
-    $n = dbUpdate(array('ignore' => $newign), 'ports', '`device_id` = ? AND `interface_id` = ?', array($device_id, $interface_id));
+    $n = dbUpdate(array('ignore' => $newign), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id));
 
     if ($n <0)
     {
@@ -38,10 +38,10 @@ foreach ($_POST as $key => $val)
   {
     # Interface identifier passed as part of the field name
 
-    $interface_id = intval(substr($key,7));
+    $port_id = intval(substr($key,7));
 
     $olddis = intval($val) ? 1 : 0;
-    $newdis = $_POST['disabled_'.$interface_id] ? 1 : 0;
+    $newdis = $_POST['disabled_'.$port_id] ? 1 : 0;
 
     # As checkboxes are not posted when unset - we effectively need to do a diff to work
     # out a set->unset case.
@@ -51,7 +51,7 @@ foreach ($_POST as $key => $val)
       continue;
     }
 
-    $n = dbUpdate(array('disabled' => $newdis), 'ports', '`device_id` = ? AND `interface_id` = ?', array($device_id, $interface_id));
+    $n = dbUpdate(array('disabled' => $newdis), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id));
 
     if ($n <0)
     {
diff --git a/html/includes/print-interface-adsl.inc.php b/html/includes/print-interface-adsl.inc.php
index b991d8f64..a53d2fc1b 100644
--- a/html/includes/print-interface-adsl.inc.php
+++ b/html/includes/print-interface-adsl.inc.php
@@ -5,7 +5,7 @@
 $port['device_id'] = $device['device_id'];
 $port['hostname'] = $device['hostname'];
 
-$if_id = $port['interface_id'];
+$if_id = $port['port_id'];
 
 $port = ifLabel($port);
 
@@ -19,7 +19,7 @@ if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0)
 }
 
 echo("
+onclick=\"location.href='device/".$device['device_id']."/port/".$port['port_id']."/'\" style='cursor: pointer;'>
  ");
 echo("        
               " . generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) . "
@@ -30,12 +30,12 @@ if ($port['ifAlias']) { echo("
"); } unset ($break); if ($port_details) { - foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip) + foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) { echo("$break ".$ip['ipv4_address']."/".$ip['ipv4_prefixlen'].""); $break = ","; } - foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip6); + foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6); { echo("$break ".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen'].""); $break = ","; @@ -50,42 +50,42 @@ echo(""); echo(formatRates($port['ifInOctets_rate'] * 8)." ".formatRates($port['ifOutOctets_rate'] * 8)); echo("
"); $port['graph_type'] = "port_bits"; -echo(generate_port_link($port, "", $port['graph_type'])); echo(""); echo("".formatRates($port['adslAturChanCurrTxRate']) . "/". formatRates($port['adslAtucChanCurrTxRate'])); echo("
"); $port['graph_type'] = "port_adsl_speed"; -echo(generate_port_link($port, "", $port['graph_type'])); echo(""); echo("".formatRates($port['adslAturCurrAttainableRate']) . "/". formatRates($port['adslAtucCurrAttainableRate'])); echo("
"); $port['graph_type'] = "port_adsl_attainable"; -echo(generate_port_link($port, "", $port['graph_type'])); echo(""); echo("".$port['adslAturCurrAtn'] . "dB/". $port['adslAtucCurrAtn'] . "dB"); echo("
"); $port['graph_type'] = "port_adsl_attenuation"; -echo(generate_port_link($port, "", $port['graph_type'])); echo(""); echo("".$port['adslAturCurrSnrMgn'] . "dB/". $port['adslAtucCurrSnrMgn'] . "dB"); echo("
"); $port['graph_type'] = "port_adsl_snr"; -echo(generate_port_link($port, "", $port['graph_type'])); echo(""); echo("".$port['adslAturCurrOutputPwr'] . "dBm/". $port['adslAtucCurrOutputPwr'] . "dBm"); echo("
"); $port['graph_type'] = "port_adsl_power"; -echo(generate_port_link($port, "", $port['graph_type'])); # if ($port[ifDuplex] != unknown) { echo("Duplex " . $port['ifDuplex'] . ""); } else { echo("-"); } diff --git a/html/includes/print-interface-graphs.inc.php b/html/includes/print-interface-graphs.inc.php index 2fb634db0..1049c7d80 100644 --- a/html/includes/print-interface-graphs.inc.php +++ b/html/includes/print-interface-graphs.inc.php @@ -5,7 +5,7 @@ global $config; $graph_array['height'] = "100"; $graph_array['width'] = "215"; $graph_array['to'] = $config['time']['now']; -$graph_array['id'] = $port['interface_id']; +$graph_array['id'] = $port['port_id']; $graph_array['type'] = $graph_type; include("includes/print-graphrow.inc.php"); diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index c6b3bdbbc..b3ff988f2 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -5,7 +5,7 @@ $port['device_id'] = $device['device_id']; $port['hostname'] = $device['hostname']; -$if_id = $port['interface_id']; +$if_id = $port['port_id']; $port = ifLabel($port); @@ -16,14 +16,14 @@ if($int_colour) if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } } -$port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `interface_id` = ?", array($port['interface_id'])); +$port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id'])); if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) { $error_img = generate_port_link($port, "Interface Errors", "port_errors"); } else { $error_img = ""; } -if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `interface_id` = ?", array($port['interface_id']))) +if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?", array($port['port_id']))) { $mac = " 'macaccounting')) . "'>"; } else { $mac = ""; } @@ -40,12 +40,12 @@ unset ($break); if ($port_details) { - foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip) + foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) { echo("$break ".$ip['ipv4_address']."/".$ip['ipv4_prefixlen'].""); $break = "
"; } - foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip6) + foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6) { echo("$break ".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen'].""); $break = "
"; @@ -59,11 +59,11 @@ echo(""); if ($port_details) { $port['graph_type'] = "port_bits"; - echo(generate_port_link($port, "")); + echo(generate_port_link($port, "")); $port['graph_type'] = "port_upkts"; - echo(generate_port_link($port, "")); + echo(generate_port_link($port, "")); $port['graph_type'] = "port_errors"; - echo(generate_port_link($port, "")); + echo(generate_port_link($port, "")); } echo(""); @@ -91,7 +91,7 @@ if ($device['os'] == "ios" || $device['os'] == "iosxe") if ($port['ifTrunk']) { echo('

"); echo(""); if (strpos($port['label'], "oopback") === false && !$graph_type) { - foreach (dbFetchRows("SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_interface_id = ? AND L.remote_interface_id = I.interface_id AND I.device_id = D.device_id", array($if_id)) as $link) + foreach (dbFetchRows("SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_port_id = ? AND L.remote_port_id = I.port_id AND I.device_id = D.device_id", array($if_id)) as $link) { # echo("Directly Connected " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "
"); # $br = "
"; - $int_links[$link['interface_id']] = $link['interface_id']; - $int_links_phys[$link['interface_id']] = 1; + $int_links[$link['port_id']] = $link['port_id']; + $int_links_phys[$link['port_id']] = 1; } unset($br); if ($port_details) { ## Show which other devices are on the same subnet as this interface - foreach (dbFetchRows("SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = ? AND `ipv4_address` NOT LIKE '127.%'", array($port['interface_id'])) as $net) + foreach (dbFetchRows("SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `port_id` = ? AND `ipv4_address` NOT LIKE '127.%'", array($port['port_id'])) as $net) { $ipv4_network_id = $net['ipv4_network_id']; - $sql = "SELECT I.interface_id FROM ipv4_addresses AS A, ports AS I, devices AS D - WHERE A.interface_id = I.interface_id + $sql = "SELECT I.port_id FROM ipv4_addresses AS A, ports AS I, devices AS D + WHERE A.port_id = I.port_id AND A.ipv4_network_id = ? AND D.device_id = I.device_id AND D.device_id != ?"; $array = array($net['ipv4_network_id'], $device['device_id']); foreach (dbFetchRows($sql, $array) AS $new) { echo($new['ipv4_network_id']); - $this_ifid = $new['interface_id']; + $this_ifid = $new['port_id']; $this_hostid = $new['device_id']; $this_hostname = $new['hostname']; $this_ifname = fixifName($new['label']); @@ -165,11 +165,11 @@ if (strpos($port['label'], "oopback") === false && !$graph_type) } } - foreach (dbFetchRows("SELECT ipv6_network_id FROM ipv6_addresses WHERE interface_id = ?", array($port['interface_id'])) as $net) + foreach (dbFetchRows("SELECT ipv6_network_id FROM ipv6_addresses WHERE port_id = ?", array($port['port_id'])) as $net) { $ipv6_network_id = $net['ipv6_network_id']; - $sql = "SELECT I.interface_id FROM ipv6_addresses AS A, ports AS I, devices AS D - WHERE A.interface_id = I.interface_id + $sql = "SELECT I.port_id FROM ipv6_addresses AS A, ports AS I, devices AS D + WHERE A.port_id = I.port_id AND A.ipv6_network_id = ? AND D.device_id = I.device_id AND D.device_id != ? AND A.ipv6_origin != 'linklayer' AND A.ipv6_origin != 'wellknown'"; $array = array($net['ipv6_network_id'], $device['device_id']); @@ -177,7 +177,7 @@ if (strpos($port['label'], "oopback") === false && !$graph_type) foreach (dbFetchRows($sql, $array) AS $new) { echo($new['ipv6_network_id']); - $this_ifid = $new['interface_id']; + $this_ifid = $new['port_id']; $this_hostid = $new['device_id']; $this_hostname = $new['hostname']; $this_ifname = fixifName($new['label']); @@ -191,7 +191,7 @@ if (strpos($port['label'], "oopback") === false && !$graph_type) { foreach ($int_links as $int_link) { - $link_if = dbFetchRow("SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = ?", array($int_link)); + $link_if = dbFetchRow("SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.port_id = ?", array($int_link)); echo("$br"); @@ -210,11 +210,11 @@ if (strpos($port['label'], "oopback") === false && !$graph_type) if ($port_details) { - foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `interface_id` = ?", array($port['interface_id'])) as $pseudowire) + foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) { - #`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid` + #`port_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid` $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id'])); - $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID'])); + $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID'])); $pw_peer_int = ifNameDescr($pw_peer_int); echo("$br " . generate_port_link($pw_peer_int, makeshortif($pw_peer_int['label'])) ." on ". generate_device_link($pw_peer_dev, shorthost($pw_peer_dev['hostname'])) . ""); @@ -234,21 +234,21 @@ if ($port_details) $br = "
"; } - foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) + foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) { - if ($higher_if['interface_id_high']) + if ($higher_if['port_id_high']) { - $this_port = get_port_by_index_cache($device['device_id'], $higher_if['interface_id_high']); + $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']); echo("$br " . generate_port_link($this_port) . ""); $br = "
"; } } - foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) + foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) { - if ($lower_if['interface_id_low']) + if ($lower_if['port_id_low']) { - $this_port = get_port_by_index_cache($device['device_id'], $lower_if['interface_id_low']); + $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']); echo("$br " . generate_port_link($this_port) . ""); $br = "
"; } diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index c16d77b2d..45bf50557 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -3,7 +3,7 @@ ## FIXME - this could do with some performance improvements, i think. possible rearranging some tables and setting flags at poller time (nothing changes outside of then anyways) $service_alerts = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '0'"); -$if_alerts = dbFetchCell("SELECT COUNT(interface_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'"); +$if_alerts = dbFetchCell("SELECT COUNT(port_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'"); if (isset($config['enable_bgp']) && $config['enable_bgp']) { @@ -265,7 +265,7 @@ if (isset($interface_alerts)) $deleted_ports = 0; foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { - if (port_permitted($interface['interface_id'], $interface['device_id'])) + if (port_permitted($interface['port_id'], $interface['device_id'])) { $deleted_ports++; } diff --git a/html/includes/print-vlan.inc.php b/html/includes/print-vlan.inc.php index 29c0273d0..9b496035c 100644 --- a/html/includes/print-vlan.inc.php +++ b/html/includes/print-vlan.inc.php @@ -9,7 +9,7 @@ echo("" . $vlan['vlan_name'] . ""); echo(""); $vlan_ports = array(); - $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.interface_id = V.interface_id", array($device['device_id'], $vlan['vlan_vlan'])); + $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan_vlan'])); foreach ($otherports as $otherport) { $vlan_ports[$otherport[ifIndex]] = $otherport; @@ -28,12 +28,12 @@ foreach ($vlan_ports as $port) { echo("

".makeshortif($port['ifDescr'])."
- ".$device['hostname']." - ".$port['ifDescr']."
\ ".$port['ifAlias']." \ - \ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " + "
".truncate(short_port_descr($port['ifAlias']), 22, '')."
"); diff --git a/html/includes/print-vrf.inc.php b/html/includes/print-vrf.inc.php index 65c264ef4..85847ab3b 100644 --- a/html/includes/print-vrf.inc.php +++ b/html/includes/print-vrf.inc.php @@ -16,12 +16,12 @@ foreach (dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?" $graph_type = "port_" . $vars['graph']; echo("
".makeshortif($port['ifDescr'])."
- ".$device['hostname']." - ".$port['ifDescr']."
\ ".$port['ifAlias']." \ - \ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " + "
".truncate(short_port_descr($port['ifAlias']), 22, '')."
"); diff --git a/html/map.php b/html/map.php index 6ca2ac298..ab0efab15 100755 --- a/html/map.php +++ b/html/map.php @@ -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"; } } } diff --git a/html/pages/about.inc.php b/html/pages/about.inc.php index a9eea27bf..809cb1ebd 100644 --- a/html/pages/about.inc.php +++ b/html/pages/about.inc.php @@ -39,7 +39,7 @@ along with this program. If not, see htt

diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index 6a4e86eb6..00bd547e2 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -41,11 +41,11 @@ if ($_POST['action'] == "reset_bill" && ($_POST['confirm'] == "rrd" || $_POST['c if ($_POST['action'] == "add_bill_port") { - dbInsert(array('bill_id' => $_POST['bill_id'], 'port_id' => $_POST['interface_id']), 'bill_ports'); + dbInsert(array('bill_id' => $_POST['bill_id'], 'port_id' => $_POST['port_id']), 'bill_ports'); } if ($_POST['action'] == "delete_bill_port") { - dbDelete('bill_ports', "`bill_id` = ? AND `port_id` = ?", array($bill_id, $_POST['interface_id'])); + dbDelete('bill_ports', "`bill_id` = ? AND `port_id` = ?", array($bill_id, $_POST['port_id'])); } if ($_POST['action'] == "update_bill") { diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index 3a4ad31e4..bd3ded416 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -118,7 +118,7 @@ for ($x=1;$x<32;$x++) { ".$port['hostname'], "\" style=\"color: #000;\"> ".$port['hostname'], $devicebtn); $portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"> ".$port['ifName']."".$portalias, $portbtn); - echo("
\n"); + echo(" \n"); echo(" \n"); - echo(" \n"); + echo(" \n"); echo("
\n"); echo("
\n"); echo("
\n"); - //echo(" \n"); + //echo(" \n"); echo(" ".$devicebtn."\n"); echo(" ".$portbtn."\n"); echo("
\n"); echo("
\n"); - echo(" Remove Interface\n"); + echo(" Remove Interface\n"); echo("
\n"); echo("
\n"); } @@ -189,9 +189,9 @@ foreach ($devices as $device)
- +
- +
diff --git a/html/pages/bill/pdf_history.inc.php b/html/pages/bill/pdf_history.inc.php index 054539b26..b02f862ee 100644 --- a/html/pages/bill/pdf_history.inc.php +++ b/html/pages/bill/pdf_history.inc.php @@ -120,7 +120,7 @@ //$res .= " Description"; //$res .= " Notes"; $res .= " "; - foreach (dbFetchRows("SELECT * FROM `bill_ports` as b, `ports` as p, `devices` as d WHERE b.bill_id = ? AND p.interface_id = b.port_id AND d.device_id = p.device_id", array($bill_id)) as $row) { + foreach (dbFetchRows("SELECT * FROM `bill_ports` as b, `ports` as p, `devices` as d WHERE b.bill_id = ? AND p.port_id = b.port_id AND d.device_id = p.device_id", array($bill_id)) as $row) { if (bill_permitted($bill_id)) { $device['name'] = $row['sysName']; //$device['port'] = $row['ifName']." (".$row['ifDescr'].")"; diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index 303a18509..d7029c7f5 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -54,7 +54,7 @@ elseif ($_GET['opta'] == "add") { if (is_numeric($vars['port'])) { - $port = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE `interface_id` = ? AND D.device_id = P.device_id", array($vars['port'])); + $port = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id", array($vars['port'])); } ?> @@ -99,7 +99,7 @@ if(is_array($port)) $portbtn = str_replace("overlib('", "overlib('
", $portbtn); $portbtn = str_replace("
',;", "
',", $portbtn); echo("
\n"); - echo(" \n"); + echo(" \n"); echo(" Ports\n"); echo("
\n"); echo("
\n"); diff --git a/html/pages/deleted-ports.inc.php b/html/pages/deleted-ports.inc.php index 46ec6c7c2..d0d6c3479 100644 --- a/html/pages/deleted-ports.inc.php +++ b/html/pages/deleted-ports.inc.php @@ -6,16 +6,16 @@ if ($vars['purge'] == "all") { foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { - if (port_permitted($interface['interface_id'], $interface['device_id'])) + if (port_permitted($interface['port_id'], $interface['device_id'])) { - delete_port($interface['interface_id']); + delete_port($interface['port_id']); echo("
Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."
"); } } } elseif ($vars['purge']) { - $interface = dbFetchRow("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = ? AND D.device_id = P.device_id", array($vars['purge'])); - if (port_permitted($interface['interface_id'], $interface['device_id'])) - delete_port($interface['interface_id']); + $interface = dbFetchRow("SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id", array($vars['purge'])); + if (port_permitted($interface['port_id'], $interface['device_id'])) + delete_port($interface['port_id']); echo("
Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."
"); } @@ -25,13 +25,13 @@ echo(""); echo("".generate_device_link($interface).""); echo("".generate_port_link($interface).""); echo(""); - echo(" Purge"); + echo(" Purge"); } } diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 4b041f336..a8915e76b 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -2,7 +2,7 @@ if ($vars['tab'] == "port" && is_numeric($vars['device']) && port_permitted($vars['port'])) { - $check_device = get_device_id_by_interface_id($vars['port']); + $check_device = get_device_id_by_port_id($vars['port']); $permit_ports = 1; } @@ -100,7 +100,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } - if (@dbFetchCell("SELECT COUNT(interface_id) FROM ports WHERE device_id = '" . $device['device_id'] . "'") > '0') + if (@dbFetchCell("SELECT COUNT(port_id) FROM ports WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('
  • @@ -236,7 +236,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
  • '); } - if ($_SESSION['userlevel'] >= "5" && dbFetchCell("SELECT COUNT(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id")) + if ($_SESSION['userlevel'] >= "5" && dbFetchCell("SELECT COUNT(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { $discovery_links = TRUE; echo('
  • diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index 3640a73ca..fcdf02d0f 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -74,9 +74,9 @@ $(document).ready(function() { var text = $(this).text(); if (name && text == 'down') { // get the interface number from the object name - var interface_id = name.split('_')[1]; + var port_id = name.split('_')[1]; // find its corresponding checkbox and toggle it - $('[name="ignore_' + interface_id + '"]').check(); + $('[name="ignore_' + port_id + '"]').check(); } }); }); @@ -87,9 +87,9 @@ $(document).ready(function() { var name = $(this).attr('name'); if (name) { // get the interface number from the object name - var interface_id = name.split('_')[1]; + var port_id = name.split('_')[1]; // find its corresponding checkbox and toggle it - $('[name="ignore_' + interface_id + '"]').check('toggle'); + $('[name="ignore_' + port_id + '"]').check('toggle'); } }); }); @@ -122,16 +122,16 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY `ifIn $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; $outofsync = $dowecare ? " class='red'" : ""; - echo("". $port['ifOperStatus'].""); + echo("". $port['ifOperStatus'].""); echo(""); - echo(""); - echo(""); + echo(""); + echo(""); echo(""); echo(""); - echo(""); - echo(""); + echo(""); + echo(""); echo(""); echo("".$port['ifAlias'] . ""); diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index 0e3fbb1a9..c613a8f62 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -40,7 +40,7 @@ foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `h $graph_array['height'] = "20"; $graph_array['width'] = "100"; $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['interface_id']; + $graph_array['id'] = $interface['port_id']; $graph_array['type'] = 'port_bits'; $graph_array['from'] = $config['time']['day']; $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index e0445f0cf..5420ff482 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -2,14 +2,14 @@ if (!isset($vars['view']) ) { $vars['view'] = "graphs"; } -$port = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($vars['port'])); +$port = dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($vars['port'])); if ($config['memcached']['enable']) { $oids = array('ifInOctets', 'ifOutOctets', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInErrors', 'ifOutErrors'); foreach ($oids as $oid) { - $port[$oid.'_rate'] = $memcache->get('port-'.$port['interface_id'].'-'.$oid.'_rate'); + $port[$oid.'_rate'] = $memcache->get('port-'.$port['port_id'].'-'.$oid.'_rate'); if ($debug) { echo("MC[".$oid."->".$port[$oid.'_rate']."]"); } } } @@ -17,7 +17,7 @@ if ($config['memcached']['enable']) $port_details = 1; $hostname = $device['hostname']; -$hostid = $device['interface_id']; +$hostid = $device['port_id']; $ifname = $port['ifDescr']; $ifIndex = $port['ifIndex']; $speed = humanspeed($port['ifSpeed']); @@ -64,20 +64,20 @@ print_optionbar_start(); $link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', - 'port' => $port['interface_id']); + 'port' => $port['port_id']); $menu_options['graphs'] = 'Graphs'; $menu_options['realtime'] = 'Real time'; ### FIXME CONDITIONAL $menu_options['arp'] = 'ARP Table'; $menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$port['interface_id']."'") ) +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) { $menu_options['adsl'] = 'ADSL'; } if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) { $menu_options['pagp'] = 'PAgP'; } -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `interface_id` = '".$port['interface_id']."' and `device_id` = '".$device['device_id']."'") ) +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) { $menu_options['vlans'] = 'VLANs'; } $sep = ""; @@ -91,7 +91,7 @@ foreach ($menu_options as $option => $text) } unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$port['interface_id']."'") > "0" ) +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) { echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); @@ -126,7 +126,7 @@ if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$po echo(")"); } -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$port['interface_id']."'") > "0" ) +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) { ### FIXME ATM VPs @@ -134,25 +134,25 @@ if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$port['i echo(" | ATM VPs : "); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo("Bits"); + echo("Bits"); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } echo(" | "); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } - echo("Packets"); + echo("Packets"); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } echo(" | "); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } - echo("Cells"); + echo("Cells"); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } echo(" | "); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } - echo("Errors"); + echo("Errors"); if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } } if ($_SESSION['userlevel'] == '10') { - echo(" Create Bill"); + echo(" Create Bill"); } print_optionbar_end(); diff --git a/html/pages/device/port/arp.inc.php b/html/pages/device/port/arp.inc.php index 95ee2989d..f9898a363 100644 --- a/html/pages/device/port/arp.inc.php +++ b/html/pages/device/port/arp.inc.php @@ -3,16 +3,16 @@ echo(''); $i = "1"; -foreach (dbFetchRows("SELECT * FROM ipv4_mac WHERE interface_id = ?", array($port['interface_id'])) as $arp) +foreach (dbFetchRows("SELECT * FROM ipv4_mac WHERE port_id = ?", array($port['port_id'])) as $arp) { if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($arp['ipv4_address'])); + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($arp['ipv4_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } if ($arp_host['device_id'] == $device['device_id']) { $arp_name = "Localhost"; } - if ($arp_host['interface_id'] == $arp['interface_id']) { $arp_if = "Local Port"; } + if ($arp_host['port_id'] == $arp['port_id']) { $arp_if = "Local Port"; } echo(' diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index bc7104639..3cdd09c7b 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,6 +1,6 @@ '); foreach ($entries as $entry) diff --git a/html/pages/device/port/junose-atm-vp.inc.php b/html/pages/device/port/junose-atm-vp.inc.php index 1f2558d29..0c57c75d6 100644 --- a/html/pages/device/port/junose-atm-vp.inc.php +++ b/html/pages/device/port/junose-atm-vp.inc.php @@ -7,7 +7,7 @@ if (!$graph_type) { $graph_type = "atmvp_bits"; } echo('
    '); -foreach (dbFetchRows("SELECT * FROM juniAtmVp WHERE interface_id = ?", array($interface['interface_id'])) as $vp) +foreach (dbFetchRows("SELECT * FROM juniAtmVp WHERE port_id = ?", array($interface['port_id'])) as $vp) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } echo(''); diff --git a/html/pages/device/port/macaccounting.inc.php b/html/pages/device/port/macaccounting.inc.php index 639ec2ebc..de7f5b746 100644 --- a/html/pages/device/port/macaccounting.inc.php +++ b/html/pages/device/port/macaccounting.inc.php @@ -3,7 +3,7 @@ ## FIXME - REWRITE! $hostname = $device['hostname']; -$hostid = $device['interface_id']; +$hostid = $device['port_id']; $ifname = $port['ifDescr']; $ifIndex = $port['ifIndex']; $speed = humanspeed($port['ifSpeed']); @@ -36,70 +36,70 @@ if ($vars['subview'] == "top10") 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => $vars['sort'], 'period' => 'day'))."'> -
    - +
    @@ -112,15 +112,15 @@ if ($vars['subview'] == "top10") { $query = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) as bps FROM `mac_accounting` AS M, - `ports` AS I, `devices` AS D WHERE M.interface_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id ORDER BY bps DESC"; - $param = array($port['interface_id']); + `ports` AS I, `devices` AS D WHERE M.port_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id ORDER BY bps DESC"; + $param = array($port['port_id']); foreach (dbFetchRows($query, $param) as $acc) { if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } $addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ?", array($acc['mac'])); #$name = gethostbyaddr($addy['ipv4_address']); FIXME - Maybe some caching for this? - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($addy['ipv4_address'])); + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($addy['ipv4_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); $arp_name .= " ".generate_port_link($arp_host); } else { unset($arp_if); } if ($name == $addy['ipv4_address']) { unset ($name); } diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index d390d0bd2..69c3e116f 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -6,17 +6,17 @@ global $config; if (!$graph_type) { $graph_type = "pagp_bits"; } -$daily_traffic = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; -$daily_url = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; +$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; +$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; -$weekly_traffic = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; -$weekly_url = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; +$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; +$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; -$monthly_traffic = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; -$monthly_url = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; +$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; +$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; -$yearly_traffic = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['yearh']."&to=".$config['time']['now']."&width=215&height=100"; -$yearly_url = "graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=".$config['time']['yearh']."&to=".$config['time']['now']."&width=500&height=150"; +$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['yearh']."&to=".$config['time']['now']."&width=215&height=100"; +$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['yearh']."&to=".$config['time']['now']."&width=500&height=150"; echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); diff --git a/html/pages/device/port/realtime.inc.php b/html/pages/device/port/realtime.inc.php index 87fd8a851..cf4f05c95 100644 --- a/html/pages/device/port/realtime.inc.php +++ b/html/pages/device/port/realtime.inc.php @@ -28,8 +28,8 @@ print_optionbar_end(); ?>
    - - + + Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin. diff --git a/html/pages/device/port/vlans.inc.php b/html/pages/device/port/vlans.inc.php index 5bbf28d7b..d96071c6a 100644 --- a/html/pages/device/port/vlans.inc.php +++ b/html/pages/device/port/vlans.inc.php @@ -1,6 +1,6 @@ '); @@ -21,7 +21,7 @@ foreach ($vlans as $vlan) echo("
    "); $vlan_ports = array(); - $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.interface_id = V.interface_id", array($device['device_id'], $vlan['vlan'])); + $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan'])); foreach ($otherports as $otherport) { $vlan_ports[$otherport[ifIndex]] = $otherport; diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 1a58acc1c..83cdd8d6e 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -17,7 +17,7 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id")) +if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { $menu_options['neighbours'] = 'Neighbours'; } @@ -78,9 +78,9 @@ if ($vars['view'] == 'minigraphs') ".$device['hostname']." - ".$port['ifDescr']."\ ".$port['ifAlias']." \ - \ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " + "
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    "); @@ -100,7 +100,7 @@ if ($vars['view'] == 'minigraphs') ### FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. foreach ($ports as $port) { - $port_cache[$port['interface_id']] = $port; + $port_cache[$port['port_id']] = $port; $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; } @@ -111,7 +111,7 @@ if ($vars['view'] == 'minigraphs') $oids = array('ifInOctets', 'ifOutOctets', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInErrors', 'ifOutErrors'); foreach ($oids as $oid) { - $port[$oid.'_rate'] = $memcache->get('port-'.$port['interface_id'].'-'.$oid.'_rate'); + $port[$oid.'_rate'] = $memcache->get('port-'.$port['port_id'].'-'.$oid.'_rate'); if ($debug) { echo("MC[".$oid."->".$port[$oid.'_rate']."]"); } } } diff --git a/html/pages/device/ports/adsl.inc.php b/html/pages/device/ports/adsl.inc.php index b8a098998..cb75fa4df 100644 --- a/html/pages/device/ports/adsl.inc.php +++ b/html/pages/device/ports/adsl.inc.php @@ -4,7 +4,7 @@ echo(""); $i = "0"; - $ports = dbFetchRows("select * from `ports` AS P, `ports_adsl` AS A WHERE P.device_id = ? AND A.interface_id = P.interface_id AND P.deleted = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + $ports = dbFetchRows("select * from `ports` AS P, `ports_adsl` AS A WHERE P.device_id = ? AND A.port_id = P.port_id AND P.deleted = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); foreach ($ports as $port) { include("includes/print-interface-adsl.inc.php"); diff --git a/html/pages/device/ports/arp.inc.php b/html/pages/device/ports/arp.inc.php index c484a5db7..e4a9b19d2 100644 --- a/html/pages/device/ports/arp.inc.php +++ b/html/pages/device/ports/arp.inc.php @@ -5,17 +5,17 @@ echo(' diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index ac666ff10..02a5091dd 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,7 +10,7 @@ echo(''); -foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.interface_id = L.local_interface_id", array($device['device_id'])) as $neighbour) +foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id", array($device['device_id'])) as $neighbour) { if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } @@ -18,9 +18,9 @@ foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? echo(''); echo(''); - if (is_numeric($neighbour['remote_interface_id']) && $neighbour['remote_interface_id']) + if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id']) { - $remote_port = get_port_by_id($neighbour['remote_interface_id']); + $remote_port = get_port_by_id($neighbour['remote_port_id']); $remote_device = device_by_id_cache($remote_port['device_id']); echo(""); echo(""); diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index 6b07b7c9e..c39f02454 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -24,21 +24,21 @@ print_optionbar_end(); echo("
    ".$vlan['cost']."".$vlan['priority']."".$vlan['state']."
    PortTrafficSync SpeedAttainable SpeedAttenuationSNR MarginOutput Powers
    PortMAC addressIPv4 addressRemote devic $i = "1"; -foreach (dbFetchRows("SELECT * FROM ipv4_mac AS M, ports AS I WHERE I.interface_id = M.interface_id AND I.device_id = ?", array($device['device_id'])) as $arp) +foreach (dbFetchRows("SELECT * FROM ipv4_mac AS M, ports AS I WHERE I.port_id = M.port_id AND I.device_id = ?", array($device['device_id'])) as $arp) { if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($arp['ipv4_address'])); + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($arp['ipv4_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } if ($arp_host['device_id'] == $device['device_id']) { $arp_name = "Localhost"; } - if ($arp_host['interface_id'] == $arp['interface_id']) { $arp_if = "Local Port"; } + if ($arp_host['port_id'] == $arp['port_id']) { $arp_if = "Local Port"; } echo("
    Local Port Protocol
    '.generate_port_link($neighbour).'
    '.$neighbour['ifAlias'].'
    ".generate_port_link($remote_port)."
    ".$remote_port['ifAlias']."
    ".generate_device_link($remote_device)."
    ".$remote_device['hardware']."
    "); -foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I WHERE P.interface_id = I.interface_id AND I.device_id = ? ORDER BY I.ifDescr", array($device['device_id'])) as $pw_a) +foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id = I.port_id AND I.device_id = ? ORDER BY I.ifDescr", array($device['device_id'])) as $pw_a) { $i = 0; while ($i < count($linkdone)) { - $thislink = $pw_a['device_id'] . $pw_a['interface_id']; + $thislink = $pw_a['device_id'] . $pw_a['port_id']; if ($linkdone[$i] == $thislink) { $skip = "yes"; } $i++; } $pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id - AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); + AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); - if (!port_permitted($pw_a['interface_id'])) { $skip = "yes"; } - if (!port_permitted($pw_b['interface_id'])) { $skip = "yes"; } + if (!port_permitted($pw_a['port_id'])) { $skip = "yes"; } + if (!port_permitted($pw_b['port_id'])) { $skip = "yes"; } if ($skip) { @@ -88,7 +88,7 @@ foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I WHERE P.interfa echo(""); } - $linkdone[] = $pw_b['device_id'] . $pw_b['interface_id']; + $linkdone[] = $pw_b['device_id'] . $pw_b['port_id']; } } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index e66bdc1ed..25227df2b 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -76,12 +76,12 @@ foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv4_address = ? AND I.interface_id = A.interface_id)"; + $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; $query .= " AND D.device_id = I.device_id"; $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv6_address = ? AND I.interface_id = A.interface_id)"; + $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; $query .= " AND D.device_id = I.device_id"; $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); @@ -167,7 +167,7 @@ foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.interface_id = M.interface_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; if (is_array($acc) && is_file($database)) { diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index f8322b36c..05168fd29 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -16,7 +16,7 @@ foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", arr $nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])); $query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE "; - $query .= "(A.ipv4_address = ? AND I.interface_id = A.interface_id)"; + $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; $query .= " AND I.device_id = ?"; $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id'])); @@ -63,7 +63,7 @@ foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", arr ##### Loop Ports $i_p = $i_a + 1; - $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.interface_id = O.interface_id"; + $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { if (!is_integer($i_a/2)) @@ -107,7 +107,7 @@ foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", arr if (!is_integer($i_n/2)) { $nbr_bg = $list_colour_b_a; } else { $nbr_bg = $list_colour_b_b; } $host = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? - AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId'])); + AND I.port_id = A.port_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId'])); if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = "unknown"; } diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index 3d0ebd464..924155ac1 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -30,16 +30,16 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } if ($vars['action'] == "delifperm") { - if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = ? AND `user_id` = ?", array($vars['interface_id'], $vars['user_id']))) + if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) { - dbDelete('ports_perms', "`interface_id` = ? AND `user_id` = ?", array($vars['interface_id'], $vars['user_id'])); + dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); } } if ($vars['action'] == "addifperm") { - if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = ? AND `user_id` = ?", array($vars['interface_id'], $vars['user_id']))) + if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) { - dbInsert(array('interface_id' => $vars['interface_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); } } if ($vars['action'] == "delbillperm") @@ -96,13 +96,13 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); echo("
    "); echo("

    Interface Access

    "); - $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.interface_id = P.interface_id AND D.device_id = I.device_id", array($vars['user_id'])); + $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); foreach ($interface_perms as $interface_perm) { echo("
    ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."
    ". "" . $interface_perm['ifAlias'] . "
      
    "); + "/port_id=" . $interface_perm['port_id'] . "'>
    "); $ipermdone = "yes"; } @@ -127,7 +127,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } echo(" - Interface: "); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index bdda5a82d..46fdb46cf 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -42,7 +42,7 @@ if ($config['warn']['ifdown']) $interface = ifNameDescr($interface); generate_front_box("#ffdd99", "
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - + ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') . "
    "); diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 30d30ca1e..722a2b896 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -96,7 +96,7 @@ if ($config['warn']['ifdown']) $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while ($interface = mysql_fetch_array($sql)) { - if (port_permitted($interface['interface_id'])) + if (port_permitted($interface['port_id'])) { echo("
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 9ba99cdf2..60fd45adc 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -116,7 +116,7 @@ if ($_SESSION['userlevel'] >= '5') unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['l2tp'] .= $seperator . $interface['interface_id']; + $ports['l2tp'] .= $seperator . $interface['port_id']; $seperator = ","; } @@ -126,7 +126,7 @@ if ($_SESSION['userlevel'] >= '5') unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['transit'] .= $seperator . $interface['interface_id']; + $ports['transit'] .= $seperator . $interface['port_id']; $seperator = ","; } @@ -136,7 +136,7 @@ if ($_SESSION['userlevel'] >= '5') unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['voip'] .= $seperator . $interface['interface_id']; + $ports['voip'] .= $seperator . $interface['port_id']; $seperator = ","; } diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index af3260792..b9fc58dc8 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -101,7 +101,7 @@ if ($config['warn']['ifdown']) $interface = ifNameDescr($interface); generate_front_box("#ffdd99", "
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - + ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') . "
    "); diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 76ccebf56..0ea0cae0a 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -42,7 +42,7 @@ if ($config['warn']['ifdown']) { $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while ($interface = mysql_fetch_assoc($sql)) { - if (port_permitted($interface['interface_id'])) { + if (port_permitted($interface['port_id'])) { echo("
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    @@ -120,7 +120,7 @@ if ($_SESSION['userlevel'] >= '5') $query = mysql_query($sql); unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['transit'] .= $seperator . $interface['interface_id']; + $ports['transit'] .= $seperator . $interface['port_id']; $seperator = ","; } @@ -128,7 +128,7 @@ if ($_SESSION['userlevel'] >= '5') $query = mysql_query($sql); unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['peering'] .= $seperator . $interface['interface_id']; + $ports['peering'] .= $seperator . $interface['port_id']; $seperator = ","; } diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 64aa779bf..f420b00e3 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -42,7 +42,7 @@ if ($config['warn']['ifdown']) { foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { - if (port_permitted($interface['interface_id'])) { + if (port_permitted($interface['port_id'])) { echo("
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    @@ -119,7 +119,7 @@ if ($_SESSION['userlevel'] >= '5') $query = mysql_query($sql); unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['transit'] .= $seperator . $interface['interface_id']; + $ports['transit'] .= $seperator . $interface['port_id']; $seperator = ","; } @@ -127,7 +127,7 @@ if ($_SESSION['userlevel'] >= '5') $query = mysql_query($sql); unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['peering'] .= $seperator . $interface['interface_id']; + $ports['peering'] .= $seperator . $interface['port_id']; $seperator = ","; } @@ -135,7 +135,7 @@ if ($_SESSION['userlevel'] >= '5') $query = mysql_query($sql); unset ($seperator); while ($interface = mysql_fetch_assoc($query)) { - $ports['core'] .= $seperator . $interface['interface_id']; + $ports['core'] .= $seperator . $interface['port_id']; $seperator = ","; } diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index bdc7ba56a..346a46436 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -17,7 +17,7 @@ $ports = dbFetchRows("SELECT * FROM `ports` as I, `devices` AS D WHERE $type_whe foreach ($ports as $port) { - $if_list .= $seperator . $port['interface_id']; + $if_list .= $seperator . $port['port_id']; $seperator = ","; } unset($seperator); @@ -32,7 +32,7 @@ echo(" if ($if_list) { $graph_type = "multiport_bits_separate"; - $port['interface_id'] = $if_list; + $port['port_id'] = $if_list; include("includes/print-interface-graphs.inc.php"); @@ -50,9 +50,9 @@ if ($if_list) " . generate_port_link($port,$port['port_descr_descr']) . "
    ".generate_device_link($port)." ".generate_port_link($port)." "); - if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = ?", array($port['interface_id']))) + if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = ?", array($port['port_id']))) { - echo(" MAC Accounting"); + echo(" MAC Accounting"); } echo('
    '); diff --git a/html/pages/ports/graph.inc.php b/html/pages/ports/graph.inc.php index 768aeca8b..90455b2d1 100644 --- a/html/pages/ports/graph.inc.php +++ b/html/pages/ports/graph.inc.php @@ -15,7 +15,7 @@ foreach ($ports as $port) $error_img = generate_port_link($port,"Interface Errors",errors); } else { $error_img = ""; } - if (port_permitted($port['interface_id'], $port['device_id'])) + if (port_permitted($port['port_id'], $port['device_id'])) { $port = ifLabel($port, $device); @@ -28,7 +28,7 @@ foreach ($ports as $port) $graph_array['height'] = 100; $graph_array['width'] = 210; $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $port['interface_id']; + $graph_array['id'] = $port['port_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; @@ -49,9 +49,9 @@ foreach ($ports as $port) # echo("\ -# \ +# \ # ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". -# " +# " # #
    "); } diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 42534e512..375fabc0c 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -35,7 +35,7 @@ foreach ($ports as $port) } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } $ports_total++; - if (port_permitted($port['interface_id'], $port['device_id'])) + if (port_permitted($port['port_id'], $port['device_id'])) { $speed = humanspeed($port['ifSpeed']); $type = humanmedia($port['ifType']); diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 4d8649ff7..b506e0efc 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -24,21 +24,21 @@ print_optionbar_end(); echo(""); -foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr") as $pw_a) +foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.port_id = I.port_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr") as $pw_a) { $i = 0; while ($i < count($linkdone)) { - $thislink = $pw_a['device_id'] . $pw_a['interface_id']; + $thislink = $pw_a['device_id'] . $pw_a['port_id']; if ($linkdone[$i] == $thislink) { $skip = "yes"; } $i++; } $pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id - AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); + AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); - if (!port_permitted($pw_a['interface_id'])) { $skip = "yes"; } - if (!port_permitted($pw_b['interface_id'])) { $skip = "yes"; } + if (!port_permitted($pw_a['port_id'])) { $skip = "yes"; } + if (!port_permitted($pw_b['port_id'])) { $skip = "yes"; } if ($skip) { @@ -88,7 +88,7 @@ foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I, devices AS D W echo(""); } - $linkdone[] = $pw_b['device_id'] . $pw_b['interface_id']; + $linkdone[] = $pw_b['device_id'] . $pw_b['port_id']; } } diff --git a/html/pages/purgeports.inc.php b/html/pages/purgeports.inc.php index 200bfd8db..3bd98e20e 100644 --- a/html/pages/purgeports.inc.php +++ b/html/pages/purgeports.inc.php @@ -2,8 +2,8 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '1'") as $port) { - echo("
    Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']); - delete_port($port['interface_id']); + echo("
    Deleting port " . $port['port_id'] . " - " . $port['ifDescr']); + delete_port($port['port_id']); echo("
    "); } diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 89c589dba..719930bd7 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -160,7 +160,7 @@ else if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } } - $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); + $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } @@ -219,7 +219,7 @@ else { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.interface_id = M.interface_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; if (is_array($acc) && is_file($database)) { diff --git a/html/pages/routing/ospf.inc.php b/html/pages/routing/ospf.inc.php index b8b8c4023..dacf7362e 100644 --- a/html/pages/routing/ospf.inc.php +++ b/html/pages/routing/ospf.inc.php @@ -19,7 +19,7 @@ foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `ospfAdminStat` = 'en $neighbour_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."'"); $ip_query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE "; - $ip_query .= "(A.ipv4_address = ? AND I.interface_id = A.interface_id)"; + $ip_query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; $ip_query .= " AND I.device_id = ?"; $ipv4_host = dbFetchRow($ip_query, array($peer['bgpPeerIdentifier'], $device['device_id'])); diff --git a/html/pages/routing/vrf.inc.php b/html/pages/routing/vrf.inc.php index 3adfca948..5d0e10a67 100644 --- a/html/pages/routing/vrf.inc.php +++ b/html/pages/routing/vrf.inc.php @@ -49,7 +49,7 @@ if($_GET['optb'] == "all" ) { // Specifying the fields reduces a lot the RAM used (1:4) . $vrf_fields = "vrf_id, mplsVpnVrfRouteDistinguisher, mplsVpnVrfDescription, vrf_name"; $dev_fields = "D.device_id as device_id, hostname, os, hardware, version, features, location, status, `ignore`, disabled"; - $port_fields = "interface_id, ifvrf, device_id, ifDescr, ifAlias, ifName"; + $port_fields = "port_id, ifvrf, device_id, ifDescr, ifAlias, ifName"; foreach (dbFetchRows("SELECT $vrf_fields, $dev_fields FROM `vrfs` AS V, `devices` AS D WHERE D.device_id = V.device_id") as $vrf_device) { diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 38b64e504..29649df74 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -9,7 +9,7 @@ '); -$query = "SELECT * FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D WHERE M.interface_id = P.interface_id AND P.device_id = D.device_id "; +$query = "SELECT * FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D WHERE M.port_id = P.port_id AND P.device_id = D.device_id "; if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { $query .= " AND `ipv4_address` LIKE ?"; @@ -71,11 +71,11 @@ foreach (dbFetchRows($query, $param) as $entry) $error_img = generate_port_link($entry,"Interface Errors",errors); } else { $error_img = ""; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } if ($arp_host['device_id'] == $entry['device_id']) { $arp_name = "Localhost"; } - if ($arp_host['interface_id'] == $entry['interface_id']) { $arp_if = "Local port"; } + if ($arp_host['port_id'] == $entry['port_id']) { $arp_if = "Local port"; } echo('
    diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index e8db87fda..ff9cdd87d 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -39,7 +39,7 @@ print_optionbar_end(); echo('
    '); -$query = "SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D, `ipv4_networks` AS N WHERE I.interface_id = A.interface_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id "; +$query = "SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D, `ipv4_networks` AS N WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id "; if (is_numeric($_POST['device_id'])) { @@ -76,7 +76,7 @@ foreach (dbFetchRows($query, $param) as $interface) $error_img = generate_port_link($interface,"Interface Errors",errors); } else { $error_img = ""; } - if (port_permitted($interface['interface_id'])) + if (port_permitted($interface['port_id'])) { $interface = ifLabel ($interface, $interface); diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 60ec16c4d..1c58dec9e 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -39,7 +39,7 @@ print_optionbar_end(); echo('
    '); -$query = "SELECT * FROM `ipv6_addresses` AS A, `ports` AS I, `devices` AS D, `ipv6_networks` AS N WHERE I.interface_id = A.interface_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id "; +$query = "SELECT * FROM `ipv6_addresses` AS A, `ports` AS I, `devices` AS D, `ipv6_networks` AS N WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id "; if (is_numeric($_POST['device_id'])) { @@ -76,7 +76,7 @@ foreach (dbFetchRows($query, $param) as $interface) $error_img = generate_port_link($interface,"Interface Errors",errors); } else { $error_img = ""; } - if (port_permitted($interface['interface_id'])) + if (port_permitted($interface['port_id'])) { $interface = ifLabel ($interface, $interface); diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index 367186e03..0b696c221 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -68,7 +68,7 @@ foreach (dbFetchRows($query, $param) as $entry) $error_img = generate_port_link($entry,"Interface Errors",errors); } else { $error_img = ""; } - if (port_permitted($entry['interface_id'])) + if (port_permitted($entry['port_id'])) { $interface = ifLabel ($interface, $interface); diff --git a/includes/common.php b/includes/common.php index bb039913a..1a049d4c7 100644 --- a/includes/common.php +++ b/includes/common.php @@ -77,17 +77,17 @@ function delete_port($int_id) { global $config; - $interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.interface_id = ? AND D.device_id = P.device_id", array($int_id)); + $interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.port_id = ? AND D.device_id = P.device_id", array($int_id)); $interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports'); foreach ($interface_tables as $table) { - dbDelete($table, "`interface_id` = ?", array($int_id)); + dbDelete($table, "`port_id` = ?", array($int_id)); } - dbDelete('links', "`local_interface_id` = ?", array($int_id)); - dbDelete('links', "`remote_interface_id` = ?", array($int_id)); + dbDelete('links', "`local_port_id` = ?", array($int_id)); + dbDelete('links', "`remote_port_id` = ?", array($int_id)); dbDelete('bill_ports', "`port_id` = ?", array($int_id)); unlink(trim($config['rrd_dir'])."/".trim($interface['hostname'])."/port-".$interface['ifIndex'].".rrd"); @@ -164,23 +164,41 @@ function get_all_devices($device, $type = "") function port_by_id_cache($port_id) { - global $port_cache; + return get_port_by_id_cache('port', $port_id); +} - if (isset($port_cache[$port_id]) && is_array($port_cache[$device_id])) +function table_from_entity_type($type) +{ + /// Fuck you, english pluralisation. + if($type == "storage") { - $port = $port_cache[$port_id]; + return $type; } else { - $port = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($port_id)); - $port_cache[$port_id] = $port; + return $type."s"; } - return $port; +} + +function get_entity_by_id_cache($type, $id) +{ + global $entity_cache; + + $table = table_from_entity_type($type); + + if (is_array($entity_cache[$type][$id])) + { + $entity = $entity_cache[$type][$id]; + } else { + $entity = dbFetchRow("SELECT * FROM `".$table."` WHERE `".$type."_id` = ?", array($port_id)); + $entity_cache[$type][$id] = $entity; + } + return $entity; } function get_port_by_id($port_id) { if (is_numeric($port_id)) { - $port = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($port_id)); + $port = dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($port_id)); } if (is_array($port)) { @@ -218,11 +236,11 @@ function get_sensor_by_id($sensor_id) } } -function get_device_id_by_interface_id($interface_id) +function get_device_id_by_port_id($port_id) { - if (is_numeric($interface_id)) + if (is_numeric($port_id)) { - $device_id = dbFetchCell("SELECT `device_id` FROM `ports` WHERE `interface_id` = ?", array($interface_id)); + $device_id = dbFetchCell("SELECT `device_id` FROM `ports` WHERE `port_id` = ?", array($port_id)); } if (is_numeric($device_id)) { @@ -294,7 +312,7 @@ function mres($string) function getifhost($id) { - return dbFetchCell("SELECT `device_id` from `ports` WHERE `interface_id` = ?", array($id)); + return dbFetchCell("SELECT `device_id` from `ports` WHERE `port_id` = ?", array($id)); } function gethostbyid($id) @@ -337,17 +355,17 @@ function getpeerhost($id) function getifindexbyid($id) { - return dbFetchCell("SELECT `ifIndex` FROM `ports` WHERE `interface_id` = ?", array($id)); + return dbFetchCell("SELECT `ifIndex` FROM `ports` WHERE `port_id` = ?", array($id)); } function getifbyid($id) { - return dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($id)); + return dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($id)); } function getifdescrbyid($id) { - return dbFetchCell("SELECT `ifDescr` FROM `ports` WHERE `interface_id` = ?", array($id)); + return dbFetchCell("SELECT `ifDescr` FROM `ports` WHERE `port_id` = ?", array($id)); } function getidbyname($hostname) diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index 014f0c0d1..82048d7f9 100644 --- a/includes/discovery/arp-table.inc.php +++ b/includes/discovery/arp-table.inc.php @@ -26,18 +26,18 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) $mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f"; $clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f; $mac_table[$if][$mac]['cleanmac'] = $clean_mac; - $interface_id = $interface['interface_id']; - $mac_table[$interface_id][$clean_mac] = 1; + $port_id = $interface['port_id']; + $mac_table[$port_id][$clean_mac] = 1; - if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0)) + if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE port_id = '".$interface['port_id']."' AND ipv4_address = '$ip'"),0)) { - $sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"; - $old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'")); + $sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE port_id = '".$interface['port_id']."' AND ipv4_address = '$ip'"; + $old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND port_id = '".$interface['port_id']."'")); if ($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '') { if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); } - log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']); + log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['port_id']); } mysql_query($sql); echo("."); @@ -46,20 +46,20 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) { echo("+"); #echo("Add MAC $mac\n"); - mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')"); + mysql_query("INSERT INTO `ipv4_mac` (port_id, mac_address, ipv4_address) VALUES ('".$interface['port_id']."','$clean_mac','$ip')"); } } } -$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'"; +$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.port_id = I.port_id and I.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); while ($entry = mysql_fetch_assoc($query)) { $entry_mac = $entry['mac_address']; - $entry_if = $entry['interface_id']; + $entry_if = $entry['port_id']; if (!$mac_table[$entry_if][$entry_mac]) { - mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$entry_mac."'"); + mysql_query("DELETE FROM ipv4_mac WHERE port_id = '".$entry_if."' AND mac_address = '".$entry_mac."'"); if ($debug) { echo("Removing MAC $entry_mac from interface ".$interface['ifName']); } echo("-"); } diff --git a/includes/discovery/cisco-mac-accounting.inc.php b/includes/discovery/cisco-mac-accounting.inc.php index dd4a13d19..4298d6a2e 100755 --- a/includes/discovery/cisco-mac-accounting.inc.php +++ b/includes/discovery/cisco-mac-accounting.inc.php @@ -28,15 +28,15 @@ if ($device['os_group'] == "cisco") if ($ip && $interface) { $new_mac = str_replace(":", "", $mac); #echo($interface['ifDescr'] . " ($if) -> $mac ($oid) -> $ip"); - if (mysql_result(mysql_query("SELECT COUNT(*) from mac_accounting WHERE interface_id = '".$interface['interface_id']."' AND mac = '$clean_mac'"),0)) { - #$sql = "UPDATE `mac_accounting` SET `mac` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND `mac` = '$clean_mac'"; + if (mysql_result(mysql_query("SELECT COUNT(*) from mac_accounting WHERE port_id = '".$interface['port_id']."' AND mac = '$clean_mac'"),0)) { + #$sql = "UPDATE `mac_accounting` SET `mac` = '$clean_mac' WHERE port_id = '".$interface['port_id']."' AND `mac` = '$clean_mac'"; #mysql_query($sql); #if (mysql_affected_rows()) { echo(" UPDATED!"); } #echo($sql); echo("."); } else { #echo(" Not Exists!"); - mysql_query("INSERT INTO `mac_accounting` (interface_id, mac) VALUES ('".$interface['interface_id']."','$clean_mac')"); + mysql_query("INSERT INTO `mac_accounting` (port_id, mac) VALUES ('".$interface['port_id']."','$clean_mac')"); echo("+"); } #echo("\n"); diff --git a/includes/discovery/cisco-pw.inc.php b/includes/discovery/cisco-pw.inc.php index 72f9f2381..07cce92ab 100755 --- a/includes/discovery/cisco-pw.inc.php +++ b/includes/discovery/cisco-pw.inc.php @@ -27,8 +27,8 @@ if ($config['enable_pseudowires'] && $device['os_group'] == "cisco") foreach ($pws as $pw_id => $pw) { list($cpw_remote_id) = explode(":", $pw['cpwVcMplsPeerLdpID']); - $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0); - $if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '".$pw['cpwVcName']."' AND `device_id` = '".$device['device_id']."'"),0); + $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.port_id = I.port_id"),0); + $if_id = @mysql_result(mysql_query("SELECT `port_id` FROM `ports` WHERE `ifDescr` = '".$pw['cpwVcName']."' AND `device_id` = '".$device['device_id']."'"),0); if (!empty($device['pws_db'][$pw['cpwVcID']])) { @@ -37,7 +37,7 @@ if ($config['enable_pseudowires'] && $device['os_group'] == "cisco") } else { - $pseudowire_id = dbInsert(array('device_id' => $device['device_id'], 'interface_id' => $if_id, 'peer_device_id' => $cpw_remote_device, 'peer_ldp_id' => $cpw_remote_id, + $pseudowire_id = dbInsert(array('device_id' => $device['device_id'], 'port_id' => $if_id, 'peer_device_id' => $cpw_remote_device, 'peer_ldp_id' => $cpw_remote_id, 'cpwVcID' => $pw['cpwVcID'], 'cpwOid' => $pw_id, 'pw_type' => $pw['cpwVcType'], 'pw_descr' => $pw['cpwVcDescr'], 'pw_psntype' => $pw['cpwVcPsnType']), 'pseudowires'); echo("+"); } diff --git a/includes/discovery/cisco-vrf.inc.php b/includes/discovery/cisco-vrf.inc.php index 36113c491..f4e191ba8 100755 --- a/includes/discovery/cisco-vrf.inc.php +++ b/includes/discovery/cisco-vrf.inc.php @@ -112,8 +112,8 @@ if ($config['enable_vrfs']) { $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE ifIndex = '$if_id' AND device_id = '" . $device['device_id'] . "'")); echo(makeshortif($interface['ifDescr']) . " "); - mysql_query("UPDATE ports SET ifVrf = '$vrf_id' WHERE interface_id = '".$interface['interface_id']."'"); - $if = $interface['interface_id']; + mysql_query("UPDATE ports SET ifVrf = '$vrf_id' WHERE port_id = '".$interface['port_id']."'"); + $if = $interface['port_id']; $valid_vrf_if[$vrf_id][$if] = 1; } } @@ -125,14 +125,14 @@ if ($config['enable_vrfs']) $data = mysql_query($sql); while ($row = mysql_fetch_assoc($data)) { - $if = $row['interface_id']; + $if = $row['port_id']; $vrf_id = $row['ifVrf']; if ($row['ifVrf']) { if (!$valid_vrf_if[$vrf_id][$if]) { echo("-"); - $query = @mysql_query("UPDATE ports SET `ifVrf` = NULL WHERE interface_id = '$if'"); + $query = @mysql_query("UPDATE ports SET `ifVrf` = NULL WHERE port_id = '$if'"); } else { diff --git a/includes/discovery/discovery-protocols.inc.php b/includes/discovery/discovery-protocols.inc.php index 870e98c09..194eb15d7 100755 --- a/includes/discovery/discovery-protocols.inc.php +++ b/includes/discovery/discovery-protocols.inc.php @@ -28,17 +28,17 @@ if ($device['os'] == "ironware") if ($remote_device_id) { $int = ifNameDescr($interface); - log_event("Device autodiscovered through FDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['interface_id']); + log_event("Device autodiscovered through FDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['port_id']); } } if ($remote_device_id) { $if = $fdp['snFdpCacheDevicePort']; - $remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0); - } else { $remote_interface_id = "0"; } + $remote_port_id = @mysql_result(mysql_query("SELECT port_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0); + } else { $remote_port_id = "0"; } - discover_link($interface['interface_id'], $fdp['snFdpCacheVendorId'], $remote_interface_id, $fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDevicePort'], $fdp['snFdpCachePlatform'], $fdp['snFdpCacheVersion']); + discover_link($interface['port_id'], $fdp['snFdpCacheVendorId'], $remote_port_id, $fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDevicePort'], $fdp['snFdpCachePlatform'], $fdp['snFdpCacheVersion']); } } } @@ -67,19 +67,19 @@ if ($cdp_array) if ($remote_device_id) { $int = ifNameDescr($interface); - log_event("Device autodiscovered through CDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['interface_id']); + log_event("Device autodiscovered through CDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['port_id']); } } if ($remote_device_id) { $if = $cdp['cdpCacheDevicePort']; - $remote_interface_id = dbFetchCell("SELECT interface_id FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ?) AND `device_id` = ?", array($if, $if, $remote_device_id)); - } else { $remote_interface_id = "0"; } + $remote_port_id = dbFetchCell("SELECT port_id FROM `ports` WHERE (`ifDescr` = ? OR `ifName` = ?) AND `device_id` = ?", array($if, $if, $remote_device_id)); + } else { $remote_port_id = "0"; } - if ($interface['interface_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) + if ($interface['port_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) { - discover_link($interface['interface_id'], 'cdp', $remote_interface_id, $cdp['cdpCacheDeviceId'], $cdp['cdpCacheDevicePort'], $cdp['cdpCachePlatform'], $cdp['cdpCacheVersion']); + discover_link($interface['port_id'], 'cdp', $remote_port_id, $cdp['cdpCacheDeviceId'], $cdp['cdpCacheDevicePort'], $cdp['cdpCachePlatform'], $cdp['cdpCacheVersion']); } } else @@ -123,21 +123,21 @@ if ($lldp_array) if ($remote_device_id) { $int = ifNameDescr($interface); - log_event("Device autodiscovered through LLDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['interface_id']); + log_event("Device autodiscovered through LLDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['port_id']); } } if ($remote_device_id) { $if = $lldp['lldpRemPortDesc']; $id = $lldp['lldpRemPortId']; - $remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if' OR `ifDescr`= '$id' OR `ifName`='$id') AND `device_id` = '".$remote_device_id."'"),0); + $remote_port_id = @mysql_result(mysql_query("SELECT port_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if' OR `ifDescr`= '$id' OR `ifName`='$id') AND `device_id` = '".$remote_device_id."'"),0); } else { - $remote_interface_id = "0"; + $remote_port_id = "0"; } - if (is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId'])) + if (is_numeric($interface['port_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId'])) { - discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortId'], NULL, $lldp['lldpRemSysDesc']); + discover_link($interface['port_id'], 'lldp', $remote_port_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortId'], NULL, $lldp['lldpRemSysDesc']); } } } @@ -146,16 +146,16 @@ if ($lldp_array) if ($debug) { print_r($link_exists); } -$sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'"; +$sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_port_id = I.port_id AND I.device_id = '".$device['device_id']."'"; if ($query = mysql_query($sql)) { while ($test = mysql_fetch_assoc($query)) { - $local_interface_id = $test['local_interface_id']; + $local_port_id = $test['local_port_id']; $remote_hostname = $test['remote_hostname']; $remote_port = $test['remote_port']; - if ($debug) { echo("$local_interface_id -> $remote_hostname -> $remote_port \n"); } - if (!$link_exists[$local_interface_id][$remote_hostname][$remote_port]) + if ($debug) { echo("$local_port_id -> $remote_hostname -> $remote_port \n"); } + if (!$link_exists[$local_port_id][$remote_hostname][$remote_port]) { echo("-"); mysql_query("DELETE FROM `links` WHERE id = '" . $test['id'] . "'"); diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 7c07c4359..e176d864f 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -336,51 +336,51 @@ function check_valid_sensors($device, $class, $valid) } } -function discover_juniAtmVp(&$valid, $interface_id, $vp_id, $vp_descr) +function discover_juniAtmVp(&$valid, $port_id, $vp_id, $vp_descr) { global $config, $debug; - if (dbFetchCell("SELECT COUNT(*) FROM `juniAtmVp` WHERE `interface_id` = ? AND `vp_id` = ?", array($interface_id, $vp_id)) == "0") + if (dbFetchCell("SELECT COUNT(*) FROM `juniAtmVp` WHERE `port_id` = ? AND `vp_id` = ?", array($port_id, $vp_id)) == "0") { - $inserted = dbInsert(array('interface_id' => $interface_id,'vp_id' => $vp_id,'vp_descr' => $vp_descr), 'juniAtmVp'); + $inserted = dbInsert(array('port_id' => $port_id,'vp_id' => $vp_id,'vp_descr' => $vp_descr), 'juniAtmVp'); if ($debug) { echo("( $inserted inserted )\n"); } #FIXME vv no $device! - log_event("Juniper ATM VP Added: port ".mres($interface_id)." vp ".mres($vp_id)." descr". mres($vp_descr), 'juniAtmVp', mysql_insert_id()); + log_event("Juniper ATM VP Added: port ".mres($port_id)." vp ".mres($vp_id)." descr". mres($vp_descr), 'juniAtmVp', mysql_insert_id()); } else { echo("."); } - $valid[$interface_id][$vp_id] = 1; + $valid[$port_id][$vp_id] = 1; } -function discover_link($local_interface_id, $protocol, $remote_interface_id, $remote_hostname, $remote_port, $remote_platform, $remote_version) +function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostname, $remote_port, $remote_platform, $remote_version) { global $config, $debug, $link_exists; - if (dbFetchCell("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = ? AND `local_interface_id` = ? AND `protocol` = ? AND `remote_port` = ?", - array($remote_hostname, $local_interface_id, $protocol, $remote_port)) == "0") + if (dbFetchCell("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = ? AND `local_port_id` = ? AND `protocol` = ? AND `remote_port` = ?", + array($remote_hostname, $local_port_id, $protocol, $remote_port)) == "0") { - $inserted = dbInsert(array('local_interface_id' => $local_interface_id,'protocol' => $protocol,'remote_interface_id' => $remote_interface_id,'remote_hostname' => $remote_hostname, + $inserted = dbInsert(array('local_port_id' => $local_port_id,'protocol' => $protocol,'remote_port_id' => $remote_port_id,'remote_hostname' => $remote_hostname, 'remote_port' => $remote_port,'remote_platform' => $remote_platform,'remote_version' => $remote_version), 'links'); echo("+"); if ($debug) { echo("( $inserted inserted )"); } } else { - $data = dbFetchRow("SELECT * FROM `links` WHERE `remote_hostname` = ? AND `local_interface_id` = ? AND `protocol` = ? AND `remote_port` = ?", array($remote_hostname, $local_interface_id, $protocol, $remote_port)); - if ($data['remote_interface_id'] == $remote_interface_id && $data['remote_platform'] == $remote_platform && $remote_version == $remote_version) + $data = dbFetchRow("SELECT * FROM `links` WHERE `remote_hostname` = ? AND `local_port_id` = ? AND `protocol` = ? AND `remote_port` = ?", array($remote_hostname, $local_port_id, $protocol, $remote_port)); + if ($data['remote_port_id'] == $remote_port_id && $data['remote_platform'] == $remote_platform && $remote_version == $remote_version) { echo("."); } else { - $updated = dbUpdate(array('remote_interface_id' => $remote_interface_id, 'remote_platform' => $remote_platform, 'remote_version' => $remote_version), 'links', '`id` = ?', array($data['id'])); + $updated = dbUpdate(array('remote_port_id' => $remote_port_id, 'remote_platform' => $remote_platform, 'remote_version' => $remote_version), 'links', '`id` = ?', array($data['id'])); echo("U"); if ($debug) { echo("( $updated updated )"); } } } - $link_exists[$local_interface_id][$remote_hostname][$remote_port] = 1; + $link_exists[$local_port_id][$remote_hostname][$remote_port] = 1; } function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size, $units, $used = NULL) @@ -511,8 +511,8 @@ function discover_process_ipv6(&$valid, $ifIndex,$ipv6_address,$ipv6_prefixlen,$ if (mysql_result(mysql_query("SELECT count(*) FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $ipv6_prefixlen > '0' && $ipv6_prefixlen < '129' && $ipv6_compressed != '::1') { - $i_query = "SELECT interface_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"; - $interface_id = mysql_result(mysql_query($i_query), 0); + $i_query = "SELECT port_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"; + $port_id = mysql_result(mysql_query($i_query), 0); if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv6_networks` WHERE `ipv6_network` = '$ipv6_network'"), 0) < '1') { mysql_query("INSERT INTO `ipv6_networks` (`ipv6_network`) VALUES ('$ipv6_network')"); @@ -527,10 +527,10 @@ function discover_process_ipv6(&$valid, $ifIndex,$ipv6_address,$ipv6_prefixlen,$ $ipv6_network_id = @mysql_result(mysql_query("SELECT `ipv6_network_id` from `ipv6_networks` WHERE `ipv6_network` = '$ipv6_network'"), 0); - if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv6_addresses` WHERE `ipv6_address` = '$ipv6_address' AND `ipv6_prefixlen` = '$ipv6_prefixlen' AND `interface_id` = '$interface_id'"), 0) == '0') + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv6_addresses` WHERE `ipv6_address` = '$ipv6_address' AND `ipv6_prefixlen` = '$ipv6_prefixlen' AND `port_id` = '$port_id'"), 0) == '0') { - mysql_query("INSERT INTO `ipv6_addresses` (`ipv6_address`, `ipv6_compressed`, `ipv6_prefixlen`, `ipv6_origin`, `ipv6_network_id`, `interface_id`) - VALUES ('$ipv6_address', '$ipv6_compressed', '$ipv6_prefixlen', '$ipv6_origin', '$ipv6_network_id', '$interface_id')"); + mysql_query("INSERT INTO `ipv6_addresses` (`ipv6_address`, `ipv6_compressed`, `ipv6_prefixlen`, `ipv6_origin`, `ipv6_network_id`, `port_id`) + VALUES ('$ipv6_address', '$ipv6_compressed', '$ipv6_prefixlen', '$ipv6_origin', '$ipv6_network_id', '$port_id')"); echo("+"); } else @@ -538,7 +538,7 @@ function discover_process_ipv6(&$valid, $ifIndex,$ipv6_address,$ipv6_prefixlen,$ echo("."); } $full_address = "$ipv6_address/$ipv6_prefixlen"; - $valid_address = $full_address . "-" . $interface_id; + $valid_address = $full_address . "-" . $port_id; $valid['ipv6'][$valid_address] = 1; } } diff --git a/includes/discovery/ipv4-addresses.inc.php b/includes/discovery/ipv4-addresses.inc.php index 887b082cc..5f66b350a 100755 --- a/includes/discovery/ipv4-addresses.inc.php +++ b/includes/discovery/ipv4-addresses.inc.php @@ -15,8 +15,8 @@ foreach (explode("\n", $oids) as $data) if (mysql_result(mysql_query("SELECT count(*) FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $oid != "0.0.0.0" && $oid != 'ipAdEntIfIndex') { - $i_query = "SELECT interface_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"; - $interface_id = mysql_result(mysql_query($i_query), 0); + $i_query = "SELECT port_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"; + $port_id = mysql_result(mysql_query($i_query), 0); if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv4_networks` WHERE `ipv4_network` = '$network'"), 0) < '1') { @@ -27,10 +27,10 @@ foreach (explode("\n", $oids) as $data) $ipv4_network_id = @mysql_result(mysql_query("SELECT `ipv4_network_id` from `ipv4_networks` WHERE `ipv4_network` = '$network'"), 0); - if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_address` = '$oid' AND `ipv4_prefixlen` = '$cidr' AND `interface_id` = '$interface_id'"), 0) == '0') + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_address` = '$oid' AND `ipv4_prefixlen` = '$cidr' AND `port_id` = '$port_id'"), 0) == '0') { - mysql_query("INSERT INTO `ipv4_addresses` (`ipv4_address`, `ipv4_prefixlen`, `ipv4_network_id`, `interface_id`) VALUES ('$oid', '$cidr', '$ipv4_network_id', '$interface_id')"); - #echo("Added $oid/$cidr to $interface_id ( $hostname $ifIndex )\n $i_query\n"); + mysql_query("INSERT INTO `ipv4_addresses` (`ipv4_address`, `ipv4_prefixlen`, `ipv4_network_id`, `port_id`) VALUES ('$oid', '$cidr', '$ipv4_network_id', '$port_id')"); + #echo("Added $oid/$cidr to $port_id ( $hostname $ifIndex )\n $i_query\n"); echo("+"); } else { echo("."); } @@ -39,7 +39,7 @@ foreach (explode("\n", $oids) as $data) } else { echo("!"); } } -$sql = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.interface_id = I.interface_id"; +$sql = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.port_id = I.port_id"; $data = mysql_query($sql); while ($row = mysql_fetch_assoc($data)) diff --git a/includes/discovery/ipv6-addresses.inc.php b/includes/discovery/ipv6-addresses.inc.php index df59c6a73..21af273de 100644 --- a/includes/discovery/ipv6-addresses.inc.php +++ b/includes/discovery/ipv6-addresses.inc.php @@ -58,14 +58,14 @@ if (!$oids) } // foreach } // if $oids -$sql = "SELECT * FROM ipv6_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.interface_id = I.interface_id"; +$sql = "SELECT * FROM ipv6_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.port_id = I.port_id"; $data = mysql_query($sql); while ($row = mysql_fetch_assoc($data)) { $full_address = $row['ipv6_address'] . "/" . $row['ipv6_prefixlen']; - $interface_id = $row['interface_id']; - $valid_address = $full_address . "-" . $interface_id; + $port_id = $row['port_id']; + $valid_address = $full_address . "-" . $port_id; if (!$valid['ipv6'][$valid_address]) { echo("-"); diff --git a/includes/discovery/junose-atm-vp.inc.php b/includes/discovery/junose-atm-vp.inc.php index 3d11e2efe..e6fd07277 100755 --- a/includes/discovery/junose-atm-vp.inc.php +++ b/includes/discovery/junose-atm-vp.inc.php @@ -17,11 +17,11 @@ if ($device['os'] == "junose" && $config['enable_ports_junoseatmvp']) { list($ifIndex,$vp_id)= explode('.', $index); - $interface_id = mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'"),0); + $port_id = mysql_result(mysql_query("SELECT `port_id` FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'"),0); - if (is_numeric($interface_id) && is_numeric($vp_id)) + if (is_numeric($port_id) && is_numeric($vp_id)) { - discover_juniAtmvp($valid_vp, $interface_id, $vp_id, NULL); + discover_juniAtmvp($valid_vp, $port_id, $vp_id, NULL); } } ## End Foreach } ## End if array @@ -30,23 +30,23 @@ if ($device['os'] == "junose" && $config['enable_ports_junoseatmvp']) ## Remove ATM vps which weren't redetected here - $sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.interface_id = P.interface_id"; + $sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.port_id = P.port_id"; $query = mysql_query($sql); if ($debug) { print_r ($valid_vp); } while ($test = mysql_fetch_assoc($query)) { - $interface_id = $test['interface_id']; + $port_id = $test['port_id']; $vp_id = $test['vp_id']; - if ($debug) { echo($interface_id . " -> " . $vp_id . "\n"); } - if (!$valid_vp[$interface_id][$vp_id]) + if ($debug) { echo($port_id . " -> " . $vp_id . "\n"); } + if (!$valid_vp[$port_id][$vp_id]) { echo("-"); mysql_query("DELETE FROM `juniAtmvp` WHERE `juniAtmVp` = '" . $test['juniAtmvp'] . "'"); } - unset($interface_id); unset($vp_id); + unset($port_id); unset($vp_id); } unset($valid_vp); diff --git a/includes/discovery/ports-stack.inc.php b/includes/discovery/ports-stack.inc.php index dd5323943..572c63ec6 100644 --- a/includes/discovery/ports-stack.inc.php +++ b/includes/discovery/ports-stack.inc.php @@ -6,41 +6,41 @@ $sql = "SELECT * FROM `ports_stack` WHERE `device_id` = '".$device['device_id']. $query = mysql_query($sql); while ($entry = mysql_fetch_assoc($query)) { - $stack_db_array[$entry['interface_id_high']][$entry['interface_id_low']]['ifStackStatus'] = $entry['ifStackStatus']; + $stack_db_array[$entry['port_id_high']][$entry['port_id_low']]['ifStackStatus'] = $entry['ifStackStatus']; } $stack_poll_array = snmpwalk_cache_twopart_oid($device, "ifStackStatus", array()); -foreach ($stack_poll_array as $interface_id_high => $entry_high) +foreach ($stack_poll_array as $port_id_high => $entry_high) { - foreach ($entry_high as $interface_id_low => $entry_low) + foreach ($entry_high as $port_id_low => $entry_low) { $ifStackStatus = $entry_low['ifStackStatus']; - if (isset($stack_db_array[$interface_id_high][$interface_id_low])) + if (isset($stack_db_array[$port_id_high][$port_id_low])) { - if ($stack_db_array[$interface_id_high][$interface_id_low]['ifStackStatus'] == $ifStackStatus) + if ($stack_db_array[$port_id_high][$port_id_low]['ifStackStatus'] == $ifStackStatus) { echo("."); } else { - mysql_query("UPDATE `ports_stack` SET `ifStackStatus` = '".$ifStackStatus."' WHERE `device_id` = '".$device['device_id']."' AND `interface_id_high` = '".$interface_id_high."' AND `interface_id_low` = '".$interface_id_low."'"); + mysql_query("UPDATE `ports_stack` SET `ifStackStatus` = '".$ifStackStatus."' WHERE `device_id` = '".$device['device_id']."' AND `port_id_high` = '".$port_id_high."' AND `port_id_low` = '".$port_id_low."'"); echo("U"); if ($debug) { echo(mysql_error()); } } - unset($stack_db_array[$interface_id_high][$interface_id_low]); + unset($stack_db_array[$port_id_high][$port_id_low]); } else { - mysql_query("INSERT INTO `ports_stack` (`device_id`,`interface_id_high`,`interface_id_low`,`ifStackStatus`) VALUES ('".$device['device_id']."','".$interface_id_high."','".$interface_id_low."','".$ifStackStatus."')"); + mysql_query("INSERT INTO `ports_stack` (`device_id`,`port_id_high`,`port_id_low`,`ifStackStatus`) VALUES ('".$device['device_id']."','".$port_id_high."','".$port_id_low."','".$ifStackStatus."')"); echo("+"); if ($debug) { echo(mysql_error()); } } } } -foreach ($stack_db_array AS $interface_id_high => $array) +foreach ($stack_db_array AS $port_id_high => $array) { - foreach ($array AS $interface_id_low => $blah) + foreach ($array AS $port_id_low => $blah) { - echo($device['device_id']." ".$interface_id_low." ".$interface_id_high. "\n"); - dbDelete('ports_stack', "`device_id` = ? AND interface_id_high = ? AND interface_id_low = ?", array($device['device_id'], $interface_id_high, $interface_id_low)); + echo($device['device_id']." ".$port_id_low." ".$port_id_high. "\n"); + dbDelete('ports_stack', "`device_id` = ? AND port_id_high = ? AND port_id_low = ?", array($device['device_id'], $port_id_high, $port_id_low)); echo("-"); } } diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index d86b4385a..c940194dc 100755 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -1,118 +1,11 @@ "0") -{ - echo("ADSL "); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.1.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.2.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.3.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.4.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.5.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.2", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.3", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.4", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.5", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.6", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.7", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.8", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.1", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.2", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.3", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.4", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.5", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.6", $port_stats, "ADSL-LINE-MIB"); - $port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.7", $port_stats, "ADSL-LINE-MIB"); -} - -/// FIXME This probably needs re-enabled. We need to clear these things when they get unset, too. -#foreach ($etherlike_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "EtherLike-MIB"); } -#foreach ($cisco_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "OLD-CISCO-INTERFACES-MIB"); } -#foreach ($pagp_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "CISCO-PAGP-MIB"); } - -if ($device['os_group'] == "cisco") -{ - $port_stats = snmp_cache_portIfIndex ($device, $port_stats); - $port_stats = snmp_cache_portName ($device, $port_stats); - foreach ($pagp_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "CISCO-PAGP-MIB"); } - $data_oids[] = "portName"; - - /// Grab data to put ports into vlans or make them trunks - /// FIXME we probably shouldn't be doing this from the VTP MIB, right? - $port_stats = snmpwalk_cache_oid($device, "vmVlan", $port_stats, "CISCO-VLAN-MEMBERSHIP-MIB"); - $port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $port_stats, "CISCO-VTP-MIB"); - $port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $port_stats, "CISCO-VTP-MIB"); - -} else { - $port_stats = snmpwalk_cache_oid($device, "dot1qPortVlanTable", $port_stats, "Q-BRIDGE-MIB"); - - $vlan_ports = snmpwalk_cache_twopart_oid($device, "dot1qVlanCurrentEgressPorts", $vlan_stats, "Q-BRIDGE-MIB"); - $vlan_ifindex_map = snmpwalk_cache_oid($device, "dot1dBasePortIfIndex", $vlan_stats, "Q-BRIDGE-MIB"); - - foreach ($vlan_ports as $instance) - { - foreach (array_keys($instance) as $vlan_id) - { - $parts = explode(' ',$instance[$vlan_id]['dot1qVlanCurrentEgressPorts']); - $binary = ''; - foreach ($parts as $part) - { - $binary .= zeropad(decbin($part),8); - } - for ($i = 0; $i < strlen($binary); $i++) - { - if ($binary[$i]) - { - $ifindex = $i; // FIXME $vlan_ifindex_map[$i] - $q_bridge_mib[$ifindex][] = $vlan_id; - } - } - } - } -} - -$polled = time(); +$port_stats = array(); +$port_stats = snmpwalk_cache_oid($device, "ifDescr", $port_stats, "IF-MIB"); +$port_stats = snmpwalk_cache_oid($device, "ifName", $port_stats, "IF-MIB"); +$port_stats = snmpwalk_cache_oid($device, "ifType", $port_stats, "IF-MIB"); /// End Building SNMP Cache Array @@ -127,7 +20,7 @@ if ($debug) { print_r($port_stats); } foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($device['device_id'])) as $port) { $ports_db[$port['ifIndex']] = $port; - $ports_db_l[$port['ifIndex']] = $port['interface_id']; + $ports_db_l[$port['ifIndex']] = $port['port_id']; } /// New interface detection @@ -138,11 +31,11 @@ foreach ($port_stats as $ifIndex => $port) { if (!is_array($ports_db[$ifIndex])) { - $interface_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); + $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); $ports_db[$ifIndex] = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex)); - echo("Adding: ".$port['ifName']."(".$ifIndex.")(".$ports_db[$port['ifIndex']]['interface_id'].")"); + echo("Adding: ".$port['ifName']."(".$ifIndex.")(".$ports_db[$port['ifIndex']]['port_id'].")"); } elseif ($ports_db[$ifIndex]['deleted'] == "1") { - dbUpdate(array('deleted' => '0'), 'ports', '`interface_id` = ?', array($ports_db[$ifIndex]['interface_id'])); + dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports_db[$ifIndex]['port_id'])); $ports_db[$ifIndex]['deleted'] = "0"; echo("U"); } else { @@ -154,7 +47,7 @@ foreach ($port_stats as $ifIndex => $port) if (is_array($ports_db[$port['ifIndex']])) { if ($ports_db[$port['ifIndex']]['deleted'] != "1") { - dbUpdate(array('deleted' => '1'), 'ports', '`interface_id` = ?', array($ports_db[$ifIndex]['interface_id'])); + dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($ports_db[$ifIndex]['port_id'])); $ports_db[$ifIndex]['deleted'] = "1"; echo("-"); } @@ -170,313 +63,16 @@ foreach ($ports_l as $ifIndex => $port_id) { if ($ports_db[$ifIndex]['deleted'] == "0") { - dbUpdate(array('deleted' => '1'), 'ports', '`interface_id` = ?', array($port_id)); + dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($port_id)); echo("-".$ifIndex); } } /// End interface deletion - echo("\n"); -/// Loop ports in the DB and update where necessary -foreach ($ports_db as $port) -{ - echo("Port " . $port['ifDescr'] . "(".$port['ifIndex'].") "); - if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1") - { /// Check to make sure Port data is cached. - $this_port = &$port_stats[$port['ifIndex']]; - - if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1]; } - - if ($config['memcached']['enable']) - { - $port['poll_time'] = $memcache->get('port-'.$port['interface_id'].'-poll_time'); -# echo("time".$port['poll_time']); - } - - $polled_period = $polled - $port['poll_time']; - - $port['update'] = array(); - if ($config['slow_statistics'] == TRUE) - { - $port['update']['poll_time'] = $polled; - $port['update']['poll_prev'] = $port['poll_time']; - $port['update']['poll_period'] = $polled_period; - } - - if ($config['memcached']['enable']) - { - $memcache->set('port-'.$port['interface_id'].'-poll_time', $polled); - $memcache->set('port-'.$port['interface_id'].'-poll_prev', $port['poll_time']); - $memcache->set('port-'.$port['interface_id'].'-poll_period', $polled_period); - } - - /// Copy ifHC[In|Out]Octets values to non-HC if they exist - if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets'])) - { - echo("HC "); - $this_port['ifInOctets'] = $this_port['ifHCInOctets']; - $this_port['ifOutOctets'] = $this_port['ifHCOutOctets']; - } - - /// rewrite the ifPhysAddress - if (strpos($this_port['ifPhysAddress'], ":")) - { - list($a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(":", $this_port['ifPhysAddress']); - $this_port['ifPhysAddress'] = zeropad($a_a).zeropad($a_b).zeropad($a_c).zeropad($a_d).zeropad($a_e).zeropad($a_f); - } - - if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts'])) - { - echo("HC "); - $this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts']; - $this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts']; - $this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts']; - $this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts']; - } - - /// Overwrite ifSpeed with ifHighSpeed if it's over 10G - if (is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000") - { - echo("HighSpeed "); - $this_port['ifSpeed'] = $this_port['ifHighSpeed'] * 1000000; - } - - /// Overwrite ifDuplex with dot3StatsDuplexStatus if it exists - if (isset($this_port['dot3StatsDuplexStatus'])) - { - echo("dot3Duplex "); - $this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus']; - } - - /// Set VLAN and Trunk from Cisco - if (isset($this_port['vlanTrunkPortEncapsulationOperType']) && $this_port['vlanTrunkPortEncapsulationOperType'] != "notApplicable") - { - $this_port['ifTrunk'] = $this_port['vlanTrunkPortEncapsulationOperType']; - if (isset($this_port['vlanTrunkPortNativeVlan'])) { $this_port['ifVlan'] = $this_port['vlanTrunkPortNativeVlan']; } - } - - if (isset($this_port['vmVlan'])) - { - $this_port['ifVlan'] = $this_port['vmVlan']; - } - - /// Set VLAN and Trunk from Q-BRIDGE-MIB - if (!isset($this_port['ifVlan']) && isset($this_port['dot1qPvid'])) - { - $this_port['ifVlan'] = $this_port['dot1qPvid']; - } - # FIXME use $q_bridge_mib[$this_port['ifIndex'] to see if it is a trunk (>1 array count) - - echo("VLAN == ".$this_port['ifVlan']); - - /// Update IF-MIB data - foreach ($data_oids as $oid) - { - if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) - { - $port['update'][$oid] = NULL; - log_event($oid . ": ".$port[$oid]." -> NULL", $device, 'interface', $port['interface_id']); - if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); } - } elseif ($port[$oid] != $this_port[$oid]) { - $port['update'][$oid] = $this_port[$oid]; - log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device, 'interface', $port['interface_id']); - if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); } - } - } - - /// Parse description (usually ifAlias) if config option set - if (isset($config['port_descr_parser']) && is_file($config['install_dir'] . "/" . $config['port_descr_parser'])) - { - $port_attribs = array('type','descr','circuit','speed','notes'); - - include($config['install_dir'] . "/" . $config['port_descr_parser']); - - foreach ($port_attribs as $attrib) - { - $attrib_key = "port_descr_".$attrib; - if ($port_ifAlias[$attrib] != $port[$attrib_key]) - { - $port['update'][$attrib_key] = $port_ifAlias[$attrib]; - log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device, 'interface', $port['interface_id']); - } - } - } - /// End parse ifAlias - - /// Update IF-MIB metrics - foreach ($stat_oids_db as $oid) - { -# echo("\n".$oid.":"); - - if ($config['slow_statistics'] == TRUE) { - $port['update'][$oid] = $this_port[$oid]; - $port['update'][$oid.'_prev'] = $port[$oid]; - } - - if ($config['memcached']['enable']) - { - $port[$oid] = $memcache->get('port-'.$port['interface_id'].'-'.$oid); - $memcache->set('port-'.$port['interface_id'].'-'.$oid, $this_port[$oid]); - $memcache->set('port-'.$port['interface_id'].'-'.$oid.'_prev', $port[$oid]); -# echo("MEMCACHE!"); - } - -# echo(" old[".$port[$oid]."]"); -# echo(" new[".$this_port[$oid]."]"); - - $oid_prev = $oid . "_prev"; - if (isset($port[$oid])) - { - $oid_diff = $this_port[$oid] - $port[$oid]; -# echo(" diff[".$oid_diff."]"); - $oid_rate = $oid_diff / $polled_period; -# echo(" rate[".$oid_rate."]"); - if ($oid_rate < 0) { $oid_rate = "0"; echo("negative $oid"); } - $port['stats'][$oid.'_rate'] = $oid_rate; - $port['stats'][$oid.'_diff'] = $oid_diff; - - if ($config['slow_statistics'] == TRUE) { - $port['update'][$oid.'_rate'] = $oid_rate; - $port['update'][$oid.'_delta'] = $oid_diff; - } - - if ($config['memcached']['enable']) - { - $memcache->set('port-'.$port['interface_id'].'-'.$oid.'_rate', $oid_rate); - $memcache->set('port-'.$port['interface_id'].'-'.$oid.'_delta', $oid_diff); -# echo($oid."[".$oid_rate."]"); - } - - if ($debug) { echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); } - } - } - - $port['stats']['ifInBits_rate'] = $port['stats']['ifInOctets_rate'] * 8; - $port['stats']['ifOutBits_rate'] = $port['stats']['ifOutOctets_rate'] * 8; - echo('bps('.formatRates($port['stats']['ifInBits_rate']).'/'.formatRates($port['stats']['ifOutBits_rate']).')'); - echo('bytes('.formatStorage($port['stats']['ifInOctets_diff']).'/'.formatStorage($port['stats']['ifOutOctets_diff']).')'); - echo('pkts('.format_si($port['stats']['ifInUcastPkts_rate']).'pps/'.format_si($port['stats']['ifOutUcastPkts_rate']).'pps)'); - - /// Port utilisation % threshold alerting. ## FIXME allow setting threshold per-port. probably 90% of ports we don't care about. - if ($config['alerts']['port_util_alert']) - { - // Check for port saturation of $config['alerts']['port_util_perc'] or higher. Alert if we see this. - // Check both inbound and outbound rates - $saturation_threshold = $this_port['ifSpeed'] * ( $config['alerts']['port_util_perc'] / 100 ); - echo("IN: " . $port['stats']['ifInBits_rate'] . " OUT: " . $port['stats']['ifOutBits_rate'] . " THRESH: " . $saturation_threshold); - if (($port['stats']['ifInBits_rate'] >= $saturation_threshold || $port['stats']['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) - { - log_event('Port reached saturation threshold: ' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['stats']['ifSpeed']) , $device, 'interface', $port['interface_id']); - notify($device, 'Port saturation threshold reached on ' . $device['hostname'] , 'Port saturation threshold alarm: ' . $device['hostname'] . ' on ' . $port['ifDescr'] . "\nRates:" . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['ifSpeed'])); - } - } - - /// Update RRDs - $rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd"); - if (!is_file($rrdfile)) - { - rrdtool_create($rrdfile," --step 300 \ - DS:INOCTETS:DERIVE:600:0:12500000000 \ - DS:OUTOCTETS:DERIVE:600:0:12500000000 \ - DS:INERRORS:DERIVE:600:0:12500000000 \ - DS:OUTERRORS:DERIVE:600:0:12500000000 \ - DS:INUCASTPKTS:DERIVE:600:0:12500000000 \ - DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \ - DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \ - DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \ - DS:INDISCARDS:DERIVE:600:0:12500000000 \ - DS:OUTDISCARDS:DERIVE:600:0:12500000000 \ - DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \ - DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \ - DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \ - DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \ - DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 ".$config['rrd_rra']); - } - - foreach ($stat_oids as $oid) - { /// Copy values from array to global variables and force numeric. - $$oid = $this_port[$oid]; - if (!is_numeric($$oid)) { $$oid = "U"; } - } - - $if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos"; - $if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts"; - $ret = rrdtool_update("$rrdfile", $if_rrd_update); - /// End Update IF-MIB - - /// Update PAgP - if ($this_port['pagpOperationMode'] || $port['pagpOperationMode']) - { - foreach ($pagp_oids as $oid) - { /// Loop the OIDs - if ($this_port[$oid] != $port[$oid]) - { /// If data has changed, build a query - $port['update'][$oid] = $this_port[$oid]; - echo("PAgP "); - log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']); - } - } - } - /// End Update PAgP - - /// Do EtherLike-MIB - if ($config['enable_ports_etherlike']) { include("port-etherlike.inc.php"); } - - /// Do ADSL MIB - if ($config['enable_ports_adsl']) { include("port-adsl.inc.php"); } - - /// Do PoE MIBs - if ($config['enable_ports_poe']) { include("port-poe.inc.php"); } - - /// Do Alcatel Detailed Stats - if ($device['os'] == "aos") { include("port-alcatel.inc.php"); } - - /// Update Database - if (count($port['update'])) - { - $updated = dbUpdate($port['update'], 'ports', '`interface_id` = ?', array($port['interface_id'])); - if ($debug) { echo("$updated updated"); } - } - /// End Update Database - - /// Send alerts for interface flaps. - if ($config['alerts']['port']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0) - { - if ($this_port['ifAlias']) - { - $falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")"; - } else { - $full = $this_port['ifDescr']; - } - switch ($this_port['ifOperStatus']) - { - case "up": - notify($device, "Interface UP - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full); - break; - case "down": - notify($device, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full); - break; - } - } - } - elseif ($port['disabled'] != "1") - { - echo("Port Deleted"); /// Port missing from SNMP cache. - if ($port['deleted'] != "1") - { - dbUpdate(array('deleted' => '1'), 'ports', '`device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $port['ifIndex'])); - } - } else { - echo("Port Disabled."); - } - - echo("\n"); - - /// Clear Per-Port Variables Here - unset($this_port); -} /// Clear Variables Here unset($port_stats); +unset($ports_db); +unset($ports_db_db); ?> diff --git a/includes/discovery/vlans.inc.php b/includes/discovery/vlans.inc.php index 0b5ceb4ed..ee51ed96b 100644 --- a/includes/discovery/vlans.inc.php +++ b/includes/discovery/vlans.inc.php @@ -52,7 +52,7 @@ foreach ($device['vlans'] as $domain_id => $vlans) str_pad($vlan_port['dot1dStpPortState'], 15).str_pad($vlan_port['dot1dStpPortPathCost'], 10)); $db_w = array('device_id' => $device['device_id'], - 'interface_id' => $port['interface_id'], + 'port_id' => $port['port_id'], 'vlan' => $vlan_id); $db_a = array('baseport' => $vlan_port_id, @@ -60,7 +60,7 @@ foreach ($device['vlans'] as $domain_id => $vlans) 'state' => $vlan_port['dot1dStpPortState'], 'cost' => $vlan_port['dot1dStpPortPathCost']); - $from_db = dbFetchRow("SELECT * FROM `ports_vlans` WHERE device_id = ? AND interface_id = ? AND `vlan` = ?", array($device['device_id'], $port['interface_id'], $vlan_id)); + $from_db = dbFetchRow("SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?", array($device['device_id'], $port['port_id'], $vlan_id)); if ($from_db['port_vlan_id']) { diff --git a/includes/functions.php b/includes/functions.php index ac296eaaa..337ebbca3 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -170,7 +170,7 @@ function delete_device($id) foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) { $int_if = $int_data['ifDescr']; - $int_id = $int_data['interface_id']; + $int_id = $int_data['port_id']; delete_port($int_id); $ret .= "Removed interface $int_id ($int_if)\n"; } diff --git a/includes/polling/cisco-cef.inc.php b/includes/polling/cisco-cef.inc.php index eb789f3d3..ab139dee2 100755 --- a/includes/polling/cisco-cef.inc.php +++ b/includes/polling/cisco-cef.inc.php @@ -68,6 +68,8 @@ if ($device['os_group'] == "cisco") if (is_numeric($cef_stat['cefSwitchingHCPunt'])) { $cef_stat['cefSwitchingPunt'] = $cef_stat['cefSwitchingHCPunt']; } if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) { $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host']; } + ## FIXME -- memcached + $cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop']; $cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt']; $cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host']; @@ -79,10 +81,7 @@ if ($device['os_group'] == "cisco") dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path)); - $rrd_update = "N:".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host']; - $ret = rrdtool_update("$filename", $rrd_update); - - if ($debug) { echo(" Values: ".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host']); } + $ret = rrdtool_update("$filename", array($cef_stat['cefSwitchingDrop'], $cef_stat['cefSwitchingPunt'], $cef_stat['cefSwitchingPunt2Host'])); echo("\n"); diff --git a/includes/polling/cisco-ipsec-flow-monitor.inc.php b/includes/polling/cisco-ipsec-flow-monitor.inc.php index 26ead9189..7c33cfea8 100755 --- a/includes/polling/cisco-ipsec-flow-monitor.inc.php +++ b/includes/polling/cisco-ipsec-flow-monitor.inc.php @@ -74,28 +74,28 @@ if ($device['os_group'] == "cisco") rrdtool_create($rrd_filename, $rrd_create); } - $rrd_update = "N"; - $rrd_update .= ":".$data['cipSecGlobalActiveTunnels']; - $rrd_update .= ":".$data['cipSecGlobalInOctets']; - $rrd_update .= ":".$data['cipSecGlobalOutOctets']; - $rrd_update .= ":".$data['cipSecGlobalInDecompOctets']; - $rrd_update .= ":".$data['cipSecGlobalOutUncompOctets']; - $rrd_update .= ":".$data['cipSecGlobalInPkts']; - $rrd_update .= ":".$data['cipSecGlobalOutPkts']; - $rrd_update .= ":".$data['cipSecGlobalInDrops']; - $rrd_update .= ":".$data['cipSecGlobalInReplayDrops']; - $rrd_update .= ":".$data['cipSecGlobalOutDrops']; - $rrd_update .= ":".$data['cipSecGlobalInAuths']; - $rrd_update .= ":".$data['cipSecGlobalOutAuths']; - $rrd_update .= ":".$data['cipSecGlobalInAuthFails']; - $rrd_update .= ":".$data['cipSecGlobalOutAuthFails']; - $rrd_update .= ":".$data['cipSecGlobalInDecrypts']; - $rrd_update .= ":".$data['cipSecGlobalOutEncrypts']; - $rrd_update .= ":".$data['cipSecGlobalInDecryptFails']; - $rrd_update .= ":".$data['cipSecGlobalOutEncryptFails']; - $rrd_update .= ":".$data['cipSecGlobalProtocolUseFails']; - $rrd_update .= ":".$data['cipSecGlobalNoSaFails']; - $rrd_update .= ":".$data['cipSecGlobalSysCapFails']; + $rrd_update = array(); + $rrd_update[] = $data['cipSecGlobalActiveTunnels']; + $rrd_update[] = $data['cipSecGlobalInOctets']; + $rrd_update[] = $data['cipSecGlobalOutOctets']; + $rrd_update[] = $data['cipSecGlobalInDecompOctets']; + $rrd_update[] = $data['cipSecGlobalOutUncompOctets']; + $rrd_update[] = $data['cipSecGlobalInPkts']; + $rrd_update[] = $data['cipSecGlobalOutPkts']; + $rrd_update[] = $data['cipSecGlobalInDrops']; + $rrd_update[] = $data['cipSecGlobalInReplayDrops']; + $rrd_update[] = $data['cipSecGlobalOutDrops']; + $rrd_update[] = $data['cipSecGlobalInAuths']; + $rrd_update[] = $data['cipSecGlobalOutAuths']; + $rrd_update[] = $data['cipSecGlobalInAuthFails']; + $rrd_update[] = $data['cipSecGlobalOutAuthFails']; + $rrd_update[] = $data['cipSecGlobalInDecrypts']; + $rrd_update[] = $data['cipSecGlobalOutEncrypts']; + $rrd_update[] = $data['cipSecGlobalInDecryptFails']; + $rrd_update[] = $data['cipSecGlobalOutEncryptFails']; + $rrd_update[] = $data['cipSecGlobalProtocolUseFails']; + $rrd_update[] = $data['cipSecGlobalNoSaFails']; + $rrd_update[] = $data['cipSecGlobalSysCapFails']; rrdtool_update($rrd_filename, $rrd_update); diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index 05bf065f8..633d95054 100755 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -18,7 +18,7 @@ if ($device['os_group'] == "cisco") $mac_entries = 0; - $acc_rows = dbFetchRows("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.interface_id = I.interface_id AND I.device_id = ?", array($device['device_id'])); + $acc_rows = dbFetchRows("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.port_id = I.port_id AND I.device_id = ?", array($device['device_id'])); foreach ($acc_rows as $acc) { diff --git a/includes/polling/cisco-vpdn.inc.php b/includes/polling/cisco-vpdn.inc.php index 50aeeee75..47a74bd63 100755 --- a/includes/polling/cisco-vpdn.inc.php +++ b/includes/polling/cisco-vpdn.inc.php @@ -16,24 +16,15 @@ if ($device['os_group'] == "cisco") { $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("vpdn-".$type.".rrd"); - $rrd_create = " DS:tunnels:GAUGE:600:0:U"; - $rrd_create .= " DS:sessions:GAUGE:600:0:U"; - $rrd_create .= " DS:denied:COUNTER:600:0:100000"; - $rrd_create .= $config['rrd_rra']; if (is_file($rrd_filename) || $vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) { if (!file_exists($rrd_filename)) { - rrdtool_create($rrd_filename, $rrd_create); + rrdtool_create($rrd_filename, " DS:tunnels:GAUGE:600:0:U DS:sessions:GAUGE:600:0:U DS:denied:COUNTER:600:0:100000" . $config['rrd_rra']); } - $rrd_update = "N"; - $rrd_update .= ":".$vpdn['cvpdnSystemTunnelTotal']; - $rrd_update .= ":".$vpdn['cvpdnSystemSessionTotal']; - $rrd_update .= ":".$vpdn['cvpdnSystemDeniedUsersTotal']; - - rrdtool_update($rrd_filename, $rrd_update); + rrdtool_update($rrd_filename, array($vpdn['cvpdnSystemTunnelTotal'], $vpdn['cvpdnSystemSessionTotal'], $vpdn['cvpdnSystemDeniedUsersTotal'])); $graphs['vpdn_sessions_'.$type] = TRUE; $graphs['vpdn_tunnels_'.$type] = TRUE; @@ -41,7 +32,7 @@ if ($device['os_group'] == "cisco") echo(" Cisco VPDN ($type) "); } } - unset($data, $vpdn, $type, $rrd_filename, $rrd_create, $rrd_update); + unset($data, $vpdn, $type, $rrd_filename); } ?> diff --git a/includes/polling/junose-atm-vp.inc.php b/includes/polling/junose-atm-vp.inc.php index c247e2901..22830ed05 100755 --- a/includes/polling/junose-atm-vp.inc.php +++ b/includes/polling/junose-atm-vp.inc.php @@ -1,6 +1,6 @@ ".$this_port[$oid], $device, 'ospf', $port['interface_id']); ## FIXME + #log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); ## FIXME } } if ($ospf_instance_update) @@ -120,7 +120,7 @@ if (is_array($ospf_areas_db)) if ($ospf_area_db[$oid] != $ospf_area_poll[$oid]) { ## If data has changed, build a query $ospf_area_update[$oid] = $ospf_area_poll[$oid]; - #log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']); ## FIXME + #log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['port_id']); ## FIXME } } if ($ospf_area_update) @@ -148,7 +148,7 @@ unset($ospf_areas_poll); echo(" Ports: "); -$ospf_port_oids = array('ospfIfIpAddress','interface_id','ospfAddressLessIf','ospfIfAreaId','ospfIfType','ospfIfAdminStat','ospfIfRtrPriority','ospfIfTransitDelay','ospfIfRetransInterval','ospfIfHelloInterval','ospfIfRtrDeadInterval','ospfIfPollInterval','ospfIfState','ospfIfDesignatedRouter','ospfIfBackupDesignatedRouter','ospfIfEvents','ospfIfAuthKey','ospfIfStatus','ospfIfMulticastForwarding','ospfIfDemand','ospfIfAuthType'); +$ospf_port_oids = array('ospfIfIpAddress','port_id','ospfAddressLessIf','ospfIfAreaId','ospfIfType','ospfIfAdminStat','ospfIfRtrPriority','ospfIfTransitDelay','ospfIfRetransInterval','ospfIfHelloInterval','ospfIfRtrDeadInterval','ospfIfPollInterval','ospfIfState','ospfIfDesignatedRouter','ospfIfBackupDesignatedRouter','ospfIfEvents','ospfIfAuthKey','ospfIfStatus','ospfIfMulticastForwarding','ospfIfDemand','ospfIfAuthType'); ### Build array of existing entries foreach (dbFetchRows("SELECT * FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id'])) as $entry) @@ -190,9 +190,9 @@ if (is_array($ospf_ports_db)) if ($ospf_port_poll['ospfAddressLessIf']) { - $ospf_port_poll['interface_id'] = @dbFetchCell("SELECT `interface_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ospf_port_poll['ospfAddressLessIf'])); + $ospf_port_poll['port_id'] = @dbFetchCell("SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ospf_port_poll['ospfAddressLessIf'])); } else { - $ospf_port_poll['interface_id'] = @dbFetchCell("SELECT A.`interface_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND I.device_id = ?", array($ospf_port_poll['ospfIfIpAddress'], $device['device_id'])); + $ospf_port_poll['port_id'] = @dbFetchCell("SELECT A.`port_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?", array($ospf_port_poll['ospfIfIpAddress'], $device['device_id'])); } foreach ($ospf_port_oids as $oid) @@ -200,7 +200,7 @@ if (is_array($ospf_ports_db)) if ($ospf_port_db[$oid] != $ospf_port_poll[$oid]) { // If data has changed, build a query $ospf_port_update[$oid] = $ospf_port_poll[$oid]; - #log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['interface_id']); ## FIXME + #log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); ## FIXME } } if ($ospf_port_update) @@ -279,14 +279,14 @@ if (is_array($ospf_nbrs_db)) { $ospf_nbr_poll = $ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']]; - $ospf_nbr_poll['interface_id'] = @dbFetchCell("SELECT A.`interface_id` FROM ipv4_addresses AS A, nbrs AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND I.device_id = ?", array($ospf_nbr_poll['ospfNbrIpAddr'], $device['device_id'])); + $ospf_nbr_poll['port_id'] = @dbFetchCell("SELECT A.`port_id` FROM ipv4_addresses AS A, nbrs AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?", array($ospf_nbr_poll['ospfNbrIpAddr'], $device['device_id'])); - if ($ospf_nbr_db['interface_id'] != $ospf_nbr_poll['interface_id']) + if ($ospf_nbr_db['port_id'] != $ospf_nbr_poll['port_id']) { - if ($ospf_nbr_poll['interface_id']) { - $ospf_nbr_update = array('interface_id' => $ospf_nbr_poll['interface_id']); + if ($ospf_nbr_poll['port_id']) { + $ospf_nbr_update = array('port_id' => $ospf_nbr_poll['port_id']); } else { - $ospf_nbr_update = array('interface_id' => array('NULL')); + $ospf_nbr_update = array('port_id' => array('NULL')); } } @@ -296,7 +296,7 @@ if (is_array($ospf_nbrs_db)) if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid]) { // If data has changed, build a query $ospf_nbr_update[$oid] = $ospf_nbr_poll[$oid]; - #log_event("$oid -> ".$this_nbr[$oid], $device, 'ospf', $nbr['interface_id']); ## FIXME + #log_event("$oid -> ".$this_nbr[$oid], $device, 'ospf', $nbr['port_id']); ## FIXME } } if ($ospf_nbr_update) diff --git a/includes/polling/port-adsl.inc.php b/includes/polling/port-adsl.inc.php index c49064fda..b054f186b 100755 --- a/includes/polling/port-adsl.inc.php +++ b/includes/polling/port-adsl.inc.php @@ -86,9 +86,9 @@ if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) $this_port[$oid] = $this_port[$oid] / 10; } - if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = ?", array($port['interface_id'])) == "0") + if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id'])) == "0") { - dbInsert(array('interface_id' => $port['interface_id']), 'ports_adsl'); + dbInsert(array('port_id' => $port['port_id']), 'ports_adsl'); } $port['adsl_update'] = array('port_adsl_updated' => array('NOW()')); @@ -97,7 +97,7 @@ if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) $data = str_replace("\"", "", $this_port[$oid]); ## FIXME - do we need this? $port['adsl_update'][$oid] = $data; } - dbUpdate($port['adsl_update'], 'ports_adsl', '`interface_id` = ?', array($port['interface_id'])); + dbUpdate($port['adsl_update'], 'ports_adsl', '`port_id` = ?', array($port['port_id'])); if ($this_port['adslAtucCurrSnrMgn'] > "1280") { $this_port['adslAtucCurrSnrMgn'] = "U"; } if ($this_port['adslAturCurrSnrMgn'] > "1280") { $this_port['adslAturCurrSnrMgn'] = "U"; } diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 071642f11..bfa3adf5b 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -135,18 +135,18 @@ foreach ($port_stats as $ifIndex => $port) echo("valid"); if (!is_array($ports[$port['ifIndex']])) { - $interface_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); - $ports[$port['ifIndex']] = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($interface_id)); - echo("Adding: ".$port['ifName']."(".$ifIndex.")(".$ports[$port['ifIndex']]['interface_id'].")"); + $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); + $ports[$port['ifIndex']] = dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($port_id)); + echo("Adding: ".$port['ifName']."(".$ifIndex.")(".$ports[$port['ifIndex']]['port_id'].")"); #print_r($ports); } elseif ($ports[$ifIndex]['deleted'] == "1") { - dbUpdate(array('deleted' => '0'), 'ports', '`interface_id` = ?', array($ports[$ifIndex]['interface_id'])); + dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports[$ifIndex]['port_id'])); $ports[$ifIndex]['deleted'] = "0"; } } else { if ($ports[$port['ifIndex']]['deleted'] != "1") { - dbUpdate(array('deleted' => '1'), 'ports', '`interface_id` = ?', array($ports[$ifIndex]['interface_id'])); + dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($ports[$ifIndex]['port_id'])); $ports[$ifIndex]['deleted'] = "1"; } } @@ -166,7 +166,7 @@ foreach ($ports as $port) if ($config['memcached']['enable']) { - $port['poll_time'] = $memcache->get('port-'.$port['interface_id'].'-poll_time'); + $port['poll_time'] = $memcache->get('port-'.$port['port_id'].'-poll_time'); # echo("time".$port['poll_time']); } @@ -182,9 +182,9 @@ foreach ($ports as $port) if ($config['memcached']['enable']) { - $memcache->set('port-'.$port['interface_id'].'-poll_time', $polled); - $memcache->set('port-'.$port['interface_id'].'-poll_prev', $port['poll_time']); - $memcache->set('port-'.$port['interface_id'].'-poll_period', $polled_period); + $memcache->set('port-'.$port['port_id'].'-poll_time', $polled); + $memcache->set('port-'.$port['port_id'].'-poll_prev', $port['poll_time']); + $memcache->set('port-'.$port['port_id'].'-poll_period', $polled_period); } ### Copy ifHC[In|Out]Octets values to non-HC if they exist @@ -252,11 +252,11 @@ foreach ($ports as $port) if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) { $port['update'][$oid] = NULL; - log_event($oid . ": ".$port[$oid]." -> NULL", $device, 'interface', $port['interface_id']); + log_event($oid . ": ".$port[$oid]." -> NULL", $device, 'interface', $port['port_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); } } elseif ($port[$oid] != $this_port[$oid]) { $port['update'][$oid] = $this_port[$oid]; - log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device, 'interface', $port['interface_id']); + log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device, 'interface', $port['port_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); } } } @@ -274,7 +274,7 @@ foreach ($ports as $port) if ($port_ifAlias[$attrib] != $port[$attrib_key]) { $port['update'][$attrib_key] = $port_ifAlias[$attrib]; - log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device, 'interface', $port['interface_id']); + log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device, 'interface', $port['port_id']); } } } @@ -283,7 +283,6 @@ foreach ($ports as $port) ### Update IF-MIB metrics foreach ($stat_oids_db as $oid) { -# echo("\n".$oid.":"); if ($config['slow_statistics'] == TRUE) { $port['update'][$oid] = $this_port[$oid]; @@ -292,22 +291,16 @@ foreach ($ports as $port) if ($config['memcached']['enable']) { - $port[$oid] = $memcache->get('port-'.$port['interface_id'].'-'.$oid); - $memcache->set('port-'.$port['interface_id'].'-'.$oid, $this_port[$oid]); - $memcache->set('port-'.$port['interface_id'].'-'.$oid.'_prev', $port[$oid]); -# echo("MEMCACHE!"); + $port[$oid] = $memcache->get('port-'.$port['port_id'].'-'.$oid); + $memcache->set('port-'.$port['port_id'].'-'.$oid, $this_port[$oid]); + $memcache->set('port-'.$port['port_id'].'-'.$oid.'_prev', $port[$oid]); } -# echo(" old[".$port[$oid]."]"); -# echo(" new[".$this_port[$oid]."]"); - $oid_prev = $oid . "_prev"; if (isset($port[$oid])) { $oid_diff = $this_port[$oid] - $port[$oid]; -# echo(" diff[".$oid_diff."]"); $oid_rate = $oid_diff / $polled_period; -# echo(" rate[".$oid_rate."]"); if ($oid_rate < 0) { $oid_rate = "0"; echo("negative $oid"); } $port['stats'][$oid.'_rate'] = $oid_rate; $port['stats'][$oid.'_diff'] = $oid_diff; @@ -319,17 +312,24 @@ foreach ($ports as $port) if ($config['memcached']['enable']) { - $memcache->set('port-'.$port['interface_id'].'-'.$oid.'_rate', $oid_rate); - $memcache->set('port-'.$port['interface_id'].'-'.$oid.'_delta', $oid_diff); -# echo($oid."[".$oid_rate."]"); + $memcache->set('port-'.$port['port_id'].'-'.$oid.'_rate', $oid_rate); + $memcache->set('port-'.$port['port_id'].'-'.$oid.'_delta', $oid_diff); } if ($debug) { echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); } } } - $port['stats']['ifInBits_rate'] = $port['stats']['ifInOctets_rate'] * 8; - $port['stats']['ifOutBits_rate'] = $port['stats']['ifOutOctets_rate'] * 8; + $port['stats']['ifInBits_rate'] = round($port['stats']['ifInOctets_rate'] * 8); + $port['stats']['ifOutBits_rate'] = round($port['stats']['ifOutOctets_rate'] * 8); + + // If we have a valid ifSpeed we should populate the stats for checking. + if(is_numeric($this_port['ifSpeed'])) + { + $port['stats']['ifInBits_perc'] = round($port['stats']['ifInBits_rate'] / $this_port['ifSpeed'] * 100); + $port['stats']['ifOutBits_perc'] = round($port['stats']['ifOutBits_rate'] / $this_port['ifSpeed'] * 100); + } + echo('bps('.formatRates($port['stats']['ifInBits_rate']).'/'.formatRates($port['stats']['ifOutBits_rate']).')'); echo('bytes('.formatStorage($port['stats']['ifInOctets_diff']).'/'.formatStorage($port['stats']['ifOutOctets_diff']).')'); echo('pkts('.format_si($port['stats']['ifInUcastPkts_rate']).'pps/'.format_si($port['stats']['ifOutUcastPkts_rate']).'pps)'); @@ -343,11 +343,14 @@ foreach ($ports as $port) echo("IN: " . $port['stats']['ifInBits_rate'] . " OUT: " . $port['stats']['ifOutBits_rate'] . " THRESH: " . $saturation_threshold); if (($port['stats']['ifInBits_rate'] >= $saturation_threshold || $port['stats']['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) { - log_event('Port reached saturation threshold: ' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['stats']['ifSpeed']) , $device, 'interface', $port['interface_id']); + log_event('Port reached saturation threshold: ' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['stats']['ifSpeed']) , $device, 'interface', $port['port_id']); notify($device, 'Port saturation threshold reached on ' . $device['hostname'] , 'Port saturation threshold alarm: ' . $device['hostname'] . ' on ' . $port['ifDescr'] . "\nRates:" . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['ifSpeed'])); } } + print_r($port['stats']); + + ### Update RRDs $rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd"); if (!is_file($rrdfile)) @@ -370,15 +373,11 @@ foreach ($ports as $port) DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 ".$config['rrd_rra']); } - foreach ($stat_oids as $oid) - { ### Copy values from array to global variables and force numeric. - $$oid = $this_port[$oid]; - if (!is_numeric($$oid)) { $$oid = "U"; } - } + $this_port['rrd_update'] = array($this_port['ifInOctets'], $this_port['ifOutOctets'], $this_port['ifInErrors'], $this_port['ifOutErrors'], $this_port['ifInUcastPkts'], $this_port['ifOutUcastPkts'], + $this_port['ifInNUcastPkts'], $this_port['ifOutNUcastPkts'], $this_port['ifInDiscards'], $this_port['ifOutDiscards'], $this_port['ifInUnknownProtos'], + $this_port['ifInBroadcastPkts'], $this_port['ifOutBroadcastPkts'], $this_port['ifInMulticastPkts'], $this_port['ifOutMulticastPkts']); - $if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos"; - $if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts"; - $ret = rrdtool_update("$rrdfile", $if_rrd_update); + rrdtool_update("$rrdfile", $this_port['rrd_update']); ### End Update IF-MIB ### Update PAgP @@ -390,7 +389,7 @@ foreach ($ports as $port) { ### If data has changed, build a query $port['update'][$oid] = $this_port[$oid]; echo("PAgP "); - log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']); + log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['port_id']); } } } @@ -411,7 +410,7 @@ foreach ($ports as $port) ### Update Database if (count($port['update'])) { - $updated = dbUpdate($port['update'], 'ports', '`interface_id` = ?', array($port['interface_id'])); + $updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', array($port['port_id'])); if ($debug) { echo("$updated updated"); } } ### End Update Database diff --git a/includes/polling/ucd-diskio.inc.php b/includes/polling/ucd-diskio.inc.php index 321b98948..92a3af276 100644 --- a/includes/polling/ucd-diskio.inc.php +++ b/includes/polling/ucd-diskio.inc.php @@ -19,9 +19,6 @@ if (count($diskio_data)) if ($debug) { print_r($entry); } - $rrd_update = $entry['diskIONReadX'].":".$entry['diskIONWrittenX']; - $rrd_update .= ":".$entry['diskIOReads'].":".$entry['diskIOWrites']; - $rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ucd_diskio-" . $diskio['diskio_descr'] .".rrd"); if ($debug) { echo("$rrd "); } @@ -35,8 +32,7 @@ if (count($diskio_data)) DS:writes:DERIVE:600:0:125000000000 ".$config['rrd_rra']); } - rrdtool_update($rrd,"N:$rrd_update"); - unset($rrd_update); + rrdtool_update($rrd, array($entry['diskIONReadX'], $entry['diskIONWrittenX'], $entry['diskIOReads'], $entry['diskIOWrites'])); } echo("\n"); diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index e1ec9f8c6..4c455ad69 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -2,14 +2,7 @@ /** * Observium Network Management and Monitoring System - * Copyright (C) 2006-2011, Observium Developers - http://www.observium.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * See COPYING for more details. + * Copyright (C) 2006-2012, Adam Armstrong - http://www.observium.org * * @package rrdtool * @author Adam Armstrong diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index fe7552223..fd1aac692 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -2,6 +2,8 @@ // If anybody has again the idea to implement the PHP internal library calls, // be aware that it was tried and banned by lead dev Adam +// +// TRUE STORY. THAT SHIT IS WHACK. -- adama. function string_to_oid($string) { diff --git a/includes/snmptrap/linkDown.inc.php b/includes/snmptrap/linkDown.inc.php index c6e6bb994..6093597df 100644 --- a/includes/snmptrap/linkDown.inc.php +++ b/includes/snmptrap/linkDown.inc.php @@ -7,16 +7,16 @@ if (!$interface) { exit; } $ifOperStatus = "down"; #$ifAdminStatus = "down"; -log_event("SNMP Trap: linkDown " . $interface['ifDescr'], $device, "interface", $interface['interface_id']); +log_event("SNMP Trap: linkDown " . $interface['ifDescr'], $device, "interface", $interface['port_id']); #if ($ifAdminStatus != $interface['ifAdminStatus']) #{ -# log_event("Interface Disabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']); +# log_event("Interface Disabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']); #} if ($ifOperStatus != $interface['ifOperStatus']) { - log_event("Interface went Down : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']); - mysql_query("UPDATE `ports` SET ifOperStatus = 'down' WHERE `interface_id` = '".$interface['interface_id']."'"); + log_event("Interface went Down : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']); + mysql_query("UPDATE `ports` SET ifOperStatus = 'down' WHERE `port_id` = '".$interface['port_id']."'"); } ?> \ No newline at end of file diff --git a/includes/snmptrap/linkUp.inc.php b/includes/snmptrap/linkUp.inc.php index 8974852df..f4d1cbd63 100644 --- a/includes/snmptrap/linkUp.inc.php +++ b/includes/snmptrap/linkUp.inc.php @@ -7,18 +7,18 @@ if (!$interface) { exit; } $ifOperStatus = "up"; $ifAdminStatus = "up"; -log_event("SNMP Trap: linkUp $ifAdminStatus/$ifOperStatus " . $interface['ifDescr'], $device, "interface", $interface['interface_id']); +log_event("SNMP Trap: linkUp $ifAdminStatus/$ifOperStatus " . $interface['ifDescr'], $device, "interface", $interface['port_id']); if ($ifAdminStatus != $interface['ifAdminStatus']) { - log_event("Interface Enabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']); - mysql_query("UPDATE `ports` SET ifAdminStatus = 'up' WHERE `interface_id` = '".$interface['interface_id']."'"); + log_event("Interface Enabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']); + mysql_query("UPDATE `ports` SET ifAdminStatus = 'up' WHERE `port_id` = '".$interface['port_id']."'"); } if ($ifOperStatus != $interface['ifOperStatus']) { - log_event("Interface went Up : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']); - mysql_query("UPDATE `ports` SET ifOperStatus = 'up' WHERE `interface_id` = '".$interface['interface_id']."'"); + log_event("Interface went Up : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['port_id']); + mysql_query("UPDATE `ports` SET ifOperStatus = 'up' WHERE `port_id` = '".$interface['port_id']."'"); } diff --git a/includes/syslog.php b/includes/syslog.php index adf50ac09..f685107ae 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -4,7 +4,7 @@ # $device_id_host = @dbFetchCell("SELECT device_id FROM devices WHERE `hostname` = '".mres($entry['host'])."' OR `sysName` = '".mres($entry['host'])."'"); -# $device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id"); +# $device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.port_id = A.port_id"); function get_cache($host, $value) { @@ -20,7 +20,7 @@ function get_cache($host, $value) // If failed, try by IP if (!is_numeric($dev_cache[$host]['device_id'])) { - $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `ipv4_addresses` AS A, `ports` AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id', array($host)); + $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `ipv4_addresses` AS A, `ports` AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id', array($host)); } break; case 'os': diff --git a/poll-billing.php b/poll-billing.php index bac05c94e..453a823c1 100755 --- a/poll-billing.php +++ b/poll-billing.php @@ -45,7 +45,7 @@ foreach (dbFetchRows("SELECT * FROM `bills`") as $bill_data) function CollectData($bill_id) { - foreach (dbFetchRows("SELECT * FROM `bill_ports` as P, `ports` as I, `devices` as D WHERE P.bill_id=? AND I.interface_id = P.port_id AND D.device_id = I.device_id", array($bill_id)) as $port_data) + foreach (dbFetchRows("SELECT * FROM `bill_ports` as P, `ports` as I, `devices` as D WHERE P.bill_id=? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($bill_id)) as $port_data) { $port_id = $port_data['port_id']; $host = $port_data['hostname']; diff --git a/poller.php b/poller.php index 362ad1a2a..c2f21cc66 100755 --- a/poller.php +++ b/poller.php @@ -24,7 +24,7 @@ include("includes/polling/functions.inc.php"); $poller_start = utime(); echo("Observium Poller v".$config['version']."\n\n"); -$options = getopt("h:m:i:n:r:d::a::"); +$options = getopt("h:m:i:n:r::d::a::"); if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; } diff --git a/snmptrap.php b/snmptrap.php index 4ebefd5a6..049da4c7c 100755 --- a/snmptrap.php +++ b/snmptrap.php @@ -33,7 +33,7 @@ $device = @dbFetchRow("SELECT * FROM devices WHERE `hostname` = ?", array($entry if (!$device['device_id']) { - $device = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id", array($entry['0'])); + $device = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id", array($entry['0'])); } if (!$device['device_id']) { exit; } else { } diff --git a/sql-schema/022.sql b/sql-schema/022.sql new file mode 100644 index 000000000..d4cbc003c --- /dev/null +++ b/sql-schema/022.sql @@ -0,0 +1 @@ +ALTER TABLE `ports` CHANGE `interface_id` `port_id` INT( 11 ) NOT NULL AUTO_INCREMENT;