From 7584bba7417e3f970bfff83c0c34f32e3f7db5dd Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 18 Sep 2011 13:11:04 +0000 Subject: [PATCH] more migration to new URL system git-svn-id: http://www.observium.org/svn/observer/trunk@2492 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/functions.inc.php | 18 ++- html/includes/print-interface-adsl.inc.php | 74 +++++----- html/includes/print-interface-graphs.inc.php | 2 +- html/includes/print-interface.inc.php | 104 +++++++------- html/pages/device.inc.php | 60 ++++----- html/pages/device/apps.inc.php | 18 ++- html/pages/device/collectd.inc.php | 24 ++-- html/pages/device/graphs.inc.php | 16 ++- html/pages/device/health.inc.php | 21 +-- html/pages/device/overview/ports.inc.php | 21 +-- html/pages/device/port.inc.php | 135 ++++++++++--------- html/pages/device/port/adsl.inc.php | 4 +- html/pages/device/port/arp.inc.php | 2 +- html/pages/device/port/graphs.inc.php | 6 +- html/pages/device/port/macaccounting.inc.php | 102 +++++++------- html/pages/device/port/pagp.inc.php | 28 ++-- html/pages/device/port/realtime.inc.php | 55 ++------ html/pages/device/ports.inc.php | 100 +++++++------- html/pages/health.inc.php | 42 +++--- html/pages/health/mempool.inc.php | 2 +- html/pages/health/processor.inc.php | 2 +- html/pages/health/sensors.inc.php | 2 +- html/pages/health/storage.inc.php | 2 +- includes/defaults.inc.php | 2 +- 24 files changed, 410 insertions(+), 432 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index dc96b73262..cddac1edf5 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1,5 +1,9 @@ '.$text.''; +} 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 = "
".$device['hostname']; if ($device['hardware']) { $contents .= " - ".$device['hardware']; } $contents .= "
"; @@ -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) diff --git a/html/includes/print-interface-adsl.inc.php b/html/includes/print-interface-adsl.inc.php index 2aef4ef5f1..b991d8f64e 100644 --- a/html/includes/print-interface-adsl.inc.php +++ b/html/includes/print-interface-adsl.inc.php @@ -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,"Interface Errors","port_errors"); + $error_img = generate_port_link($port,"Interface Errors","port_errors"); } else { $error_img = ""; } echo(" +onclick=\"location.href='device/".$device['device_id']."/port/".$port['interface_id']."/'\" style='cursor: pointer;'> "); echo(" - " . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . " -
".$interface['ifAlias'].""); + " . generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) . " +
".$port['ifAlias'].""); -if ($interface['ifAlias']) { echo("
"); } +if ($port['ifAlias']) { echo("
"); } 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 ".$ip['ipv4_address']."/".$ip['ipv4_prefixlen'].""); $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 ".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen'].""); $break = ","; @@ -47,48 +47,48 @@ echo(""); $width="120"; $height="40"; $from = $config['time']['day']; echo(""); -echo(formatRates($interface['ifInOctets_rate'] * 8)." ".formatRates($interface['ifOutOctets_rate'] * 8)); +echo(formatRates($port['ifInOctets_rate'] * 8)." ".formatRates($port['ifOutOctets_rate'] * 8)); echo("
"); -$interface['graph_type'] = "port_bits"; -echo(generate_port_link($interface, "", $interface['graph_type'])); +$port['graph_type'] = "port_bits"; +echo(generate_port_link($port, "", $port['graph_type'])); echo(""); -echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate'])); +echo("".formatRates($port['adslAturChanCurrTxRate']) . "/". formatRates($port['adslAtucChanCurrTxRate'])); echo("
"); -$interface['graph_type'] = "port_adsl_speed"; -echo(generate_port_link($interface, "", $interface['graph_type'])); +$port['graph_type'] = "port_adsl_speed"; +echo(generate_port_link($port, "", $port['graph_type'])); echo(""); -echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate'])); +echo("".formatRates($port['adslAturCurrAttainableRate']) . "/". formatRates($port['adslAtucCurrAttainableRate'])); echo("
"); -$interface['graph_type'] = "port_adsl_attainable"; -echo(generate_port_link($interface, "", $interface['graph_type'])); +$port['graph_type'] = "port_adsl_attainable"; +echo(generate_port_link($port, "", $port['graph_type'])); echo(""); -echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB"); +echo("".$port['adslAturCurrAtn'] . "dB/". $port['adslAtucCurrAtn'] . "dB"); echo("
"); -$interface['graph_type'] = "port_adsl_attenuation"; -echo(generate_port_link($interface, "", $interface['graph_type'])); +$port['graph_type'] = "port_adsl_attenuation"; +echo(generate_port_link($port, "", $port['graph_type'])); echo(""); -echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB"); +echo("".$port['adslAturCurrSnrMgn'] . "dB/". $port['adslAtucCurrSnrMgn'] . "dB"); echo("
"); -$interface['graph_type'] = "port_adsl_snr"; -echo(generate_port_link($interface, "", $interface['graph_type'])); +$port['graph_type'] = "port_adsl_snr"; +echo(generate_port_link($port, "", $port['graph_type'])); echo(""); -echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm"); +echo("".$port['adslAturCurrOutputPwr'] . "dBm/". $port['adslAtucCurrOutputPwr'] . "dBm"); echo("
"); -$interface['graph_type'] = "port_adsl_power"; -echo(generate_port_link($interface, "", $interface['graph_type'])); +$port['graph_type'] = "port_adsl_power"; +echo(generate_port_link($port, "", $port['graph_type'])); -# if ($interface[ifDuplex] != unknown) { echo("Duplex " . $interface['ifDuplex'] . ""); } else { echo("-"); } +# if ($port[ifDuplex] != unknown) { echo("Duplex " . $port['ifDuplex'] . ""); } else { echo("-"); } # echo(""); # echo($port_adsl['adslLineCoding']."/".$port_adsl['adslLineType']); diff --git a/html/includes/print-interface-graphs.inc.php b/html/includes/print-interface-graphs.inc.php index b90e031017..e1bc4856b4 100644 --- a/html/includes/print-interface-graphs.inc.php +++ b/html/includes/print-interface-graphs.inc.php @@ -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"); diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index 62b5b19c35..3ad386e76b 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -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, "Interface Errors", "port_errors"); + $error_img = generate_port_link($port, "Interface Errors", "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 = ""; + $mac = ""; } else { $mac = ""; } -echo(" +echo(" "); echo(" - " . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . " $error_img $mac -
".$interface['ifAlias'].""); + " . generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) . " $error_img $mac +
".$port['ifAlias'].""); -if ($interface['ifAlias']) { echo("
"); } +if ($port['ifAlias']) { echo("
"); } 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 ".$ip['ipv4_address']."/".$ip['ipv4_prefixlen'].""); $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 ".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen'].""); $break = "
"; @@ -58,42 +58,42 @@ echo(""); if ($port_details) { - $interface['graph_type'] = "port_bits"; - echo(generate_port_link($interface, "")); - $interface['graph_type'] = "port_upkts"; - echo(generate_port_link($interface, "")); - $interface['graph_type'] = "port_errors"; - echo(generate_port_link($interface, "")); + $port['graph_type'] = "port_bits"; + echo(generate_port_link($port, "")); + $port['graph_type'] = "port_upkts"; + echo(generate_port_link($port, "")); + $port['graph_type'] = "port_errors"; + echo(generate_port_link($port, "")); } echo(""); -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(" ".formatRates($interface['in_rate'])."
- ".formatRates($interface['out_rate']) . "
- ".format_bi($interface['ifInUcastPkts_rate'])."pps

