new mac address search

git-svn-id: http://www.observium.org/svn/observer/trunk@2151 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2011-04-24 00:28:09 +00:00
parent 28b98dad8d
commit c6964aec37
6 changed files with 117 additions and 6 deletions

View File

@ -156,9 +156,6 @@ if ($config['enable_pseudowires']) { echo('<li><a href="pseudowires/"><img src="
if ($config['enable_vrfs']) { echo('<li><a href="vrfs/"><img src="images/16/layers.png" border="0" align="absmiddle" /> VRFs</a></li>'); $ifbreak = 1; }
?>
<li><a href="ipv4/"><img src="images/16/email_link.png" border="0" align="absmiddle" /> IPv4 Search</a></li>
<li><a href="ipv6/"><img src="images/16/email_link.png" border="0" align="absmiddle" /> IPv6 Search</a></li>
<?php
if ($_SESSION['userlevel'] >= '5')
@ -280,7 +277,7 @@ foreach (array_keys($menu_sensors) as $item)
if ($_SESSION['userlevel'] >= '5')
{
echo('
<li><a class="menu2four" href="routing/"><img src="images/16/arrow_branch.png" border="0" align="absmiddle" />Routing</a>
<li><a class="menu2four" href="routing/"><img src="images/16/arrow_branch.png" border="0" align="absmiddle" /> Routing</a>
<table><tr><td>
<ul>');
@ -317,6 +314,17 @@ if ($_SESSION['userlevel'] >= '5')
?>
<li><a class="menu2four" href=""><img src="images/16/find.png" border="0" align="absmiddle" /> Search
<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href="search/ipv4/"><img src="images/16/email_link.png" border="0" align="absmiddle" /> IPv4 Search</a></li>
<li><a href="search/ipv6/"><img src="images/16/email_link.png" border="0" align="absmiddle" /> IPv6 Search</a></li>
<li><a href="search/mac/"><img src="images/16/email_link.png" border="0" align="absmiddle" /> MAC Search</a></li>
</ul>
</td></tr></table>
</li>
<li style="float: right;"><a><img src="images/16/wrench.png" border="0" align="absmiddle" /> System
<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>

View File

@ -10,7 +10,7 @@ $i = "1";
echo('<tr><th>Local Port</th>
<th>Remote Port</th>
<th>Remote Device</th>
<th></th>
<th>Protocol</th>
</tr>');
while($neighbour = mysql_fetch_assoc($query))
@ -32,6 +32,8 @@ while($neighbour = mysql_fetch_assoc($query))
echo("<td>".$neighbour['remote_hostname']."
<br />".$neighbour['remote_platform']."</td>");
}
echo("<td>".$neighbour['protocol']."</td>");
echo("</tr>");
$i++;
}

View File

@ -0,0 +1,86 @@
<?php print_optionbar_start(28); ?>
<table cellpadding="0" cellspacing="0" class="devicetable" width="100%">
<tr>
<form method="post" action="">
<td width="200" style="padding: 1px;">
<select name="device_id" id="device_id">
<option value="">All Devices</option>
<?php
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
while ($data = mysql_fetch_assoc($query))
{
echo('<option value="'.$data['device_id'].'"');
if ($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
</select>
</td>
<td width="200" style="padding: 1px;">
<select name="interface" id="interface">
<option value="">All Interfaces</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%"){ echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%"){ echo("selected"); } ?> >VLANs</option>
</select>
</td>
<td>
</td>
<td width=400>
<input type="text" name="address" id="address" size=40 value="<?php echo($_POST['address']); ?>" />
<input style="align:right;" type=submit class=submit value=Search></div>
</td>
</form>
</tr>
</table>
<?php
print_optionbar_end();
echo('<table width="100%" cellspacing="0" cellpadding="2">');
$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('<tr class="tablehead"><th>Device</a></th><th>Interface</th><th>MAC Address</th><th>Description</th></tr>');
$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,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if (port_permitted($entry['interface_id']))
{
echo('<tr bgcolor="' . $row_colour . '">
<td class="list-bold">' . generate_device_link($entry) . '</td>
<td class="list-bold">' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '</td>
<td>' . formatMac($entry['ifPhysAddress']) . '</td>
<td>' . $entry['ifAlias'] . "</td>
</tr>\n");
$row++;
}
}
unset($ignore);
}
echo("</table>");
?>

View File

@ -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);
?>
?>