remove overview for routing. it was retarded. :D

git-svn-id: http://www.observium.org/svn/observer/trunk@2204 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-29 22:29:42 +00:00
parent f37f8890f0
commit c7e46edfb8
5 changed files with 183 additions and 50 deletions

View File

@@ -10,7 +10,7 @@ if (strpos($_SERVER['REQUEST_URI'], "debug"))
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);
ini_set('log_errors', 1); ini_set('log_errors', 1);
ini_set('error_reporting', E_PARSE); ini_set('error_reporting', E_ALL);
} else { } else {
$debug = FALSE; $debug = FALSE;
ini_set('display_errors', 0); ini_set('display_errors', 0);

View File

@@ -1,23 +1,21 @@
<?php <?php
$datas[] = 'overview'; #$datas[] = 'overview';
if (@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') $routing_count['bgp'] = mysql_result(mysql_query("select count(*) from bgpPeers WHERE device_id = '" . $device['device_id'] . "'"), 0);
{ if ($routing_count['bgp']) { $datas[] = 'bgp'; }
$datas[] = 'vrf';
}
$bgp_count = mysql_result(mysql_query("select count(*) from bgpPeers WHERE device_id = '" . $device['device_id'] . "'"), 0); $routing_count['ospf'] = mysql_result(mysql_query("select count(*) from ospf_ports WHERE device_id = '" . $device['device_id'] . "'"), 0);
if ($bgp_count) { $datas[] = 'bgp'; } if ($routing_count['ospf']) { $datas[] = 'ospf'; }
$cef_count = mysql_result(mysql_query("select count(*) from cef_switching WHERE device_id = '" . $device['device_id'] . "'"), 0); $routing_count['cef'] = mysql_result(mysql_query("select count(*) from cef_switching WHERE device_id = '" . $device['device_id'] . "'"), 0);
if ($cef_count) { $datas[] = 'cef'; } if ($routing_count['cef']) { $datas[] = 'cef'; }
$ospf_count = mysql_result(mysql_query("select count(*) from ospf_instances WHERE device_id = '" . $device['device_id'] . "'"), 0); $routing_count['vrf'] = @mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0);
if ($ospf_count) { $datas[] = 'ospf'; } if($routing_count['vrf']) { $datas[] = 'vrf'; }
$type_text['overview'] = "Overview"; #$type_text['overview'] = "Overview";
$type_text['bgp'] = "BGP"; $type_text['bgp'] = "BGP";
$type_text['cef'] = "CEF"; $type_text['cef'] = "CEF";
$type_text['ospf'] = "OSPF"; $type_text['ospf'] = "OSPF";
@@ -25,11 +23,14 @@ $type_text['vrf'] = "VRFs";
print_optionbar_start(); print_optionbar_start();
if (!$_GET['opta']) { $_GET['opta'] = "overview"; } echo("<span style='font-weight: bold;'>Routing</span> &#187; ");
unset($sep); unset($sep);
foreach ($datas as $type) foreach ($datas as $type)
{ {
if (!$_GET['opta']) { $_GET['opta'] = $type; }
echo($sep); echo($sep);
if ($_GET['opta'] == $type) if ($_GET['opta'] == $type)
@@ -37,7 +38,7 @@ foreach ($datas as $type)
echo('<span class="pagemenu-selected">'); echo('<span class="pagemenu-selected">');
} }
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/routing/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ."</a>"); echo("<a href='".$config['base_url']."/device/".$device['device_id']."/routing/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ." (".$routing_count[$type].")</a>");
if ($_GET['opta'] == $type) { echo("</span>"); } if ($_GET['opta'] == $type) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }

View File

