revamped customer aggregates page, using new port description parser fields in database

git-svn-id: http://www.observium.org/svn/observer/trunk@1290 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2010-07-04 19:14:42 +00:00
parent ad406723eb
commit c98b16c559

View File

@ -1,63 +1,48 @@
<?php
$sql = "SELECT * FROM `ports` AS I, `devices` AS D";
$sql .= " WHERE I.ifAlias like 'Cust: %' AND I.device_id = D.device_id ORDER BY I.ifAlias,D.hostname";
$query = mysql_query($sql);
$sql = "SELECT * FROM `ports` WHERE `port_descr_type` = 'Cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`";
$cust_query = mysql_query($sql);
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
echo("<table border=0 cellspacing=0 cellpadding=2 class=devicetable width=100%>");
echo("<table border=0 cellspacing=0 cellpadding=2 class=devicetable width=100%>");
echo("
<tr bgcolor='$list_colour_a'>
<th width='7'></th>
<th width='250'><span style='font-weight: bold;' class=interface>Customer</span></th>
<th width='150'>Device</th>
<th width='100'>Interface</th>
<th width='100'>Speed</th>
<th width='100'>Circuit</th>
<th>Notes</th>
</tr>
");
echo("
<tr bgcolor='$list_colour_a'>
<th width='7'></th>
<th width='250'><span style='font-weight: bold;' class=interface>Customer</span></th>
<th width='150'>Device</th>
<th width='100'>Interface</th>
<th width='100'>Speed</th>
<th width='100'>Circuit</th>
<th>Notes</th>
</tr>
");
$i = 1;
while($customer = mysql_fetch_array($cust_query)) {
$customers = 1;
while($interface = mysql_fetch_array($query)) {
$device = &$interface;
$i++;
$port_sql = "SELECT * FROM `ports` WHERE `port_descr_type` = 'Cust' AND `port_descr_descr` = '".$customer['port_descr_descr']."'";
$port_query = mysql_query($port_sql);
$customer_name = $customer['port_descr_descr'];
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
while($port = mysql_fetch_array($port_query)) {
$device = device_by_id_cache($port['device_id']);
unset($class);
$ifname = fixifname($device['ifDescr']);
$ifclass = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
list($type,$customer) = preg_split("/[\:\[\]\{\}\(\)]/", $interface['ifAlias']);
list(,$circuit) = preg_split("/[\{\}]/", $interface['ifAlias']);
list(,$notes) = preg_split("/[\(\)]/", $interface['ifAlias']);
list(,$speed) = preg_split("/[\[\]]/", $interface['ifAlias']);
$customer = trim($customer);
if ($customer == $prev_customer) {
unset($customer);
} else {
if(isset($prev_customer)) {
echo("<tr bgcolor='$bg_colour'><td></td><td colspan=6>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($prev_customer)."&type=customer_bits&from=$day&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($prev_customer)."&type=customer_bits&from=$week&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($prev_customer)."&type=customer_bits&from=$month&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($prev_customer)."&type=customer_bits&from=$year&to=$now&width=215&height=100'>
</td></tr>");
}
if(is_integer($customers/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
$customers++;
$prev_customer = $customer;
}
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if($device['os'] == "ios") {
if($interface['ifTrunk']) { $vlan = "<span class=box-desc><span class=red>" . $interface['ifTrunk'] . "</span></span>";
} elseif ($interface['ifVlan']) { $vlan = "<span class=box-desc><span class=blue>VLAN " . $interface['ifVlan'] . "</span></span>";
if($port['ifTrunk']) { $vlan = "<span class=box-desc><span class=red>" . $port['ifTrunk'] . "</span></span>";
} elseif ($port['ifVlan']) { $vlan = "<span class=box-desc><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>";
} else { $vlan = ""; }
}
@ -65,17 +50,30 @@
echo("
<tr bgcolor='$bg_colour'>
<td width='7'></td>
<td width='250'><span style='font-weight: bold;' class=interface>$customer</span></td>
<td width='250'><span style='font-weight: bold;' class=interface>".$customer_name."</span></td>
<td width='150'>" . generatedevicelink($device) . "</td>
<td width='100'>" . generateiflink($interface, makeshortif($interface['ifDescr'])) . "</td>
<td width='100'>$speed</td>
<td width='100'>$circuit</td>
<td>$notes</td>
<td width='100'>" . generateiflink($port, makeshortif($port['ifDescr'])) . "</td>
<td width='100'>".$port['port_descr_speed']."</td>
<td width='100'>".$port['port_descr_circuit']."</td>
<td>".$port['port_descr_notes']."</td>
</tr>
");
unset($customer_name);
}
echo("<tr bgcolor='$bg_colour'><td></td><td colspan=6>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$day&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$week&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$month&to=$now&width=215&height=100'>
<img src='".$config['base_url']."/graph.php?cust=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$year&to=$now&width=215&height=100'>
</td></tr>");
}
echo("</table>");
?>