- ".format_bi($interface['ifOutUcastPkts_rate'])."pps
"); + $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(" ".formatRates($port['in_rate'])."
+ ".formatRates($port['out_rate']) . "
+ ".format_bi($port['ifInUcastPkts_rate'])."pps

+ ".format_bi($port['ifOutUcastPkts_rate'])."pps
"); } echo(""); -if ($interface['ifSpeed']) { echo("".humanspeed($interface['ifSpeed']).""); } +if ($port['ifSpeed']) { echo("".humanspeed($port['ifSpeed']).""); } echo("
"); -if ($interface[ifDuplex] != "unknown") { echo("" . $interface['ifDuplex'] . ""); } else { echo("-"); } +if ($port[ifDuplex] != "unknown") { echo("" . $port['ifDuplex'] . ""); } else { echo("-"); } if ($device['os'] == "ios" || $device['os'] == "iosxe") { - if ($interface['ifTrunk']) { - echo("" . $interface['ifTrunk'] . ""); - } elseif ($interface['ifVlan']) { - echo("VLAN " . $interface['ifVlan'] . ""); - } elseif ($interface['ifVrf']) { - $vrf = dbFetchRow("SELECT * FROM vrfs WHERE vrf_id = ?", array($interface['ifVrf'])); + if ($port['ifTrunk']) { + echo("" . $port['ifTrunk'] . ""); + } elseif ($port['ifVlan']) { + echo("VLAN " . $port['ifVlan'] . ""); + } elseif ($port['ifVrf']) { + $vrf = dbFetchRow("SELECT * FROM vrfs WHERE vrf_id = ?", array($port['ifVrf'])); echo("" . $vrf['vrf_name'] . ""); } } @@ -112,18 +112,18 @@ if ($port_adsl['adslLineCoding']) echo("SNR:".$port_adsl['adslAtucCurrSnrMgn'] . "dB/". $port_adsl['adslAturCurrSnrMgn']. "dB"); } else { echo(""); - if ($interface['ifType'] && $interface['ifType'] != "") { echo("" . fixiftype($interface['ifType']) . ""); } else { echo("-"); } + if ($port['ifType'] && $port['ifType'] != "") { echo("" . fixiftype($port['ifType']) . ""); } else { echo("-"); } echo("
"); if ($ifHardType && $ifHardType != "") { echo("" . $ifHardType . ""); } else { echo("-"); } echo(""); - if ($interface['ifPhysAddress'] && $interface['ifPhysAddress'] != "") { echo("" . formatMac($interface['ifPhysAddress']) . ""); } else { echo("-"); } + if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") { echo("" . formatMac($port['ifPhysAddress']) . ""); } else { echo("-"); } echo("
"); - if ($interface['ifMtu'] && $interface['ifMtu'] != "") { echo("MTU " . $interface['ifMtu'] . ""); } else { echo("-"); } + if ($port['ifMtu'] && $port['ifMtu'] != "") { echo("MTU " . $port['ifMtu'] . ""); } else { echo("-"); } } echo(""); echo(""); -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 = "
"; } -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 " . generate_port_link($member) . " (PAgP)"); $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 " . generate_port_link($parent) . " (PAgP)"); $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(""); 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)) diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index e4cdabfd4b..596ab312f4 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -1,27 +1,25 @@ - + Overview '); } echo('
  • - + Graphs
  • '); @@ -61,7 +59,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if ($health) { echo('
  • - + Health
  • '); @@ -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('
  • - + Apps
  • '); @@ -79,7 +77,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { echo('
  • - + CollectD
  • '); @@ -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('
  • - + Ports
  • '); @@ -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('
  • - + VLANs
  • '); @@ -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('
  • - + Virtual Machines
  • '); @@ -132,7 +130,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if (is_array($routing_tabs)) { echo('
  • - + Routing
  • '); @@ -142,7 +140,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) { $discovery_links = TRUE; echo('
  • - + Map
  • '); @@ -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('
  • - + Inventory
  • '); @@ -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('
  • - + Inventory
  • '); @@ -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('
  • - + Services
  • '); @@ -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('
  • - + Toner
  • '); @@ -186,7 +184,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if (device_permitted($device['device_id'])) { echo('
  • - + Events
  • '); @@ -195,7 +193,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if ($config['enable_syslog']) { echo('
  • - + Syslog
  • '); @@ -214,7 +212,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if ($device_config_file) { echo('
  • - + Config
  • '); @@ -237,7 +235,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if ($nfsen_rrd_file) { echo('
  • - + Netflow
  • '); @@ -247,7 +245,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) if ($_SESSION['userlevel'] >= "7") { echo('
  • - + Settings
  • '); @@ -255,10 +253,10 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta']) echo(""); } - if(device_permitted($device['device_id']) || $check_device == $_GET['opta']) { + if(device_permitted($device['device_id']) || $check_device == $vars['device']) { echo('
    '); - include("pages/device/".mres(basename($section)).".inc.php"); + include("pages/device/".mres(basename($tab)).".inc.php"); echo("
    "); } else { diff --git a/html/pages/device/apps.inc.php b/html/pages/device/apps.inc.php index de9ad7bdd1..b1c4c77700 100644 --- a/html/pages/device/apps.inc.php +++ b/html/pages/device/apps.inc.php @@ -6,31 +6,35 @@ echo("Apps » "); 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(""); #echo(''); } else { #echo(''); } - echo(" " . $app['app_type'] .""); - if ($_GET['optc'] == $app['app_type']) { echo(""); } + echo(generate_link($app['app_type'],$link_array,array('app'=>$app['app_type']))); + if ($vars['app'] == $app['app_type']) { echo(""); } $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"); } ?> diff --git a/html/pages/device/collectd.inc.php b/html/pages/device/collectd.inc.php index ea712dd840..3e4e4838f8 100644 --- a/html/pages/device/collectd.inc.php +++ b/html/pages/device/collectd.inc.php @@ -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(""); } - echo("" . htmlspecialchars($plugin) .""); - if ($_GET['optc'] == $plugin) { echo(""); } + if ($vars['plugin'] == $plugin) { echo(""); } + echo(generate_link(htmlspecialchars($plugin),$link_array,array('plugin'=>$plugin))); + if ($vars['plugin'] == $plugin) { echo(""); } $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('
    '); echo('
    '); 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("
    "); $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; diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index d2840bdbab..ee26dc3443 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,8 +1,12 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs'); + $bg="#ffffff"; echo('
    '); @@ -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) diff --git a/html/pages/device/health.inc.php b/html/pages/device/health.inc.php index 09cb0fc663..40dabda452 100644 --- a/html/pages/device/health.inc.php +++ b/html/pages/device/health.inc.php @@ -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("Health » "); -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(''); - } + if ($vars['metric'] == $type) + { echo(''); } - echo(" " . $type_text[$type] .""); - if ($_GET['optc'] == $type) { echo(""); } + echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); + if ($vars['metric'] == $type) { echo(""); } $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) { diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 146dccba6c..560b3eace2 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -5,7 +5,7 @@ if ($ports['total']) echo('
    '); $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 = "
    ".$device['hostname']." - Device Traffic
    "; - $content .= "
    "; - $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 .= "
    "; - - echo(overlib_link($link, $graph, $content, NULL)); + echo(overlib_link($link, $graph, $overlib_content, NULL)); echo('
    '); diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index b2f474c284..83d34c5822 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,25 +1,25 @@ Disabled"; } -if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } $i = 1; $inf = fixifName($ifname); @@ -51,90 +51,95 @@ echo("
    "); print_optionbar_start(); -if ($_GET['optd'] == "graphs" || !$_GET['optd']) { echo(""); } -echo("Graphs"); -if ($_GET['optd'] == "graphs" || !$_GET['optd']) { echo(""); } +$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(""); } -echo("Real Time"); -if ($_GET['optd'] == "realtime" || !$_GET['optd']) { echo(""); } +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(""); } - echo("ADSL"); - if ($_GET['optd'] == "adsl") { echo(""); } + echo($sep); + if ($vars['view'] == $option) { echo(""); } + echo(generate_link($text,$link_array,array('view'=>$option))); + if ($vars['view'] == $option) { echo(""); } + $sep = " | "; } +unset($sep); -echo(" | "); -if ($_GET['optd'] == "arp") { echo(""); } -echo("ARP Table"); -if ($_GET['optd'] == "arp") { echo(""); } - -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(""); } - echo("PAgP"); - if ($_GET['optd'] == "pagp") { echo(""); } -} + 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(""); } - echo("Bits"); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && !$_GET['optf']) { echo(""); } + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo("("); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "thumbs") { echo(""); } - echo("Mini"); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "thumbs") { echo(""); } + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } + echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } echo('|'); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "top10") { echo(""); } - echo("Top10"); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "top10") { echo(""); } + + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } + echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } echo(") | "); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && !$_GET['optf']) { echo(""); } - echo("Packets"); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && !$_GET['optf']) { echo(""); } + + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } + echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } echo("("); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && $_GET['optf'] == "thumbs") { echo(""); } - echo("Mini"); - if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && $_GET['optf'] == "thumbs") { echo(""); } + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } + echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } + echo('|'); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } + echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } 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(""); } - echo("Bits"); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo(""); } + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo("Bits"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } echo(" | "); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "packets") { echo(""); } - echo("Packets"); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo(""); } + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } + echo("Packets"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } echo(" | "); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "cells") { echo(""); } - echo("Cells"); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo(""); } + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } + echo("Cells"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } echo(" | "); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "errors") { echo(""); } - echo("Errors"); - if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo(""); } + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } + echo("Errors"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } } print_optionbar_end(); echo("
    "); -include("pages/device/port/".mres($_GET['optd']).".inc.php"); +include("pages/device/port/".mres($vars['view']).".inc.php"); echo("
    "); ?> diff --git a/html/pages/device/port/adsl.inc.php b/html/pages/device/port/adsl.inc.php index 276f1fa70f..2f309823e7 100644 --- a/html/pages/device/port/adsl.inc.php +++ b/html/pages/device/port/adsl.inc.php @@ -1,6 +1,6 @@ ADSL Line Speed
    "); @@ -20,4 +20,4 @@ if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . "-ad include("includes/print-interface-graphs.inc.php"); } -?> \ No newline at end of file +?> diff --git a/html/pages/device/port/arp.inc.php b/html/pages/device/port/arp.inc.php index e5976f26c2..95ee2989d5 100644 --- a/html/pages/device/port/arp.inc.php +++ b/html/pages/device/port/arp.inc.php @@ -3,7 +3,7 @@ echo(''); $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'])); diff --git a/html/pages/device/port/graphs.inc.php b/html/pages/device/port/graphs.inc.php index 38b350858b..160303c567 100644 --- a/html/pages/device/port/graphs.inc.php +++ b/html/pages/device/port/graphs.inc.php @@ -1,6 +1,6 @@ Interface Traffic"); @@ -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("
    Ethernet Errors
    "); $graph_type = "port_etherlike"; @@ -27,4 +27,4 @@ if (file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . ".rr } } -?> \ No newline at end of file +?> diff --git a/html/pages/device/port/macaccounting.inc.php b/html/pages/device/port/macaccounting.inc.php index 1d5c7d6857..49becf5a7f 100644 --- a/html/pages/device/port/macaccounting.inc.php +++ b/html/pages/device/port/macaccounting.inc.php @@ -1,119 +1,107 @@ Disabled"; } -if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } $i = 1; $inf = fixifName($ifname); echo("
    "); -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("
    - +
    @@ -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"; } diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index 42a64cb1d4..9d8341b8ca 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -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'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100"; -$daily_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; +$daily_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100"; +$daily_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; -$weekly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100"; -$weekly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150"; +$weekly_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100"; +$weekly_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150"; -$monthly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100"; -$monthly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150"; +$monthly_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100"; +$monthly_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150"; -$yearly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100"; -$yearly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150"; +$yearly_traffic = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100"; +$yearly_url = $config['base_url'] . "/graph.php?port=" . $port['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150"; -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> +echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> +echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> +echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> +echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> "); -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 " . generate_port_link($member) . " (PAgP)"); $br = "
    "; diff --git a/html/pages/device/port/realtime.inc.php b/html/pages/device/port/realtime.inc.php index 2109dd9e4c..9627721bf7 100644 --- a/html/pages/device/port/realtime.inc.php +++ b/html/pages/device/port/realtime.inc.php @@ -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(""); } -echo("0.25s"); -if ($interval == "0.25" || !$interval) { echo(""); } - -echo(" | "); - -if ($interval == "1" || !$interval) { echo(""); } -echo("1s"); -if ($interval == "1" || !$interval) { echo(""); } - - -echo(" | "); - -if ($interval == "2" || !$interval) { echo(""); } -echo("2s"); -if ($interval == "2" || !$interval) { echo(""); } - -echo(" | "); - -if ($interval == "5" || !$interval) { echo(""); } -echo("5s"); -if ($interval == "5" || !$interval) { echo(""); } - -echo(" | "); - -if ($interval == "15" || !$interval) { echo(""); } -echo("15s"); -if ($interval == "15" || !$interval) { echo(""); } - -echo(" | "); - -if ($interval == "60" || !$interval) { echo(""); } -echo("60s"); -if ($interval == "60" || !$interval) { echo(""); } +foreach(array(0.25, 1, 2, 5, 15, 60) as $interval) +{ + echo($thinger); + if ($vars['interval'] == $interval) { echo(""); } + echo(generate_link($interval."s",$link_array,array('view'=>'realtime','interval'=>$interval))); + if ($vars['interval'] == $interval) { echo(""); } + $thinger = " | "; +} print_optionbar_end(); ?>
    - - + + Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin. diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 5e15f00f8e..a406f5ebd3 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,9 +1,15 @@ '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(""); } - echo('' . $text . ''); - if ($_GET['optc'] == $option) { echo(""); } + if ($vars['view'] == $option) { echo(""); } + echo(generate_link($text,$link_array,array('view'=>$option))); + if ($vars['view'] == $option) { echo(""); } $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(""); } - echo(''.$descr.''); - if ($_GET['optd'] == $type && $_GET['opte'] != "thumbs") { echo(""); } + if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } + echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } echo('('); - if ($_GET['optd'] == $type && $_GET['opte'] == "thumbs") { echo(""); } - echo('Mini'); - if ($_GET['optd'] == $type && $_GET['opte'] == "thumbs") { echo(""); } + if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } + echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } echo(')'); $type_sep = " | "; } print_optionbar_end(); -if ($_GET['opte'] == thumbs) +if ($vars['view'] == minigraphs) { $timeperiods = array('-1day','-1week','-1month','-1year'); $from = '-1day'; echo("
    "); 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("
    -
    ".makeshortif($interface['ifDescr'])."
    - ".$device['hostname']." - ".$interface['ifDescr']."
    \ - ".$interface['ifAlias']." \ - \ +
    ".makeshortif($port['ifDescr'])."
    +
    ".$device['hostname']." - ".$port['ifDescr']."
    \ + ".$port['ifAlias']." \ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " + " -
    ".truncate(short_port_descr($interface['ifAlias']), 32, '')."
    +
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    "); } echo(""); +} 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("
    "); + $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("
    "); - $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("
    "); + $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("
    "); } + ?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 6623a4ac85..bb63f06abb 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -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('Health » '); $sep = ""; foreach ($datas as $texttype) { - $type = strtolower($texttype); + $metric = strtolower($texttype); echo($sep); - if ($_GET['opta'] == $type) + if ($vars['metric'] == $metric) { echo(""); } - echo('' . $type_text[$type] .''); - - if ($_GET['opta'] == $type) { echo(""); } + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + + if ($vars['metric'] == $metric) { echo(""); } $sep = ' | '; } @@ -51,28 +53,26 @@ unset ($sep); echo('
    '); -if ($_GET['optb'] == "graphs") +if ($vars['view'] == "graphs") { echo(''); } - -echo(' Graphs'); - -if ($_GET['optb'] == "graphs") +echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); +if ($vars['view'] == "graphs") { echo(''); } echo(' | '); -if ($_GET['optb'] == "nographs") +if ($vars['view'] == "nographs") { echo(''); } -echo(' No Graphs'); +echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($_GET['optb'] == "nographs") +if ($vars['view'] == "nographs") { echo(''); } @@ -81,16 +81,16 @@ echo('
    '); 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."); } ?> diff --git a/html/pages/health/mempool.inc.php b/html/pages/health/mempool.inc.php index 3973b64de9..daf30e9b9e 100644 --- a/html/pages/health/mempool.inc.php +++ b/html/pages/health/mempool.inc.php @@ -45,7 +45,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.devi ".$mempool['mempool_perc']."% "); - if ($_GET['optb'] == "graphs") + if ($vars['view'] == "graphs") { echo(""); diff --git a/html/pages/health/processor.inc.php b/html/pages/health/processor.inc.php index cfe59516e4..1527850027 100644 --- a/html/pages/health/processor.inc.php +++ b/html/pages/health/processor.inc.php @@ -49,7 +49,7 @@ foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.de echo(' '); - if ($_GET['optb'] == "graphs") + if ($vars['view'] == "graphs") { ## If graphs are requested, do them, else not! echo(' '); diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index b67ff123ed..2316075adb 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -54,7 +54,7 @@ foreach (dbFetchRows($sql, $param) as $sensor) " . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . " \n"); - if ($_GET['optb'] == "graphs") + if ($vars['view'] == "graphs") { echo(""); diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php index 3233534729..29ed2f7bf1 100644 --- a/html/pages/health/storage.inc.php +++ b/html/pages/health/storage.inc.php @@ -72,7 +72,7 @@ foreach (dbFetchRows("SELECT * FROM `storage` AS S, `devices` AS D WHERE S.devic ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right'])." $perc"."%"); - if ($_GET['optb'] == "graphs") + if ($vars['view'] == "graphs") { echo(""); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 3e4958c5dd..92a679e7cf 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -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