more migration to new URL system

git-svn-id: http://www.observium.org/svn/observer/trunk@2492 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-09-18 13:11:04 +00:00
parent 95a287baa7
commit 7584bba741
24 changed files with 410 additions and 432 deletions

View File

@ -1,5 +1,9 @@
<?php
function generate_link($text, $vars, $new_vars = array())
{
return '<a href="'.generate_url($vars, $new_vars).'">'.$text.'</a>';
}
function generate_url($vars, $new_vars = array())
@ -52,12 +56,12 @@ function get_percentage_colours($percentage)
}
function generate_device_url($device, $linksuffix="")
function generate_device_url($device, $vars=array())
{
return "device/" . $device['device_id'] . "/" . $linksuffix;
return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars);
}
function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0)
function generate_device_link($device, $text=0, $vars=array(), $start=0, $end=0)
{
global $config;
@ -80,7 +84,8 @@ function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0
$graphs = $config['os']['default']['over'];
}
$url = generate_device_url($device, $linksuffix);
$url = generate_device_url($device, $vars);
$contents = "<div class=list-large>".$device['hostname'];
if ($device['hardware']) { $contents .= " - ".$device['hardware']; }
$contents .= "</div>";
@ -345,8 +350,9 @@ function generate_port_link($args, $text = NULL, $type = NULL)
}
}
function generate_port_url($args) {
return $url = "device/".$args['device_id']."/port/" . $args['interface_id'] . "/";
function generate_port_url($port, $vars=array())
{
return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'section' => 'port', 'port' => $port['interface_id']), $vars);
}
function generate_port_thumbnail($args)

View File