@@ -1,5 +1,114 @@
<?php <?php
echo("<pre>");
print_r(mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."'"))); $sql = "SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."'";
echo("</pre>"); $query = mysql_query($sql);
$i_i = "0";
echo('<table width=100% border=0 cellpadding=5>');
#### Loop Instances
while($instance = mysql_fetch_assoc($query))
{
if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; }
$area_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"),0);
$port_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"),0);
$port_count_enabled = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = '".$device['device_id']."'"),0);
$query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE ";
$query .= "(A.ipv4_address = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id)";
$query .= " AND I.device_id = '".$device['device_id']."'";
$ipv4_host = mysql_fetch_assoc(mysql_query($query));
if($instance['ospfAdminStat'] == "enabled") { $enabled = '<span style="color: #00aa00">enabled</span>'; } else { $enabled = '<span style="color: #aaaaaa">disabled</span>'; }
if($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = '<span style="color: #00aa00">yes</span>'; } else { $abr = '<span style="color: #aaaaaa">no</span>'; }
if($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span style="color: #00aa00">yes</span>'; } else { $asbr = '<span style="color: #aaaaaa">no</span>'; }
echo('<tr><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr>');
echo('<tr bgcolor="'.$instance_bg.'">');
echo(' <td class="list-large">'.$instance['ospfRouterId'] . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $abr . '</td>');
echo(' <td>' . $asbr . '</td>');
echo(' <td>' . $area_count . '</td>');
echo(' <td>' . $port_count . '('.$port_count_enabled.')</td>');
echo(' <td>' . ($neighbour_count+0) . '</td>');
echo('</tr>');
echo('<tr bgcolor="'.$instance_bg.'">');
echo('<td colspan=7>');
echo('<table width=100% border=0 cellpadding=5>');
echo('<tr><th></th><th>Area Id</th><th>Status</th><th>Ports</th></tr>');
##### Loop Areas
$i_a = 0;
$a_sql = "SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'";
$a_query = mysql_query($a_sql);
while($area = mysql_fetch_assoc($a_query))
{
if (!is_integer($i_a/2)) { $area_bg = $list_colour_b_a; } else { $area_bg = $list_colour_b_b; }
$area_port_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospfIfAreaId` = '".$area['ospfAreaId']."'"),0);
$area_port_count_enabled = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = '".$device['device_id']."' AND `ospfIfAreaId` = '".$area['ospfAreaId']."'"),0);
echo('<tr bgcolor="'.$area_bg.'">');
echo(' <td width=5></td>');
echo(' <td class="list-large">'.$area['ospfAreaId'] . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $area_port_count . '('.$area_port_count_enabled.')</td>');
echo('</tr>');
echo('<tr bgcolor="'.$area_bg.'">');
echo('<td colspan=7>');
echo('<table width=100% border=0 cellpadding=5>');
echo('<tr><th></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr>');
##### 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` = '".$device['device_id']."' AND O.`ospfIfAreaId` = '".$area['ospfAreaId']."' AND P.interface_id = O.interface_id";
$p_query = mysql_query($p_sql);
while($ospfport = mysql_fetch_assoc($p_query))
{
if (!is_integer($i_a/2)) {
if (!is_integer($i_p/2)) { $port_bg = $list_colour_b_b; } else { $port_bg = $list_colour_b_a; }
} else {
if (!is_integer($i_p/2)) { $port_bg = $list_colour_a_b; } else { $port_bg = $list_colour_a_a; }
}
if($ospfport['ospfIfAdminStat'] == "enabled") { $port_enabled = '<span style="color: #00aa00">enabled</span>'; } else { $port_enabled = '<span style="color: #aaaaaa">disabled</span>'; }
echo('<tr bgcolor="'.$port_bg.'">');
echo(' <td width=15></td>');
echo(' <td><strong>'. generate_port_link($ospfport) . '</strong></td>');
echo(' <td>' . $port_enabled . '</td>');
echo(' <td>' . $ospfport['ospfIfType'] . '</td>');
echo(' <td>' . $ospfport['ospfIfState'] . '</td>');
echo('</tr>');
$i_p++;
}
echo('</table>');
echo('</td>');
echo('</tr>');
$i_a++;
} ### End loop areas
echo('</table>');
echo('</td>');
echo('</tr>');
$i_i++;
} ### End loop instances
echo('</table>');
?> ?>

View File

