From c6964aec3731fc1341cb397c470667ddc0d8fe3c Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 24 Apr 2011 00:28:09 +0000 Subject: [PATCH] new mac address search git-svn-id: http://www.observium.org/svn/observer/trunk@2151 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/print-menubar.php | 16 +++- html/pages/device/ports/neighbours.inc.php | 4 +- html/pages/{ => search}/ipv4.inc.php | 0 html/pages/{ => search}/ipv6.inc.php | 0 html/pages/search/mac.inc.php | 86 ++++++++++++++++++++++ includes/polling/ports.inc.php | 17 ++++- 6 files changed, 117 insertions(+), 6 deletions(-) rename html/pages/{ => search}/ipv4.inc.php (100%) rename html/pages/{ => search}/ipv6.inc.php (100%) create mode 100644 html/pages/search/mac.inc.php diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 26e2478e6a..2091f81a5c 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -156,9 +156,6 @@ if ($config['enable_pseudowires']) { echo('
  • VRFs
  • '); $ifbreak = 1; } ?> -
  • IPv4 Search
  • -
  • IPv6 Search
  • - = '5') @@ -280,7 +277,7 @@ foreach (array_keys($menu_sensors) as $item) if ($_SESSION['userlevel'] >= '5') { echo(' -
  • Routing +
  • Routing '); +$row = 1; +while ($entry = mysql_fetch_assoc($query)) +{ + + if (!$ignore) + { + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + + $speed = humanspeed($entry['ifSpeed']); + $type = humanmedia($entry['ifType']); + + if ($entry['in_errors'] > 0 || $entry['out_errors'] > 0) + { + $error_img = generate_port_link($entry,"Interface Errors",errors); + } else { $error_img = ""; } + + if (port_permitted($entry['interface_id'])) + { + echo(' + + + + + \n"); + + $row++; + } + } + + unset($ignore); +} + +echo("
      '); @@ -317,6 +314,17 @@ if ($_SESSION['userlevel'] >= '5') ?> +
    • Search + +
      + +
      +
    • +
    • System - + '); while($neighbour = mysql_fetch_assoc($query)) @@ -32,6 +32,8 @@ while($neighbour = mysql_fetch_assoc($query)) echo(""); } + echo(""); + echo(""); $i++; } diff --git a/html/pages/ipv4.inc.php b/html/pages/search/ipv4.inc.php similarity index 100% rename from html/pages/ipv4.inc.php rename to html/pages/search/ipv4.inc.php diff --git a/html/pages/ipv6.inc.php b/html/pages/search/ipv6.inc.php similarity index 100% rename from html/pages/ipv6.inc.php rename to html/pages/search/ipv6.inc.php diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php new file mode 100644 index 0000000000..fe6036fe89 --- /dev/null +++ b/html/pages/search/mac.inc.php @@ -0,0 +1,86 @@ + + +
      diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 37cb0e24bd..300278a6f3 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,7 +10,7 @@ $i = "1"; echo('
      Local Port Remote Port Remote DeviceProtocol
      ".$neighbour['remote_hostname']."
      ".$neighbour['remote_platform']."
      ".$neighbour['protocol']."
      + + + + + + + + +
      + + + + + + + +
      + +'); + +$where = "AND `ifPhysAddress` LIKE '%".$_POST['address']."%'"; +if (is_numeric($_POST['device_id'])) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; } +if ($_POST['interface']) { $where .= " AND I.ifDescr LIKE '".mres($_POST['interface'])."'"; } + +$sql = "SELECT * FROM `ports` AS P, `devices` AS D WHERE P.device_id = D.device_id $where ORDER BY P.ifPhysAddress"; + +$query = mysql_query($sql); + +echo('
    DeviceInterfaceMAC AddressDescription
    ' . generate_device_link($entry) . '' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '' . formatMac($entry['ifPhysAddress']) . '' . $entry['ifAlias'] . "
    "); + +?> diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 500dbd803b..f7754696fd 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -123,6 +123,21 @@ while ($port = mysql_fetch_assoc($port_query)) $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']); + $ah_a = zeropad(dechex($a_a)); + $ah_b = zeropad(dechex($a_b)); + $ah_c = zeropad(dechex($a_c)); + $ah_d = zeropad(dechex($a_d)); + $ah_e = zeropad(dechex($a_e)); + $ah_f = zeropad(dechex($a_f)); + #$this_port['ifPhysAddress'] = $ah_a.":".$ah_b.":".$ah_c.":".$ah_d.":".$ah_e.":".$ah_f; + $this_port['ifPhysAddress'] = $ah_a.$ah_b.$ah_c.$ah_d.$ah_e.$ah_f; + } + if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts'])) { echo("HC "); @@ -319,4 +334,4 @@ while ($port = mysql_fetch_assoc($port_query)) #### Clear Variables Here unset($port_stats); -?> \ No newline at end of file +?>