From a8e6e7b0e927e1b430b42daef40c42183ecc1d8e Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 28 Sep 2011 16:47:12 +0000 Subject: [PATCH] fixes. speed improvements. git-svn-id: http://www.observium.org/svn/observer/trunk@2602 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/print-interface.inc.php | 105 ++++++++++++++------------ includes/dbFacile.php | 4 +- scripts/removespikes.php | 2 +- 3 files changed, 58 insertions(+), 53 deletions(-) diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index df1dfb173..bb24f089b 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -179,69 +179,74 @@ if (strpos($port['label'], "oopback") === false && !$graph_type) } } - foreach ($int_links as $int_link) + if ($port_details) { - $link_if = dbFetchRow("SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = ?", array($int_link)); + foreach ($int_links as $int_link) + { + $link_if = dbFetchRow("SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = ?", array($int_link)); - echo("$br"); + echo("$br"); - if ($int_links_phys[$int_link]) { echo(" "); } else { - echo(" "); } + if ($int_links_phys[$int_link]) { echo(" "); } else { + echo(" "); } - echo("" . generate_port_link($link_if, makeshortif($link_if['label'])) . " on " . generate_device_link($link_if, shorthost($link_if['hostname']))); + echo("" . generate_port_link($link_if, makeshortif($link_if['label'])) . " on " . generate_device_link($link_if, shorthost($link_if['hostname']))); - if ($int_links_v6[$int_link]) { echo(" v6"); } - if ($int_links_v4[$int_link]) { echo(" v4"); } - $br = "
"; + if ($int_links_v6[$int_link]) { echo(" v6"); } + if ($int_links_v4[$int_link]) { echo(" v4"); } + $br = "
"; + } } # unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); } -foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `interface_id` = ?", array($port['interface_id'])) as $pseudowire) +if ($port_details) { -#`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'])); - $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID'])); + 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'])); + $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID'])); - $pw_peer_int = ifNameDescr($pw_peer_int); - echo("$br " . generate_port_link($pw_peer_int, makeshortif($pw_peer_int['label'])) ." on ". generate_device_link($pw_peer_dev, shorthost($pw_peer_dev['hostname'])) . ""); - $br = "
"; + $pw_peer_int = ifNameDescr($pw_peer_int); + echo("$br " . generate_port_link($pw_peer_int, makeshortif($pw_peer_int['label'])) ." on ". generate_device_link($pw_peer_dev, shorthost($pw_peer_dev['hostname'])) . ""); + $br = "
"; + } + + 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 ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) + { + $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($port['ifIndex'], $device['device_id'])) as $higher_if) + { + if ($higher_if['interface_id_high']) + { + $this_port = get_port_by_index_cache($device['device_id'], $higher_if['interface_id_high']); + echo("$br " . generate_port_link($this_port) . ""); + $br = "
"; + } + } + + 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']) + { + $this_port = get_port_by_index_cache($device['device_id'], $lower_if['interface_id_low']); + echo("$br " . generate_port_link($this_port) . ""); + $br = "
"; + } + } } -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 ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) -{ - $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($port['ifIndex'], $device['device_id'])) as $higher_if) -{ - if ($higher_if['interface_id_high']) - { - $this_port = get_port_by_index_cache($device['device_id'], $higher_if['interface_id_high']); - echo("$br " . generate_port_link($this_port) . ""); - $br = "
"; - } -} - -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']) - { - $this_port = get_port_by_index_cache($device['device_id'], $lower_if['interface_id_low']); - echo("$br " . generate_port_link($this_port) . ""); - $br = "
"; - } -} - - unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); diff --git a/includes/dbFacile.php b/includes/dbFacile.php index 2c1d7e791..bd872dff9 100644 --- a/includes/dbFacile.php +++ b/includes/dbFacile.php @@ -30,8 +30,6 @@ function dbQuery($sql, $parameters = array()) { $time_start = microtime(true); */ -# echo($fullSql); - $result = mysql_query($fullSql); // sets $this->result /* if($this->logFile) { @@ -286,6 +284,7 @@ function dbFetchKeyValue($sql, $parameters = array()) { */ function dbMakeQuery($sql, $parameters) { // bypass extra logic if we have no parameters + if(sizeof($parameters) == 0) return $sql; @@ -300,6 +299,7 @@ function dbMakeQuery($sql, $parameters) { $namedParams[ ':' . $key ] = $value; } } + // sort namedParams in reverse to stop substring squashing krsort($namedParams); diff --git a/scripts/removespikes.php b/scripts/removespikes.php index 1d4af1da8..b088ad5b0 100755 --- a/scripts/removespikes.php +++ b/scripts/removespikes.php @@ -1,5 +1,5 @@ -