@@ -1,26 +1,47 @@
<?php <?php
## We are assuming there will only ever be one instance, because OSPF-MIB is retarded. $sql = "SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."'";
$query = mysql_query($sql);
$instance = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."'")); $i_i = "1";
$area_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"),0); echo('<table width=100%>');
$port_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"),0);
echo(" #### Loop Instances
<table width=100%>
<tr> while($instance = mysql_fetch_assoc($query))
<th>Router ID</th> {
<th>Area Count</th>
<th>Port Count</th> if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; }
<th>Neighbour Count</th>
</tr> $area_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"),0);
<tr> $port_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"),0);
<td>".$instance['ospfRouterId']."</td>
<td>".$area_count."</td> $query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE ";
<td>".$port_count."</td> $query .= "(A.ipv4_address = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id)";
</tr> $query .= " AND I.device_id = '".$device['device_id']."'";
</table> $ipv4_host = mysql_fetch_assoc(mysql_query($query));
");
if($instance['ospfAdminStat'] == "enabled") { $enabled = '<span style="color: #00aa00">enabled</span>'; } else { $enabled = '<span style="color: #aaaaaa">disabled</span>'; }
if($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = '<span style="color: #00aa00">yes</span>'; } else { $abr = '<span style="color: #aaaaaa">no</span>'; }
if($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span style="color: #00aa00">yes</span>'; } else { $asbr = '<span style="color: #aaaaaa">no</span>'; }
echo('<tr><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr>');
echo('<tr bgcolor="'.$instance_bg.'">');
echo(' <td class="list-large">'.$instance['ospfRouterId'] . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $abr . '</td>');
echo(' <td>' . $asbr . '</td>');
echo(' <td>' . $area_count . '</td>');
echo(' <td>' . $port_count . '</td>');
echo(' <td>' . ($neighbour_count+0) . '</td>');
echo('</tr>');
$i_i++;
} ### End loop instances
echo('</table>');
?> ?>

View File

@@ -1,23 +1,22 @@
<?php <?php
if (!$_GET['opta']) { $_GET['opta'] = "overview"; }
if ($_GET['optb'] == "graphs" || $_GET['optc'] == "graphs") { $graphs = "graphs"; } else { $graphs = "nographs"; } if ($_GET['optb'] == "graphs" || $_GET['optc'] == "graphs") { $graphs = "graphs"; } else { $graphs = "nographs"; }
$datas[] = 'overview'; #$datas[] = 'overview';
$vrf_count = @mysql_result(mysql_query("SELECT COUNT(*) FROM `vrfs`"), 0); $routing_count['bgp'] = mysql_result(mysql_query("select count(*) from bgpPeers"), 0);
if($vrf_count) { $datas[] = 'vrf'; } if ($routing_count['bgp']) { $datas[] = 'bgp'; }
$bgp_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `bgpPeers`"), 0); $routing_count['ospf'] = mysql_result(mysql_query("select count(*) from ospf_ports"), 0);
if ($bgp_count) { $datas[] = 'bgp'; } if ($routing_count['ospf']) { $datas[] = 'ospf'; }
$cef_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `cef_switching`"), 0); $routing_count['cef'] = mysql_result(mysql_query("select count(*) from cef_switching"), 0);
if ($cef_count) { $datas[] = 'cef'; } if ($routing_count['cef']) { $datas[] = 'cef'; }
$ospf_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_instances`"), 0); $routing_count['vrf'] = @mysql_result(mysql_query("select count(*) from vrfs"), 0);
if ($ospf_count) { $datas[] = 'ospf'; } if($routing_count['vrf']) { $datas[] = 'vrf'; }
$type_text['overview'] = "Overview"; #$type_text['overview'] = "Overview";
$type_text['bgp'] = "BGP"; $type_text['bgp'] = "BGP";
$type_text['cef'] = "CEF"; $type_text['cef'] = "CEF";
$type_text['ospf'] = "OSPF"; $type_text['ospf'] = "OSPF";
@@ -25,13 +24,16 @@ $type_text['vrf'] = "VRFs";
print_optionbar_start(); print_optionbar_start();
if (!$_GET['opta']) { $_GET['opta'] = "overview"; } #if (!$_GET['opta']) { $_GET['opta'] = "overview"; }
echo("<span style='font-weight: bold;'>Routing</span> &#187; "); echo("<span style='font-weight: bold;'>Routing</span> &#187; ");
unset($sep); unset($sep);
foreach ($datas as $type) foreach ($datas as $type)
{ {
if (!$_GET['opta']) { $_GET['opta'] = $type; }
echo($sep); echo($sep);
if ($_GET['opta'] == $type) if ($_GET['opta'] == $type)
@@ -39,7 +41,7 @@ foreach ($datas as $type)
echo('<span class="pagemenu-selected">'); echo('<span class="pagemenu-selected">');
} }
echo("<a href='routing/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ."</a>"); echo("<a href='routing/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ." (".$routing_count[$type].")</a>");
if ($_GET['opta'] == $type) { echo("</span>"); } if ($_GET['opta'] == $type) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }