cleanups etc

git-svn-id: http://www.observium.org/svn/observer/trunk@2213 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-05-01 17:26:06 +00:00
parent e8178b4065
commit 6e5558db82
9 changed files with 43 additions and 62 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
# This file prints a table row for each interface # This file prints a table row for each interface
$interface['device_id'] = $device['device_id']; $interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname']; $interface['hostname'] = $device['hostname'];
@@ -14,11 +14,12 @@ if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $l
if ($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0) if ($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0)
{ {
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>","port_errors"); $error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>","port_errors");
} else { $error_img = ""; } } else {
$error_img = "";
}
# FIXME leading slash - does javascript honor base tag?
echo("<tr style=\"background-color: $row_colour; padding: 5px;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" echo("<tr style=\"background-color: $row_colour; padding: 5px;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\"
onclick=\"location.href='/device/".$device['device_id']."/port/".$interface['interface_id']."/'\" style='cursor: pointer;'> onclick=\"location.href='device/".$device['device_id']."/port/".$interface['interface_id']."/'\" style='cursor: pointer;'>
<td valign=top width=350>"); <td valign=top width=350>");
echo(" <span class=list-large> echo(" <span class=list-large>
" . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . " " . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . "
@@ -30,17 +31,15 @@ unset ($break);
if ($port_details) if ($port_details)
{ {
$ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'"); $ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while ($ip = mysql_fetch_Array($ipdata)) while ($ip = mysql_fetch_assoc($ipdata))
{ {
# FIXME leading slash - does javascript honor base tag? echo("$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&amp;query=".$ip['ipv4_address']."')\">".$ip['ipv4_address']."/".$ip['ipv4_prefixlen']."</a>");
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&amp;query=$ip[ipv4_address]')\">$ip[ipv4_address]/$ip[ipv4_prefixlen]</a>");
$break = ","; $break = ",";
} }
$ip6data = mysql_query("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'"); $ip6data = mysql_query("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while ($ip6 = mysql_fetch_Array($ip6data)) while ($ip6 = mysql_fetch_assoc($ip6data))
{ {
# FIXME leading slash - does javascript honor base tag? echo("$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
$break = ","; $break = ",";
} }
} }
@@ -141,7 +140,6 @@ if ($graph_type && is_file($graph_file))
onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>"); onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
echo("</td></tr>"); echo("</td></tr>");
} }
?> ?>

View File

@@ -87,15 +87,16 @@ if ($updated && $update_message)
<select name="type"> <select name="type">
<?php <?php
$unknown = 1; $unknown = 1;
foreach ($device_types as $type)
foreach ($config['device_types'] as $type)
{ {
echo(' <option value="'.$type.'"'); echo(' <option value="'.$type['type'].'"');
if ($device['type'] == $type) if ($device['type'] == $type['type'])
{ {
echo('selected="1"'); echo(' selected="1"');
$unknown = 0; $unknown = 0;
} }
echo(' >' . ucfirst($type) . '</option>'); echo(' >' . ucfirst($type['type']) . '</option>');
} }
if ($unknown) if ($unknown)
{ {

View File

@@ -9,9 +9,8 @@ echo('<table width=100% border=0 cellpadding=5>');
#### Loop Instances #### Loop Instances
while($instance = mysql_fetch_assoc($query)) while ($instance = mysql_fetch_assoc($query))
{ {
if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; } 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); $area_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"),0);
@@ -25,9 +24,9 @@ while($instance = mysql_fetch_assoc($query))
$query .= " AND I.device_id = '".$device['device_id']."'"; $query .= " AND I.device_id = '".$device['device_id']."'";
$ipv4_host = mysql_fetch_assoc(mysql_query($query)); $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['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['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>'; } 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><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('<tr bgcolor="'.$instance_bg.'">');
@@ -49,9 +48,8 @@ while($instance = mysql_fetch_assoc($query))
$i_a = 0; $i_a = 0;
$a_sql = "SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"; $a_sql = "SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'";
$a_query = mysql_query($a_sql); $a_query = mysql_query($a_sql);
while($area = mysql_fetch_assoc($a_query)) 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; } 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 = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospfIfAreaId` = '".$area['ospfAreaId']."'"),0);
@@ -62,7 +60,7 @@ while($instance = mysql_fetch_assoc($query))
echo(' <td class="list-large">'.$area['ospfAreaId'] . '</td>'); echo(' <td class="list-large">'.$area['ospfAreaId'] . '</td>');
echo(' <td>' . $enabled . '</td>'); echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $area_port_count . '('.$area_port_count_enabled.')</td>'); echo(' <td>' . $area_port_count . '('.$area_port_count_enabled.')</td>');
echo('</tr>'); echo('</tr>');
echo('<tr bgcolor="'.$area_bg.'">'); echo('<tr bgcolor="'.$area_bg.'">');
echo('<td colspan=7>'); echo('<td colspan=7>');
@@ -73,34 +71,38 @@ while($instance = mysql_fetch_assoc($query))
$i_p = $i_a + 1; $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_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); $p_query = mysql_query($p_sql);
while($ospfport = mysql_fetch_assoc($p_query)) while ($ospfport = mysql_fetch_assoc($p_query))
{ {
if (!is_integer($i_a/2))
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; } if (!is_integer($i_p/2)) { $port_bg = $list_colour_b_b; } else { $port_bg = $list_colour_b_a; }
} else { } else {
if (!is_integer($i_p/2)) { $port_bg = $list_colour_a_b; } else { $port_bg = $list_colour_a_a; } 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>';
}
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('<tr bgcolor="'.$port_bg.'">');
echo(' <td width=15></td>'); echo(' <td width=15></td>');
echo(' <td><strong>'. generate_port_link($ospfport) . '</strong></td>'); echo(' <td><strong>'. generate_port_link($ospfport) . '</strong></td>');
echo(' <td>' . $port_enabled . '</td>'); echo(' <td>' . $port_enabled . '</td>');
echo(' <td>' . $ospfport['ospfIfType'] . '</td>'); echo(' <td>' . $ospfport['ospfIfType'] . '</td>');
echo(' <td>' . $ospfport['ospfIfState'] . '</td>'); echo(' <td>' . $ospfport['ospfIfState'] . '</td>');
echo('</tr>'); echo('</tr>');
$i_p++; $i_p++;
} }
echo('</table>'); echo('</table>');
echo('</td>'); echo('</td>');
echo('</tr>'); echo('</tr>');
$i_a++; $i_a++;
} ### End loop areas } ### End loop areas
echo('</table>'); echo('</table>');
@@ -108,7 +110,6 @@ while($instance = mysql_fetch_assoc($query))
echo('</tr>'); echo('</tr>');
$i_i++; $i_i++;
} ### End loop instances } ### End loop instances
echo('</table>'); echo('</table>');

View File

@@ -9,9 +9,8 @@ echo('<table width=100%>');
#### Loop Instances #### Loop Instances
while($instance = mysql_fetch_assoc($query)) while ($instance = mysql_fetch_assoc($query))
{ {
if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; } 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); $area_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"),0);
@@ -22,9 +21,9 @@ while($instance = mysql_fetch_assoc($query))
$query .= " AND I.device_id = '".$device['device_id']."'"; $query .= " AND I.device_id = '".$device['device_id']."'";
$ipv4_host = mysql_fetch_assoc(mysql_query($query)); $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['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['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>'; } 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><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('<tr bgcolor="'.$instance_bg.'">');
@@ -37,9 +36,7 @@ while($instance = mysql_fetch_assoc($query))
echo(' <td>' . ($neighbour_count+0) . '</td>'); echo(' <td>' . ($neighbour_count+0) . '</td>');
echo('</tr>'); echo('</tr>');
$i_i++; $i_i++;
} ### End loop instances } ### End loop instances
echo('</table>'); echo('</table>');

View File

@@ -21,7 +21,6 @@ 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; } if (!$_GET['opta']) { $_GET['opta'] = $type; }
echo($sep); echo($sep);

View File

@@ -142,14 +142,12 @@ else
$afi = $afisafi['afi']; $afi = $afisafi['afi'];
$safi = $afisafi['safi']; $safi = $afisafi['safi'];
$this_afisafi = $afi.$safi; $this_afisafi = $afi.$safi;
#$peer['afi'] .= $sep . $config['afi'][$afi][$safi]; ##### CLEAN ME UP, I AM MESSY AND I SMELL OF CHEESE! FIXME!
$peer['afi'] .= $sep . $afi .".".$safi; $peer['afi'] .= $sep . $afi .".".$safi;
$sep = "<br />"; $sep = "<br />";
$peer['afisafi'][$this_afisafi] = 1; ## Build a list of valid AFI/SAFI for this peer $peer['afisafi'][$this_afisafi] = 1; ## Build a list of valid AFI/SAFI for this peer
} }
unset($sep); unset($sep);
echo(" <td></td> echo(" <td></td>
<td width=150>" . $localaddresslink . "<br />".generate_device_link($peer, shorthost($peer['hostname']), 'routing/bgp/')."</td> <td width=150>" . $localaddresslink . "<br />".generate_device_link($peer, shorthost($peer['hostname']), 'routing/bgp/')."</td>
<td width=30><b>&#187;</b></td> <td width=30><b>&#187;</b></td>

View File

@@ -10,9 +10,8 @@ echo('<tr><th>Device</th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</
#### Loop Instances #### Loop Instances
while($instance = mysql_fetch_assoc($query)) while ($instance = mysql_fetch_assoc($query))
{ {
if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; } if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; }
$device = device_by_id_cache($instance['device_id']); $device = device_by_id_cache($instance['device_id']);
@@ -26,9 +25,9 @@ while($instance = mysql_fetch_assoc($query))
$ip_query .= " AND I.device_id = '".$device['device_id']."'"; $ip_query .= " AND I.device_id = '".$device['device_id']."'";
$ipv4_host = mysql_fetch_assoc(mysql_query($ip_query)); $ipv4_host = mysql_fetch_assoc(mysql_query($ip_query));
if($instance['ospfAdminStat'] == "enabled") { $enabled = '<span style="color: #00aa00">enabled</span>'; } else { $enabled = '<span style="color: #aaaaaa">disabled</span>'; } 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['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>'; } if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span style="color: #00aa00">yes</span>'; } else { $asbr = '<span style="color: #aaaaaa">no</span>'; }
echo('<tr bgcolor="'.$instance_bg.'">'); echo('<tr bgcolor="'.$instance_bg.'">');
echo(' <td class="list-large">'.generate_device_link($device, 0, "routing/ospf/"). '</td>'); echo(' <td class="list-large">'.generate_device_link($device, 0, "routing/ospf/"). '</td>');
@@ -42,7 +41,6 @@ while($instance = mysql_fetch_assoc($query))
echo('</tr>'); echo('</tr>');
$i_i++; $i_i++;
} ### End loop instances } ### End loop instances
echo('</table>'); echo('</table>');

View File

@@ -137,7 +137,7 @@ else
{ {
$afi = $peer_afi['afi']; $afi = $peer_afi['afi'];
$safi = $peer_afi['safi']; $safi = $peer_afi['safi'];
if ($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); } if ($debug) { echo("$afi $safi\n"); }
if ($device['os_group'] == "ios") if ($device['os_group'] == "ios")
{ {

View File

@@ -6,14 +6,6 @@
# YES, THAT MEANS YOU # # YES, THAT MEANS YOU #
######################################################### #########################################################
## AFI / SAFI pairs for BGP (and other stuff, perhaps)
$config['afi']['ipv4']['unicast'] = "IPv4";
$config['afi']['ipv4']['multiicast'] = "IPv4 Multicast";
$config['afi']['ipv4']['vpn'] = "VPNv4";
$config['afi']['ipv6']['unicast'] = "IPv6";
$config['afi']['ipv6']['multicast'] = "IPv6 Multicast";
$config['afi']['ipv4']['vpn'] = "VPNv6";
$config['os']['default']['over'][0]['graph'] = "device_processor"; $config['os']['default']['over'][0]['graph'] = "device_processor";
$config['os']['default']['over'][0]['text'] = "Processor Usage"; $config['os']['default']['over'][0]['text'] = "Processor Usage";
$config['os']['default']['over'][1]['graph'] = "device_mempool"; $config['os']['default']['over'][1]['graph'] = "device_mempool";
@@ -23,7 +15,6 @@ $os_group = "unix";
$config['os_group'][$os_group]['type'] = "server"; $config['os_group'][$os_group]['type'] = "server";
$config['os_group'][$os_group]['processor_stacked'] = 1; $config['os_group'][$os_group]['processor_stacked'] = 1;
$os = "generic"; $os = "generic";
$config['os'][$os]['text'] = "Generic Device"; $config['os'][$os]['text'] = "Generic Device";
@@ -714,7 +705,8 @@ $config['os'][$os]['icon'] = "tripplite";
foreach($config['os'] as $this_os => $blah) foreach($config['os'] as $this_os => $blah)
{ {
if (isset($config['os'][$this_os]['group'])){ if (isset($config['os'][$this_os]['group']))
{
$this_os_group = $config['os'][$this_os]['group']; $this_os_group = $config['os'][$this_os]['group'];
if (isset($config['os_group'][$this_os_group])) if (isset($config['os_group'][$this_os_group]))
{ {
@@ -729,8 +721,6 @@ foreach($config['os'] as $this_os => $blah)
} }
} }
$device_types = array('server', 'network', 'firewall', 'workstation', 'printer', 'power', 'environment');
### Graph Types ### Graph Types
$config['graph_sections'] = array('system', 'firewall', 'netstats', 'wireless', 'storage'); $config['graph_sections'] = array('system', 'firewall', 'netstats', 'wireless', 'storage');
@@ -887,7 +877,6 @@ if (isset($config['enable_printers']) && $config['enable_printers'])
} }
############################## ##############################
# No changes below this line # # No changes below this line #
############################## ##############################