@ -2,40 +2,40 @@
# This file prints a table row for each interface
$interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname'];
$port['device_id'] = $device['device_id'];
$port['hostname'] = $device['hostname'];
$if_id = $interface['interface_id'];
$if_id = $port['interface_id'];
$interface = ifLabel($interface);
$port = ifLabel($port);
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if ($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0)
if ($port['ifInErrors_delta'] > 0 || $port['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($port,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>","port_errors");
} else {
$error_img = "";
}
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/".$port['interface_id']."/'\" style='cursor: pointer;'>
<td valign=top width=350>");
echo(" <span class=list-large>
" . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . "
</span><br /><span class=interface-desc>".$interface['ifAlias']."</span>");
" . generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) . "
</span><br /><span class=interface-desc>".$port['ifAlias']."</span>");
if ($interface['ifAlias']) { echo("<br />"); }
if ($port['ifAlias']) { echo("<br />"); }
unset ($break);
if ($port_details)
{
foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ?", array($interface['interface_id'])) as $ip)
foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip)
{
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 = ",";
}
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($interface['interface_id'])) as $ip6);
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip6);
{
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 = ",";
@ -47,48 +47,48 @@ echo("</span>");
$width="120"; $height="40"; $from = $config['time']['day'];
echo("</td><td width=135>");
echo(formatRates($interface['ifInOctets_rate'] * 8)." <img class='optionicon' src='images/icons/arrow_updown.png' /> ".formatRates($interface['ifOutOctets_rate'] * 8));
echo(formatRates($port['ifInOctets_rate'] * 8)." <img class='optionicon' src='images/icons/arrow_updown.png' /> ".formatRates($port['ifOutOctets_rate'] * 8));
echo("<br />");
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
$port['graph_type'] = "port_bits";
echo(generate_port_link($port, "<img src='graph.php?type=".$port['graph_type']."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $port['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate']));
echo("".formatRates($port['adslAturChanCurrTxRate']) . "/". formatRates($port['adslAtucChanCurrTxRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_speed";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
$port['graph_type'] = "port_adsl_speed";
echo(generate_port_link($port, "<img src='graph.php?type=".$port['graph_type']."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $port['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate']));
echo("".formatRates($port['adslAturCurrAttainableRate']) . "/". formatRates($port['adslAtucCurrAttainableRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_attainable";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
$port['graph_type'] = "port_adsl_attainable";
echo(generate_port_link($port, "<img src='graph.php?type=".$port['graph_type']."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $port['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB");
echo("".$port['adslAturCurrAtn'] . "dB/". $port['adslAtucCurrAtn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_attenuation";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
$port['graph_type'] = "port_adsl_attenuation";
echo(generate_port_link($port, "<img src='graph.php?type=".$port['graph_type']."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $port['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB");
echo("".$port['adslAturCurrSnrMgn'] . "dB/". $port['adslAtucCurrSnrMgn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_snr";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
$port['graph_type'] = "port_adsl_snr";
echo(generate_port_link($port, "<img src='graph.php?type=".$port['graph_type']."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $port['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm");
echo("".$port['adslAturCurrOutputPwr'] . "dBm/". $port['adslAtucCurrOutputPwr'] . "dBm");
echo("<br />");
$interface['graph_type'] = "port_adsl_power";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
$port['graph_type'] = "port_adsl_power";
echo(generate_port_link($port, "<img src='graph.php?type=".$port['graph_type']."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$config['time']['now']."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $port['graph_type']));
# if ($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
# if ($port[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $port['ifDuplex'] . "</span>"); } else { echo("-"); }
# echo("</td><td width=150>");
# echo($port_adsl['adslLineCoding']."/".$port_adsl['adslLineType']);

View File

@ -5,7 +5,7 @@ global $config;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $interface['interface_id'];
$graph_array['id'] = $port['interface_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");

View File

@ -2,12 +2,12 @@
# This file prints a table row for each interface
$interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname'];
$port['device_id'] = $device['device_id'];
$port['hostname'] = $device['hostname'];
$if_id = $interface['interface_id'];
$if_id = $port['interface_id'];
$interface = ifLabel($interface);
$port = ifLabel($port);
if($int_colour)
{
@ -16,36 +16,36 @@ if($int_colour)
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
}
$port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `interface_id` = ?", array($interface['interface_id']));
$port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `interface_id` = ?", array($port['interface_id']));
if ($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0)
if ($port['ifInErrors_delta'] > 0 || $port['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($port, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", "port_errors");
} else { $error_img = ""; }
if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `interface_id` = ?", array($interface['interface_id'])))
if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `interface_id` = ?", array($port['interface_id'])))
{
$mac = "<a href='device/".$interface['device_id']."/port/".$interface['interface_id']."/macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'></a>";
$mac = "<a href='device/".$port['device_id']."/port/".$port['interface_id']."/macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'></a>";
} else { $mac = ""; }
echo("<tr style=\"background-color: $row_colour;\" 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;'>
echo("<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" onclick=\"location.href='device/".$device['device_id']."/port/".$port['interface_id']."/'\" style='cursor: pointer;'>
<td valign=top width=350>");
echo(" <span class=list-large>
" . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . " $error_img $mac
</span><br /><span class=interface-desc>".$interface['ifAlias']."</span>");
" . generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) . " $error_img $mac
</span><br /><span class=interface-desc>".$port['ifAlias']."</span>");
if ($interface['ifAlias']) { echo("<br />"); }
if ($port['ifAlias']) { echo("<br />"); }
unset ($break);
if ($port_details)
{
foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ?", array($interface['interface_id'])) as $ip)
foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip)
{
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 = "<br />";
}
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($interface['interface_id'])) as $ip6)
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($port['interface_id'])) as $ip6)
{
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 = "<br />";
@ -58,42 +58,42 @@ echo("</td><td width=100>");
if ($port_details)
{
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=port_bits&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$interface['graph_type'] = "port_upkts";
echo(generate_port_link($interface, "<img src='graph.php?type=port_upkts&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$interface['graph_type'] = "port_errors";
echo(generate_port_link($interface, "<img src='graph.php?type=port_errors&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$port['graph_type'] = "port_bits";
echo(generate_port_link($port, "<img src='graph.php?type=port_bits&amp;id=".$port['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$port['graph_type'] = "port_upkts";
echo(generate_port_link($port, "<img src='graph.php?type=port_upkts&amp;id=".$port['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
$port['graph_type'] = "port_errors";
echo(generate_port_link($port, "<img src='graph.php?type=port_errors&amp;id=".$port['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
}
echo("</td><td width=120>");
if ($interface['ifOperStatus'] == "up")
if ($port['ifOperStatus'] == "up")
{
$interface['in_rate'] = $interface['ifInOctets_rate'] * 8;
$interface['out_rate'] = $interface['ifOutOctets_rate'] * 8;
$in_perc = @round($interface['in_rate']/$interface['ifSpeed']*100);
$out_perc = @round($interface['in_rate']/$interface['ifSpeed']*100);
echo("<img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>".formatRates($interface['in_rate'])."<br />
<img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>".formatRates($interface['out_rate']) . "<br />
<img src='images/icons/arrow_pps_in.png' align=absmiddle> ".format_bi($interface['ifInUcastPkts_rate'])."pps</span><br />
<img src='images/icons/arrow_pps_out.png' align=absmiddle> ".format_bi($interface['ifOutUcastPkts_rate'])."pps</span>");
$port['in_rate'] = $port['ifInOctets_rate'] * 8;
$port['out_rate'] = $port['ifOutOctets_rate'] * 8;
$in_perc = @round($port['in_rate']/$port['ifSpeed']*100);
$out_perc = @round($port['in_rate']/$port['ifSpeed']*100);
echo("<img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>".formatRates($port['in_rate'])."<br />
<img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>".formatRates($port['out_rate']) . "<br />
<img src='images/icons/arrow_pps_in.png' align=absmiddle> ".format_bi($port['ifInUcastPkts_rate'])."pps</span><br />
<img src='images/icons/arrow_pps_out.png' align=absmiddle> ".format_bi($port['ifOutUcastPkts_rate'])."pps</span>");
}
echo("</td><td width=75>");
if ($interface['ifSpeed']) { echo("<span class=box-desc>".humanspeed($interface['ifSpeed'])."</span>"); }
if ($port['ifSpeed']) { echo("<span class=box-desc>".humanspeed($port['ifSpeed'])."</span>"); }
echo("<br />");
if ($interface[ifDuplex] != "unknown") { echo("<span class=box-desc>" . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
if ($port[ifDuplex] != "unknown") { echo("<span class=box-desc>" . $port['ifDuplex'] . "</span>"); } else { echo("-"); }
if ($device['os'] == "ios" || $device['os'] == "iosxe")
{
if ($interface['ifTrunk']) {
echo("<span class=box-desc><span class=red>" . $interface['ifTrunk'] . "</span></span>");
} elseif ($interface['ifVlan']) {
echo("<span class=box-desc><span class=blue>VLAN " . $interface['ifVlan'] . "</span></span>");
} elseif ($interface['ifVrf']) {
$vrf = dbFetchRow("SELECT * FROM vrfs WHERE vrf_id = ?", array($interface['ifVrf']));
if ($port['ifTrunk']) {
echo("<span class=box-desc><span class=red>" . $port['ifTrunk'] . "</span></span>");
} elseif ($port['ifVlan']) {
echo("<span class=box-desc><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>");
} elseif ($port['ifVrf']) {
$vrf = dbFetchRow("SELECT * FROM vrfs WHERE vrf_id = ?", array($port['ifVrf']));
echo("<span style='color: green;'>" . $vrf['vrf_name'] . "</span>");
}
}
@ -112,18 +112,18 @@ if ($port_adsl['adslLineCoding'])
echo("SNR:".$port_adsl['adslAtucCurrSnrMgn'] . "dB/". $port_adsl['adslAturCurrSnrMgn']. "dB");
} else {
echo("</td><td width=150>");
if ($interface['ifType'] && $interface['ifType'] != "") { echo("<span class=box-desc>" . fixiftype($interface['ifType']) . "</span>"); } else { echo("-"); }
if ($port['ifType'] && $port['ifType'] != "") { echo("<span class=box-desc>" . fixiftype($port['ifType']) . "</span>"); } else { echo("-"); }
echo("<br />");
if ($ifHardType && $ifHardType != "") { echo("<span class=box-desc>" . $ifHardType . "</span>"); } else { echo("-"); }
echo("</td><td width=150>");
if ($interface['ifPhysAddress'] && $interface['ifPhysAddress'] != "") { echo("<span class=box-desc>" . formatMac($interface['ifPhysAddress']) . "</span>"); } else { echo("-"); }
if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") { echo("<span class=box-desc>" . formatMac($port['ifPhysAddress']) . "</span>"); } else { echo("-"); }
echo("<br />");
if ($interface['ifMtu'] && $interface['ifMtu'] != "") { echo("<span class=box-desc>MTU " . $interface['ifMtu'] . "</span>"); } else { echo("-"); }
if ($port['ifMtu'] && $port['ifMtu'] != "") { echo("<span class=box-desc>MTU " . $port['ifMtu'] . "</span>"); } else { echo("-"); }
}
echo("</td>");
echo("<td width=375 valign=top class=interface-desc>");
if (strpos($interface['label'], "oopback") === false && !$graph_type)
if (strpos($port['label'], "oopback") === false && !$graph_type)
{
foreach(dbFetchRows("SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_interface_id = ? AND L.remote_interface_id = I.interface_id AND I.device_id = D.device_id", array($if_id)) as $link)
{
@ -137,7 +137,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type)
if ($port_details)
{ ## Show which other devices are on the same subnet as this interface
foreach (dbFetchRows("SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = ? AND `ipv4_address` NOT LIKE '127.%'", array($interface['interface_id'])) as $net)
foreach (dbFetchRows("SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = ? AND `ipv4_address` NOT LIKE '127.%'", array($port['interface_id'])) as $net)
{
$ipv4_network_id = $net['ipv4_network_id'];
$sql = "SELECT I.interface_id FROM ipv4_addresses AS A, ports AS I, devices AS D
@ -157,7 +157,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type)
}
}
foreach (dbFetchRows("SELECT ipv6_network_id FROM ipv6_addresses WHERE interface_id = ?", array($interface['interface_id'])) as $net)
foreach (dbFetchRows("SELECT ipv6_network_id FROM ipv6_addresses WHERE interface_id = ?", array($port['interface_id'])) as $net)
{
$ipv6_network_id = $net['ipv6_network_id'];
$sql = "SELECT I.interface_id FROM ipv6_addresses AS A, ports AS I, devices AS D
@ -197,7 +197,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type)
# unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
}
foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `interface_id` = ?", array($interface['interface_id'])) as $pseudowire)
foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `interface_id` = ?", array($port['interface_id'])) as $pseudowire)
{
#`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
$pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id']));
@ -208,20 +208,20 @@ foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `interface_id` = ?", arr
$br = "<br />";
}
foreach(dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($interface['ifIndex'], $device['device_id'])) as $member)
foreach(dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member)
{
echo("$br<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . " (PAgP)</strong>");
$br = "<br />";
}
if ($interface['pagpGroupIfIndex'] && $interface['pagpGroupIfIndex'] != $interface['ifIndex'])
if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex'])
{
$parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($interface['pagpGroupIfIndex'], $device['device_id']));
$parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id']));
echo("$br<img src='images/16/bricks.png' align=absmiddle> <strong>" . generate_port_link($parent) . " (PAgP)</strong>");
$br = "<br />";
}
foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? and `device_id` = ?", array($interface['ifIndex'], $device['device_id'])) as $higher_if)
foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if)
{
if($higher_if['interface_id_high'])
{
@ -231,7 +231,7 @@ foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? an
}
}
foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? and `device_id` = ?", array($interface['ifIndex'], $device['device_id'])) as $lower_if)
foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if)
{
if($lower_if['interface_id_low'])
{
@ -251,9 +251,9 @@ echo("</td></tr>");
if ($graph_type == "etherlike")
{
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($interface['ifIndex']) . "-dot3.rrd";
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($port['ifIndex']) . "-dot3.rrd";
} else {
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($interface['ifIndex']) . ".rrd";
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($port['ifIndex']) . ".rrd";
}
if ($graph_type && is_file($graph_file))

View File

@ -1,27 +1,25 @@
<?php
if ($_GET['opta']) { $_GET['opta'] = mres($_GET['opta']); }
if ($_GET['optb'] == "port" && is_numeric($_GET['opta']) && port_permitted($_GET['optc']))
if ($vars['tab'] == "port" && is_numeric($vars['device']) && port_permitted($vars['port']))
{
$check_device = get_device_id_by_interface_id($_GET['opta']);
$check_device = get_device_id_by_interface_id($vars['device']);
$permit_ports = 1;
}
if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (device_permitted($vars['device']) || $check_device == $vars['device'])
{
$selected['iface'] = "selected";
$section = str_replace(".", "", mres($_GET['optb']));
$tab = str_replace(".", "", mres($vars['tab']));
if (!$section)
if (!$tab)
{
$section = "overview";
$tab = "overview";
}
$select[$section] = "selected";
$select[$tab] = "selected";
$device = device_by_id_cache($_GET['opta']);
$device = device_by_id_cache($vars['device']);
$attribs = get_dev_attribs($device['device_id']);
if ($config['os'][$device['os']]['group']) { $device['os_group'] = $config['os'][$device['os']]['group']; }
@ -40,14 +38,14 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
{
echo('
<li class="' . $select['overview'] . '">
<a href="device/' . $device['device_id'] . '/overview/">
<a href="'.generate_device_url($device, array('tab' => 'overview')).'">
<img src="images/16/server_lightning.png" align="absmiddle" border="0"> Overview
</a>
</li>');
}
echo('<li class="' . $select['graphs'] . '">
<a href="device/' . $device['device_id'] . '/graphs/">
<a href="'.generate_device_url($device, array('tab' => 'graphs')).'">
<img src="images/16/server_chart.png" align="absmiddle" border="0"> Graphs
</a>
</li>');
@ -61,7 +59,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if ($health)
{
echo('<li class="' . $select['health'] . '">
<a href="device/' . $device['device_id'] . '/health/">
<a href="'.generate_device_url($device, array('tab' => 'health')).'">
<img src="images/icons/sensors.png" align="absmiddle" border="0" /> Health
</a>
</li>');
@ -70,7 +68,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (@dbFetchCell("SELECT COUNT(app_id) FROM applications WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['apps'] . '">
<a href="device/' . $device['device_id'] . '/apps/">
<a href="'.generate_device_url($device, array('tab' => 'apps')).'">
<img src="images/icons/apps.png" align="absmiddle" border="0" /> Apps
</a>
</li>');
@ -79,7 +77,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/"))
{
echo('<li class="' . $select['collectd'] . '">
<a href="device/' . $device['device_id'] . '/collectd/">
<a href="'.generate_device_url($device, array('tab' => 'collectd')).'">
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> CollectD
</a>
</li>');
@ -88,7 +86,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (@dbFetchCell("SELECT COUNT(interface_id) FROM ports WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['ports'] . $select['port'] . '">
<a href="device/' . $device['device_id'] . '/ports/' .$config['ports_page_default']. '">
<a href="'.generate_device_url($device, array('tab' => 'ports')). '">
<img src="images/16/connect.png" align="absmiddle" border="0" /> Ports
</a>
</li>');
@ -97,7 +95,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (@dbFetchCell("SELECT COUNT(vlan_id) FROM vlans WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['vlans'] . '">
<a href="device/' . $device['device_id'] . '/vlans/">
<a href="'.generate_device_url($device, array('tab' => 'vlans')).'">
<img src="images/16/vlans.png" align="absmiddle" border="0" /> VLANs
</a>
</li>');
@ -106,7 +104,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (@dbFetchCell("SELECT COUNT(id) FROM vminfo WHERE device_id = '" . $device["device_id"] . "'") > '0')
{
echo('<li class="' . $select['vm'] . '">
<a href="device/' . $device['device_id'] . '/vm/">
<a href="'.generate_device_url($device, array('tab' => 'vm')).'">
<img src="images/16/server_cog.png" align="absmiddle" border="0" /> Virtual Machines
</a>
</li>');
@ -132,7 +130,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (is_array($routing_tabs))
{
echo('<li class="' . $select['routing'] . '">
<a href="device/' . $device['device_id'] . '/routing/">
<a href="'.generate_device_url($device, array('tab' => 'routing')).'">
<img src="images/16/arrow_branch.png" align="absmiddle" border="0" /> Routing
</a>
</li>');
@ -142,7 +140,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
{
$discovery_links = TRUE;
echo('<li class="' . $select['map'] . '">
<a href="device/' . $device['device_id'] . '/map/">
<a href="'.generate_device_url($device, array('tab' => 'map')).'">
<img src="images/16/chart_organisation.png" align="absmiddle" border="0" /> Map
</a>
</li>');
@ -151,7 +149,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if ($config['enable_inventory'] && @dbFetchCell("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."'") > '0')
{
echo('<li class="' . $select['entphysical'] . '">
<a href="device/' . $device['device_id'] . '/entphysical/">
<a href="'.generate_device_url($device, array('tab' => 'entphysical')).'">
<img src="images/16/bricks.png" align="absmiddle" border="0" /> Inventory
</a>
</li>');
@ -159,7 +157,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
elseif (device_permitted($device['device_id']) && $config['enable_inventory'] && @dbFetchCell("SELECT * FROM `hrDevice` WHERE device_id = '".$device['device_id']."'") > '0')
{
echo('<li class="' . $select['hrdevice'] . '">
<a href="device/' . $device['device_id'] . '/hrdevice/">
<a href="'.generate_device_url($device, array('tab' => 'hrdevice')).'">
<img src="images/16/bricks.png" align="absmiddle" border="0" /> Inventory
</a>
</li>');
@ -168,7 +166,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (dbFetchCell("SELECT COUNT(service_id) FROM services WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['services'] . '">
<a href="device/' . $device['device_id'] . '/services/">
<a href="'.generate_device_url($device, array('tab' => 'services')).'">
<img src="images/icons/services.png" align="absmiddle" border="0" /> Services
</a>
</li>');
@ -177,7 +175,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (@dbFetchCell("SELECT COUNT(toner_id) FROM toner WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['toner'] . '">
<a href="device/' . $device['device_id'] . '/toner/">
<a href="'.generate_device_url($device, array('tab' => 'toner')).'">
<img src="images/icons/toner.png" align="absmiddle" border="0" /> Toner
</a>
</li>');
@ -186,7 +184,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (device_permitted($device['device_id']))
{
echo('<li class="' . $select['events'] . '">
<a href="device/' . $device['device_id'] . '/events/">
<a href="'.generate_device_url($device, array('tab' => 'events')).'">
<img src="images/16/report_magnify.png" align="absmiddle" border="0" /> Events
</a>
</li>');
@ -195,7 +193,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if ($config['enable_syslog'])
{
echo('<li class="' . $select['syslog'] . '">
<a href="device/' . $device['device_id'] . '/syslog/">
<a href="'.generate_device_url($device, array('tab' => 'syslog')).'">
<img src="images/16/printer.png" align="absmiddle" border="0" /> Syslog
</a>
</li>');
@ -214,7 +212,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if ($device_config_file)
{
echo('<li class="' . $select['showconfig'] . '">
<a href="device/' . $device['device_id'] . '/showconfig/">
<a href="'.generate_device_url($device, array('tab' => 'showconfig')).'/">
<img src="images/16/page_white_text.png" align="absmiddle" border="0" /> Config
</a>
</li>');
@ -237,7 +235,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if ($nfsen_rrd_file)
{
echo('<li class="' . $select['nfsen'] . '">
<a href="device/' . $device['device_id'] . '/nfsen/">
<a href="'.generate_device_url($device, array('tab' => 'nfsen')).'">
<img src="images/16/rainbow.png" align="absmiddle" border="0" /> Netflow
</a>
</li>');
@ -247,7 +245,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if ($_SESSION['userlevel'] >= "7")
{
echo('<li class="' . $select['edit'] . '" style="text-align: right;">
<a href="device/' . $device['device_id'] . '/edit/">
<a href="'.generate_device_url($device, array('tab' => 'edit')).'">
<img src="images/16/server_edit.png" align="absmiddle" border="0" /> Settings
</a>
</li>');
@ -255,10 +253,10 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
echo("</ul>");
}
if(device_permitted($device['device_id']) || $check_device == $_GET['opta']) {
if(device_permitted($device['device_id']) || $check_device == $vars['device']) {
echo('<div class="contentstyle">');
include("pages/device/".mres(basename($section)).".inc.php");
include("pages/device/".mres(basename($tab)).".inc.php");
echo("</div>");
} else {

View File

@ -6,31 +6,35 @@ echo("<span style='font-weight: bold;'>Apps</span> &#187; ");
unset($sep);
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'apps');
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $app)
{
echo($sep);
if (!$_GET['optc']) { $_GET['optc'] = $app['app_type']; }
if (!$vars['app']) { $vars['app'] = $app['app_type']; }
if ($_GET['optc'] == $app['app_type'])
if ($vars['app'] == $app['app_type'])
{
echo("<span class='pagemenu-selected'>");
#echo('<img src="images/icons/'.$app['app_type'].'.png" class="optionicon" />');
} else {
#echo('<img src="images/icons/greyscale/'.$app['app_type'].'.png" class="optionicon" />');
}
echo("<a href='device/".$device['device_id']."/apps/" . $app['app_type'] . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . $app['app_type'] ."</a>");
if ($_GET['optc'] == $app['app_type']) { echo("</span>"); }
echo(generate_link($app['app_type'],$link_array,array('app'=>$app['app_type'])));
if ($vars['app'] == $app['app_type']) { echo("</span>"); }
$sep = " | ";
}
print_optionbar_end();
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?", array($device['device_id'], $_GET['optc']));
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?", array($device['device_id'], $vars['app']));
if (is_file("pages/device/apps/".mres($_GET['optc']).".inc.php"))
if (is_file("pages/device/apps/".mres($vars['app']).".inc.php"))
{
include("pages/device/apps/".mres($_GET['optc']).".inc.php");
include("pages/device/apps/".mres($vars['app']).".inc.php");
}
?>

View File

@ -48,14 +48,18 @@ function dhtml_response_list(&$items, $method) {
print_optionbar_start();
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'collectd');
$plugins = collectd_list_plugins($device['hostname']);
unset($sep);
foreach ($plugins as &$plugin) {
if (!$_GET['optc']) { $_GET['optc'] = $plugin; }
if (!$vars['plugin']) { $vars['plugin'] = $plugin; }
echo($sep);
if ($_GET['optc'] == $plugin) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='device/" . $device['device_id'] . "/collectd/" . $plugin . "/'>" . htmlspecialchars($plugin) ."</a>");
if ($_GET['optc'] == $plugin) { echo("</span>"); }
if ($vars['plugin'] == $plugin) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link(htmlspecialchars($plugin),$link_array,array('plugin'=>$plugin)));
if ($vars['plugin'] == $plugin) { echo("</span>"); }
$sep = ' | ';
}
unset ($sep);
@ -64,13 +68,13 @@ print_optionbar_end();
$i=0;
$pinsts = collectd_list_pinsts($device['hostname'], $_GET['optc']);
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
$types = collectd_list_types($device['hostname'], $_GET['optc'], $instance);
$types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
foreach ($types as &$type) {
$typeinstances = collectd_list_tinsts($device['hostname'], $_GET['optc'], $instance, $type);
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); }
@ -81,16 +85,16 @@ print_optionbar_end();
echo('<div style="background-color: '.$row_colour.';">');
echo('<div class="graphhead" style="padding:4px 0px 0px 8px;">');
if ($tinst) {
echo($_GET['optc']." $instance - $type - $tinst");
echo($vars['plugin']." $instance - $type - $tinst");
} else {
echo($_GET['optc']." $instance - $type");
echo($vars['plugin']." $instance - $type");
}
echo("</div>");
$graph_array['type'] = "device_collectd";
$graph_array['id'] = $device['device_id'];
$graph_array['c_plugin'] = $_GET['optc'];
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst;

View File

@ -1,8 +1,12 @@
<?php
### Sections are printed in the order they exist in $config['graph_sections']
### Sections are printed in the order they exist in $config['graph_tabs']
### Graphs are printed in the order they exist in $config['graph_types']
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'graphs');
$bg="#ffffff";
echo('<div style="clear: both;">');
@ -15,15 +19,15 @@ $sep = "";
foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ?", array($device['device_id'])) as $graph)
{
$section = $config['graph_types']['device'][$graph['graph']]['section'];
$graph_enable[$section][$graph['graph']] = $graph['graph'];
$tab = $config['graph_types']['device'][$graph['graph']]['tab'];
$graph_enable[$tab][$graph['graph']] = $graph['graph'];
}
foreach ($config['graph_sections'] as $section)
foreach ($config['graph_tabs'] as $tab)
{
if (isset($graph_enable) && is_array($graph_enable[$section]))
if (isset($graph_enable) && is_array($graph_enable[$tab]))
{
$type = strtolower($section);
$type = strtolower($tab);
if (!$_GET['optc']) { $_GET['optc'] = $type; }
echo($sep);
if ($_GET['optc'] == $type)

View File

@ -40,32 +40,35 @@ $type_text['frequency'] = "Frequency";
$type_text['current'] = "Current";
$type_text['power'] = "Power";
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'health');
print_optionbar_start();
echo("<span style='font-weight: bold;'>Health</span> &#187; ");
if (!$_GET['optc']) { $_GET['optc'] = "overview"; }
if (!$vars['metric']) { $vars['metric'] = "overview"; }
unset($sep);
foreach ($datas as $type)
{
echo($sep);
if ($_GET['optc'] == $type)
{
echo('<span class="pagemenu-selected">');
}
if ($vars['metric'] == $type)
{ echo('<span class="pagemenu-selected">'); }
echo("<a href='device/".$device['device_id']."/health/" . $type . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . $type_text[$type] ."</a>");
if ($_GET['optc'] == $type) { echo("</span>"); }
echo(generate_link($type_text[$type],$link_array,array('metric'=>$type)));
if ($vars['metric'] == $type) { echo("</span>"); }
$sep = " | ";
}
print_optionbar_end();
if (is_file("pages/device/health/".mres($_GET['optc']).".inc.php"))
if (is_file("pages/device/health/".mres($vars['metric']).".inc.php"))
{
include("pages/device/health/".mres($_GET['optc']).".inc.php");
include("pages/device/health/".mres($vars['metric']).".inc.php");
} else {
foreach ($datas as $type)
{

View File

@ -5,7 +5,7 @@ if ($ports['total'])
echo('<div style="background-color: #eeeeee; margin: 5px; padding: 5px;">');
$graph_array['height'] = "100";
$graph_array['width'] = "490";
$graph_array['width'] = "485";
$graph_array['to'] = $now;
$graph_array['id'] = $device['device_id'];
$graph_array['type'] = "device_bits";
@ -18,23 +18,10 @@ if ($ports['total'])
unset($link_array['height'], $link_array['width']);
$link = generate_url($link_array);
$graph_array['width'] = "210";
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic");
$content = "<div class=list-large>".$device['hostname']." - Device Traffic</div>";
$content .= "<div style=\'width: 850px\'>";
$graph_array['legend'] = "no";
$graph_array['width'] = "340";
$graph_array['from'] = $config['time']['day'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
$content .= "</div>";
echo(overlib_link($link, $graph, $content, NULL));
echo(overlib_link($link, $graph, $overlib_content, NULL));
echo(' <div style="height: 5px;"></div>');

View File

@ -1,25 +1,25 @@
<?php
if (!isset($_GET['optd']) ) { $_GET['optd'] = "graphs"; }
if (!isset($vars['view']) ) { $vars['view'] = "graphs"; }
$interface = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($_GET['optc']));
$port = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($vars['port']));
$port_details = 1;
$hostname = $device['hostname'];
$hostid = $device['interface_id'];
$ifname = $interface['ifDescr'];
$ifIndex = $interface['ifIndex'];
$speed = humanspeed($interface['ifSpeed']);
$ifname = $port['ifDescr'];
$ifIndex = $port['ifIndex'];
$speed = humanspeed($port['ifSpeed']);
$ifalias = $interface['name'];
$ifalias = $port['name'];
if ($interface['ifPhysAddress']) { $mac = "$interface[ifPhysAddress]"; }
if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; }
$color = "black";
if ($interface['ifAdminStatus'] == "down") { $status = "<span class='grey'>Disabled</span>"; }
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "down") { $status = "<span class='red'>Enabled / Disconnected</span>"; }
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "up") { $status = "<span class='green'>Enabled / Connected</span>"; }
if ($port['ifAdminStatus'] == "down") { $status = "<span class='grey'>Disabled</span>"; }
if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "<span class='red'>Enabled / Disconnected</span>"; }
if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "<span class='green'>Enabled / Connected</span>"; }
$i = 1;
$inf = fixifName($ifname);
@ -51,90 +51,95 @@ echo("<div style='clear: both;'>");
print_optionbar_start();
if ($_GET['optd'] == "graphs" || !$_GET['optd']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/'>Graphs</a>");
if ($_GET['optd'] == "graphs" || !$_GET['optd']) { echo("</span>"); }
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'port',
'port' => $port['interface_id']);
echo(" | ");
$menu_options['graphs'] = 'Graphs';
$menu_options['realtime'] = 'Real time'; ### FIXME CONDITIONAL
$menu_options['arp'] = 'ARP Table';
if ($_GET['optd'] == "realtime" || !$_GET['optd']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/'>Real Time</a>");
if ($_GET['optd'] == "realtime" || !$_GET['optd']) { echo("</span>"); }
if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$port['interface_id']."'") )
{ $menu_options['adsl'] = 'ADSL'; }
if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") )
{ $menu_options['pagp'] = 'PAgP'; }
if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$interface['interface_id']."'") )
$sep = "";
foreach ($menu_options as $option => $text)
{
echo(" | ");
if ($_GET['optd'] == "adsl") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/port/".$interface['interface_id']."/adsl/'>ADSL</a>");
if ($_GET['optd'] == "adsl") { echo("</span>"); }
echo($sep);
if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($text,$link_array,array('view'=>$option)));
if ($vars['view'] == $option) { echo("</span>"); }
$sep = " | ";
}
unset($sep);
echo(" | ");
if ($_GET['optd'] == "arp") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/arp/'>ARP Table</a>");
if ($_GET['optd'] == "arp") { echo("</span>"); }
if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".
$interface['ifIndex']."' and `device_id` = '".$device['device_id']."'") )
if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$port['interface_id']."'") > "0" )
{
echo(" | ");
if ($_GET['optd'] == "pagp") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/pagp/'>PAgP</a>");
if ($_GET['optd'] == "pagp") { echo("</span>"); }
}
echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type)));
if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'") > "0" )
{
echo(" | Mac Accounting : ");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && !$_GET['optf']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/'>Bits</a>");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && !$_GET['optf']) { echo("</span>"); }
if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits')));
if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo("</span>"); }
echo("(");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/thumbs/'>Mini</a>");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "thumbs") { echo("</span>"); }
if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits')));
if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo("</span>"); }
echo('|');
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "top10") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/top10/'>Top10</a>");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "top10") { echo("</span>"); }
if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits')));
if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo("</span>"); }
echo(") | ");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && !$_GET['optf']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/'>Packets</a>");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && !$_GET['optf']) { echo("</span>"); }
if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts')));
if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo("</span>"); }
echo("(");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && $_GET['optf'] == "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/thumbs/'>Mini</a>");
if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && $_GET['optf'] == "thumbs") { echo("</span>"); }
if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts')));
if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo("</span>"); }
echo('|');
if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts')));
if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo("</span>"); }
echo(")");
}
if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$interface['interface_id']."'") > "0" )
if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$port['interface_id']."'") > "0" )
{
### FIXME ATM VPs
echo(" | ATM VPs : ");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/bits/'>Bits</a>");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$port['interface_id']."/junose-atm-vp/bits/'>Bits</a>");
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo("</span>"); }
echo(" | ");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "packets") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/packets/'>Packets</a>");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$port['interface_id']."/junose-atm-vp/packets/'>Packets</a>");
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo("</span>"); }
echo(" | ");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "cells") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/cells/'>Cells</a>");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$port['interface_id']."/junose-atm-vp/cells/'>Cells</a>");
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo("</span>"); }
echo(" | ");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "errors") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/errors/'>Errors</a>");
if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$port['interface_id']."/junose-atm-vp/errors/'>Errors</a>");
if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo("</span>"); }
}
print_optionbar_end();
echo("<div style='margin: 5px;'>");
include("pages/device/port/".mres($_GET['optd']).".inc.php");
include("pages/device/port/".mres($vars['view']).".inc.php");
echo("</div>");
?>

View File

@ -1,6 +1,6 @@
<?php
if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . "-adsl.rrd"))
if (file_exists($config['rrd_dir'] . "/" . $device['hostname'] . "/port-". $port['ifIndex'] . "-adsl.rrd"))
{
$iid = $id;
echo("<div class=graphhead>ADSL Line Speed</div>");
@ -20,4 +20,4 @@ if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . "-ad
include("includes/print-interface-graphs.inc.php");
}
?>
?>

View File

@ -3,7 +3,7 @@
echo('<table border="0" cellspacing="0" cellpadding="5" width="100%">');
$i = "1";
foreach (dbFetchRows("SELECT * FROM ipv4_mac WHERE interface_id = ?", array($interface['interface_id'])) as $arp)
foreach (dbFetchRows("SELECT * FROM ipv4_mac WHERE interface_id = ?", array($port['interface_id'])) as $arp)
{
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
$arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($arp['ipv4_address']));

View File

@ -1,6 +1,6 @@
<?php
if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . ".rrd"))
if (file_exists($config['rrd_dir'] . "/" . $device['hostname'] . "/port-". $port['ifIndex'] . ".rrd"))
{
$iid = $id;
echo("<div class=graphhead>Interface Traffic</div>");
@ -19,7 +19,7 @@ if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . ".rr
$graph_type = "port_errors";
include("includes/print-interface-graphs.inc.php");
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . $interface['ifIndex'] . "-dot3.rrd"))
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . $port['ifIndex'] . "-dot3.rrd"))
{
echo("<div class=graphhead>Ethernet Errors</div>");
$graph_type = "port_etherlike";
@ -27,4 +27,4 @@ if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . ".rr
}
}
?>
?>

View File

@ -1,119 +1,107 @@
<?php
## FIXME - REWRITE!
$hostname = $device['hostname'];
$hostid = $device['interface_id'];
$ifname = $interface['ifDescr'];
$ifIndex = $interface['ifIndex'];
$speed = humanspeed($interface['ifSpeed']);
$ifname = $port['ifDescr'];
$ifIndex = $port['ifIndex'];
$speed = humanspeed($port['ifSpeed']);
$ifalias = $interface['name'];
$ifalias = $port['name'];
if ($interface['ifPhysAddress']) { $mac = "$interface[ifPhysAddress]"; }
if ($port['ifPhysAddress']) { $mac = $port['ifPhysAddress']; }
$color = "black";
if ($interface['ifAdminStatus'] == "down") { $status = "<span class='grey'>Disabled</span>"; }
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "down") { $status = "<span class='red'>Enabled / Disconnected</span>"; }
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "up") { $status = "<span class='green'>Enabled / Connected</span>"; }
if ($port['ifAdminStatus'] == "down") { $status = "<span class='grey'>Disabled</span>"; }
if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "<span class='red'>Enabled / Disconnected</span>"; }
if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "<span class='green'>Enabled / Connected</span>"; }
$i = 1;
$inf = fixifName($ifname);
echo("<div style='clear: both;'>");
if ($_GET['optd'] == "top10")
if ($vars['subview'] == "top10")
{
if ($_GET['opte'])
{
$period = $_GET['opte'];
} else { $period = "1day"; }
$from = "-" . $period;
if ($_GET['optc'])
{
$stat = $_GET['optc'];
} else { $stat = "bits"; }
if(!isset($vars['sort'])) { $vars['sort'] = "in"; }
if(!isset($vars['period'])) { $vars['period'] = "1day"; }
$from = "-" . $vars['period'];
if ($_GET['optf'])
{
$sort = $_GET['optf'];
} else { $sort = "in"; }
echo("<div style='margin: 0px 0px 0px 0px'>
<div style=' margin:0px; float: left;';>
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Day</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id'].
"/macaccounting/$stat/top10/1day/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id'].
"&amp;stat=$stat&amp;type=port_mac_acc_total&amp;sort=$sort&amp;from=-1day&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => $vars['sort'], 'period' => '1day'))."'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id'].
"&amp;stat=".$vars['graph']."&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;from=-1day&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Two Day</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id'].
"/macaccounting/$stat/top10/2day/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id'].
"&amp;stat=$stat&amp;type=port_mac_acc_total&amp;sort=$sort&amp;from=-2day&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => $vars['sort'], 'period' => '2day'))."/'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id'].
"&amp;stat=".$vars['graph']."&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;from=-2day&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Week</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/$stat/top10/1week/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id']."&amp;type=port_mac_acc_total&amp;sort=$sort&amp;stat=$stat&amp;from=-1week&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => $vars['sort'], 'period' => '1week'))."/'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id']."&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;stat=".$vars['graph']."&amp;from=-1week&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Month</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/$stat/top10/1month/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id']."&amp;type=port_mac_acc_total&amp;sort=$sort&amp;stat=$stat&amp;from=-1month&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => $vars['sort'], 'period' => '1month'))."/'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id']."&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;stat=".$vars['graph']."&amp;from=-1month&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Year</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/$stat/top10/1year/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id']."&amp;type=port_mac_acc_total&amp;sort=$sort&amp;stat=$stat&amp;from=-1year&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => $vars['sort'], 'period' => '1year'))."/'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id']."&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;stat=".$vars['graph']."&amp;from=-1year&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
</div>
<div style='float: left;'>
<img src='".$config['base_url']."/graph.php?id=".$interface['interface_id']."&amp;type=port_mac_acc_total&amp;sort=$sort&amp;stat=$stat&amp;from=$from&amp;to=now&amp;width=745&amp;height=300' />
<img src='graph.php?id=".$port['interface_id']."&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;stat=".$vars['graph']."&amp;from=$from&amp;to=now&amp;width=745&amp;height=300' />
</div>
<div style=' margin:0px; float: left;';>
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Traffic</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/top10/$period/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id']."&amp;stat=bits&amp;type=port_mac_acc_total&amp;sort=$sort&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits', sort => $vars['sort'], 'period' => $vars['period']))."'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id']."&amp;stat=bits&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Packets</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/top10/$period/$sort/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id']."&amp;stat=pkts&amp;type=port_mac_acc_total&amp;sort=$sort&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts', sort => $vars['sort'], 'period' => $vars['period']))."/'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id']."&amp;stat=pkts&amp;type=port_mac_acc_total&amp;sort=".$vars['sort']."&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Top Input</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id'].
"/macaccounting/$stat/top10/$period/in/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id'].
"&amp;stat=$stat&amp;type=port_mac_acc_total&amp;sort=in&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => 'in', 'period' => $vars['period']))."'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id'].
"&amp;stat=".$vars['graph']."&amp;type=port_mac_acc_total&amp;sort=in&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Top Output</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id'].
"/macaccounting/$stat/top10/$period/out/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id'].
"&amp;stat=$stat&amp;type=port_mac_acc_total&amp;sort=out&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => 'out', 'period' => $vars['period']))."'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id'].
"&amp;stat=".$vars['graph']."&amp;type=port_mac_acc_total&amp;sort=out&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Top Aggregate</span><br />
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id'].
"/macaccounting/$stat/top10/$period/both/'>
<img style='border: #5e5e5e 2px;' valign=middle src='".$config['base_url']."/graph.php?id=".$interface['interface_id'].
"&amp;stat=$stat&amp;type=port_mac_acc_total&amp;sort=both&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
<a href='".generate_url($link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>$vars['graph'], sort => 'both', 'period' => $vars['period']))."'>
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['interface_id'].
"&amp;stat=".$vars['graph']."&amp;type=port_mac_acc_total&amp;sort=both&amp;from=$from&amp;to=now&amp;width=150&amp;height=50' />
</a>
</div>
</div>
@ -126,7 +114,7 @@ if ($_GET['optd'] == "top10")
$query = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) as bps FROM `mac_accounting` AS M,
`ports` AS I, `devices` AS D WHERE M.interface_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id ORDER BY bps DESC";
$param = array($interface['interface_id']);
$param = array($port['interface_id']);
foreach (dbFetchRows($query, $param) as $acc)
{
@ -150,14 +138,14 @@ if ($_GET['optd'] == "top10")
unset ($as); unset ($astext); unset($asn);
}
if ($_GET['optc'])
if ($vars['graph'])
{
$graph_type = "macaccounting_" . $_GET['optc'];
$graph_type = "macaccounting_" . $vars['graph'];
} else {
$graph_type = "macaccounting_bits";
}
if ($_GET['optd'] == "thumbs")
if ($vars['subview'] == "minigraphs")
{
if (!$asn) { $asn = "No Session"; }

View File

@ -2,30 +2,32 @@
global $config;
### FIXME functions!
if (!$graph_type) { $graph_type = "pagp_bits"; }
$daily_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$day&amp;to=$now&amp;width=215&amp;height=100";
$daily_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$day&amp;to=$now&amp;width=500&amp;height=150";
$daily_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$day&amp;to=$now&amp;width=215&amp;height=100";
$daily_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$day&amp;to=$now&amp;width=500&amp;height=150";
$weekly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$week&amp;to=$now&amp;width=215&amp;height=100";
$weekly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$weekly_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$week&amp;to=$now&amp;width=215&amp;height=100";
$weekly_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$monthly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$month&amp;to=$now&amp;width=215&amp;height=100";
$monthly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$month&amp;to=$now&amp;width=500&amp;height=150";
$monthly_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$month&amp;to=$now&amp;width=215&amp;height=100";
$monthly_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$month&amp;to=$now&amp;width=500&amp;height=150";
$yearly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$year&amp;to=$now&amp;width=215&amp;height=100";
$yearly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;type=$graph_type&amp;from=$year&amp;to=$now&amp;width=500&amp;height=150";
$yearly_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$year&amp;to=$now&amp;width=215&amp;height=100";
$yearly_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&amp;type=$graph_type&amp;from=$year&amp;to=$now&amp;width=500&amp;height=150";
echo("<a href='device/".$device['device_id']."/port/".$interface['interface_id']."/' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
echo("<a href='#' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$daily_traffic' border=0></a> ");
echo("<a href='device/".$device['device_id']."/port/".$interface['interface_id']."/' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
echo("<a href='#' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$weekly_traffic' border=0></a> ");
echo("<a href='device/".$device['device_id']."/port/".$interface['interface_id']."/' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
echo("<a href='#' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$monthly_traffic' border=0></a> ");
echo("<a href='device/".$device['device_id']."/port/".$interface['interface_id']."/' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
echo("<a href='#' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$yearly_traffic' border=0></a>");
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($interface['ifIndex'], $device['device_id'])) as $member)
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member)
{
echo("$br<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . " (PAgP)</strong>");
$br = "<br />";

View File

@ -2,14 +2,11 @@
### FIXME - do this in a function and/or do it in graph-realtime.php
if($_GET['opte']) {
$interval = $_GET['opte'];
} else {
if(!isset($vars['interval'])) {
if($device['os'] == "linux") {
$interval = "15";
$vars['interval'] = "15";
} else {
$interval = "2";
$vars['interval'] = "2";
}
}
@ -17,48 +14,22 @@ print_optionbar_start();
echo("Polling Interval: ");
if ($interval == "0.25" || !$interval) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/0.25/'>0.25s</a>");
if ($interval == "0.25" || !$interval) { echo("</span>"); }
echo(" | ");
if ($interval == "1" || !$interval) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/1/'>1s</a>");
if ($interval == "1" || !$interval) { echo("</span>"); }
echo(" | ");
if ($interval == "2" || !$interval) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/2/'>2s</a>");
if ($interval == "2" || !$interval) { echo("</span>"); }
echo(" | ");
if ($interval == "5" || !$interval) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/5/'>5s</a>");
if ($interval == "5" || !$interval) { echo("</span>"); }
echo(" | ");
if ($interval == "15" || !$interval) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/15/'>15s</a>");
if ($interval == "15" || !$interval) { echo("</span>"); }
echo(" | ");
if ($interval == "60" || !$interval) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/60/'>60s</a>");
if ($interval == "60" || !$interval) { echo("</span>"); }
foreach(array(0.25, 1, 2, 5, 15, 60) as $interval)
{
echo($thinger);
if ($vars['interval'] == $interval) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($interval."s",$link_array,array('view'=>'realtime','interval'=>$interval)));
if ($vars['interval'] == $interval) { echo("</span>"); }
$thinger = " | ";
}
print_optionbar_end();
?>
<div align="center" style="margin: 30px;">
<object data="graph-realtime.php?type=bits&id=<?php echo($interface['interface_id'] . "&interval=".$interval); ?>" type="image/svg+xml" width="1000" height="400">
<param name="src" value="graph.php?type=bits&id=<?php echo($interface['interface_id'] . "&interval=".$interval); ?>" />
<object data="graph-realtime.php?type=bits&id=<?php echo($port['interface_id'] . "&interval=".$vars['interval']); ?>" type="image/svg+xml" width="1000" height="400">
<param name="src" value="graph.php?type=bits&id=<?php echo($port['interface_id'] . "&interval=".$vars['interval']); ?>" />
Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin.
</object>
</div>

View File

@ -1,9 +1,15 @@
<?php
if ($_GET['optc'] == 'graphs')
if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs')
{
if ($_GET['optd']) { $graph_type = "port_" . $_GET['optd']; } else { $graph_type = "port_bits"; }
if (isset($vars['graph'])) { $graph_type = "port_" . $vars['graph']; } else { $graph_type = "port_bits"; }
}
if (!$vars['view']) { $vars['view'] = "basic"; }
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'ports');
print_optionbar_start();
@ -13,22 +19,21 @@ $menu_options['arp'] = 'ARP Table';
if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id"))
{
$menu_options['neighbours'] = 'Neighbours';
$menu_options['neighbours'] = 'Neighbours';
}
if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'"))
{
$menu_options['adsl'] = 'ADSL';
}
if (!$_GET['optc']) { $_GET['optc'] = "basic"; }
$sep = "";
foreach ($menu_options as $option => $text)
{
echo($sep);
if ($_GET['optc'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/' . $option . ($_GET['optd'] ? '/' . $_GET['optd'] : ''). '/">' . $text . '</a>');
if ($_GET['optc'] == $option) { echo("</span>"); }
if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($text,$link_array,array('view'=>$option)));
if ($vars['view'] == $option) { echo("</span>"); }
$sep = " | ";
}
@ -45,69 +50,70 @@ $graph_types = array("bits" => "Bits",
foreach ($graph_types as $type => $descr)
{
echo("$type_sep");
if ($_GET['optd'] == $type && $_GET['opte'] != "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/graphs/'.$type.'/">'.$descr.'</a>');
if ($_GET['optd'] == $type && $_GET['opte'] != "thumbs") { echo("</span>"); }
if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type)));
if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo("</span>"); }
echo('(');
if ($_GET['optd'] == $type && $_GET['opte'] == "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/graphs/'.$type.'/thumbs/">Mini</a>');
if ($_GET['optd'] == $type && $_GET['opte'] == "thumbs") { echo("</span>"); }
if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type)));
if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo("</span>"); }
echo(')');
$type_sep = " | ";
}
print_optionbar_end();
if ($_GET['opte'] == thumbs)
if ($vars['view'] == minigraphs)
{
$timeperiods = array('-1day','-1week','-1month','-1year');
$from = '-1day';
echo("<div style='display: block; clear: both; margin: auto; min-height: 500px;'>");
unset ($seperator);
foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $interface)
## FIX THIS. UGLY.
foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port)
{
echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 183px; max-width:183px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e9e9e9;'>
<div style='font-weight: bold;'>".makeshortif($interface['ifDescr'])."</div>
<a href='device/".$device['device_id']."/port/".$interface['interface_id']."/' onmouseover=\"return overlib('\
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$interface['ifDescr']."</div>\
".$interface['ifAlias']." \
<img src=\'graph.php?type=$graph_type&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=450&amp;height=150\'>\
<div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div>
<a href='device/".$device['device_id']."/port/".$port['interface_id']."/' onmouseover=\"return overlib('\
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\
".$port['ifAlias']." \
<img src=\'graph.php?type=".$graph_type."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=450&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<img src='graph.php?type=$graph_type&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=180&amp;height=45&amp;legend=no'>
"<img src='graph.php?type=".$graph_type."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=180&amp;height=45&amp;legend=no'>
</a>
<div style='font-size: 9px;'>".truncate(short_port_descr($interface['ifAlias']), 32, '')."</div>
<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 32, '')."</div>
</div>");
}
echo("</div>");
} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") {
include("ports/".$vars['view'].".inc.php");
} else {
if ($_GET['optc'] == "arp" || $_GET['optc'] == "adsl" || $_GET['optc'] == "neighbours")
if ($vars['view'] == "details") { $port_details = 1; }
echo("<div style='margin: 0px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
global $port_cache;
global $port_index_cache;
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id']));
### As we've dragged the whole database, lets pre-populate our caches :)
### FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries.
foreach($ports as $port)
{
include("ports/".$_GET['optc'].".inc.php");
} else {
if ($_GET['optc'] == "details") { $port_details = 1; }
echo("<div style='margin: 0px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
global $port_cache;
global $port_index_cache;
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id']));
### As we've dragged the whole database, lets pre-populate our caches :)
### FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries.
foreach($ports as $port)
{
$port_cache[$port['interface_id']] = $port;
$port_index_cache[$port['device_id']][$port['ifIndex']] = $port;
}
foreach ($ports as $interface)
{
include("includes/print-interface.inc.php");
$i++;
}
echo("</table></div>");
$port_cache[$port['interface_id']] = $port;
$port_index_cache[$port['device_id']][$port['ifIndex']] = $port;
}
foreach ($ports as $port)
{
include("includes/print-interface.inc.php");
$i++;
}
echo("</table></div>");
}
?>

View File

@ -23,8 +23,10 @@ $type_text['frequency'] = "Frequency";
$type_text['current'] = "Current";
$type_text['power'] = "Power";
if (!$_GET['opta']) { $_GET['opta'] = "processor"; }
if (!$_GET['optb']) { $_GET['optb'] = "nographs"; }
if (!$vars['metric']) { $vars['metric'] = "processor"; }
if (!$vars['view']) { $vars['view'] = "detail"; }
$link_array = array('page' => 'health');
print_optionbar_start('', '');
@ -33,16 +35,16 @@ echo('<span style="font-weight: bold;">Health</span> &#187; ');
$sep = "";
foreach ($datas as $texttype)
{
$type = strtolower($texttype);
$metric = strtolower($texttype);
echo($sep);
if ($_GET['opta'] == $type)
if ($vars['metric'] == $metric)
{
echo("<span class='pagemenu-selected'>");
}
echo('<a href="health/' . $type . ($_GET['optb'] ? '/' . $_GET['optb'] : ''). '/">' . $type_text[$type] .'</a>');
if ($_GET['opta'] == $type) { echo("</span>"); }
echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view'])));
if ($vars['metric'] == $metric) { echo("</span>"); }
$sep = ' | ';
}
@ -51,28 +53,26 @@ unset ($sep);
echo('<div style="float: right;">');
if ($_GET['optb'] == "graphs")
if ($vars['view'] == "graphs")
{
echo('<span class="pagemenu-selected">');
}
echo('<a href="health/'. $_GET['opta'].'/graphs/"> Graphs</a>');
if ($_GET['optb'] == "graphs")
echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs")));
if ($vars['view'] == "graphs")
{
echo('</span>');
}
echo(' | ');
if ($_GET['optb'] == "nographs")
if ($vars['view'] == "nographs")
{
echo('<span class="pagemenu-selected">');
}
echo('<a href="health/'. $_GET['opta'].'/nographs/"> No Graphs</a>');
echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail")));
if ($_GET['optb'] == "nographs")
if ($vars['view'] == "nographs")
{
echo('</span>');
}
@ -81,16 +81,16 @@ echo('</div>');
print_optionbar_end();
if (in_array($_GET['opta'],array_keys($used_sensors))
|| $_GET['opta'] == 'processor'
|| $_GET['opta'] == 'storage'
|| $_GET['opta'] == 'mempool')
if (in_array($vars['metric'],array_keys($used_sensors))
|| $vars['metric'] == 'processor'
|| $vars['metric'] == 'storage'
|| $vars['metric'] == 'mempool')
{
include('pages/health/'.$_GET['opta'].'.inc.php');
include('pages/health/'.$vars['metric'].'.inc.php');
}
else
{
echo("No sensors of type " . $_GET['opta'] . " found.");
echo("No sensors of type " . $vars['metric'] . " found.");
}
?>

View File

@ -45,7 +45,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.devi
<td width=50>".$mempool['mempool_perc']."%</td>
</tr>");
if ($_GET['optb'] == "graphs")
if ($vars['view'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=5>");

View File

@ -49,7 +49,7 @@ foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.de
echo('</a></td>
</tr>');
if ($_GET['optb'] == "graphs")
if ($vars['view'] == "graphs")
{ ## If graphs are requested, do them, else not!
echo(' <tr bgcolor="'.$row_colour.'"><td colspan="5">');

View File

@ -54,7 +54,7 @@ foreach (dbFetchRows($sql, $param) as $sensor)
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
</tr>\n");
if ($_GET['optb'] == "graphs")
if ($vars['view'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=7>");

View File

@ -72,7 +72,7 @@ foreach (dbFetchRows("SELECT * FROM `storage` AS S, `devices` AS D WHERE S.devic
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right'])."</a>
</td><td>$perc"."%</td></tr>");
if ($_GET['optb'] == "graphs")
if ($vars['view'] == "graphs")
{
echo("<tr bgcolor='$row_colour'><td colspan=5>");

View File

@ -60,7 +60,7 @@ $config['int_l2tp'] = 0; # Enable L2TP Port Types
$config['show_locations'] = 1; # Enable Locations on menu
$config['show_locations_dropdown'] = 1; # Enable Locations dropdown on menu
$config['show_services'] = 1; # Enable Services on menu
$config['ports_page_default'] = "details/"; ## eg "details/" "graphs/bits/"
$config['ports_page_default'] = "details"; ## eg "details" "graphs/bits" ### THIS NO LONGER WORKS
### SNMP Settings - Timeouts/Retries disabled as default
#$config['snmp']['timeout'] = 1; # timeout in seconds