mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
improve efficiency of devices/ports/, add some caching, fix db profiling.
git-svn-id: http://www.observium.org/svn/observer/trunk@2349 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -250,6 +250,7 @@ function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
if (!isset($args['graph_type'])) { $args['graph_type'] = 'port_bits'; }
|
||||
|
||||
$class = ifclass($args['ifOperStatus'], $args['ifAdminStatus']);
|
||||
|
||||
if (!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); }
|
||||
|
||||
$content = "<div class=list-large>".$args['hostname']." - " . fixifName($args['label']) . "</div>";
|
||||
@@ -273,7 +274,7 @@ function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
|
||||
$url = generate_port_url($args);
|
||||
|
||||
if (port_permitted($args['interface_id'])) {
|
||||
if (port_permitted($args['interface_id'], $args['device_id'])) {
|
||||
return overlib_link($url, $text, $content, $class);
|
||||
} else {
|
||||
return fixifName($text);
|
||||
|
||||
@@ -225,7 +225,7 @@ foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? an
|
||||
{
|
||||
if($higher_if['interface_id_high'])
|
||||
{
|
||||
$this_port = get_port_by_ifIndex($device, $higher_if['interface_id_high']);
|
||||
$this_port = get_port_by_index_cache($device['device_id'], $higher_if['interface_id_high']);
|
||||
echo("$br<img src='images/16/arrow_divide.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>");
|
||||
$br = "<br />";
|
||||
}
|
||||
@@ -235,13 +235,14 @@ foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? a
|
||||
{
|
||||
if($lower_if['interface_id_low'])
|
||||
{
|
||||
$this_port = get_port_by_ifIndex($device, $lower_if['interface_id_low']);
|
||||
$this_port = get_port_by_index_cache($device['device_id'], $lower_if['interface_id_low']);
|
||||
echo("$br<img src='images/16/arrow_join.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>");
|
||||
$br = "<br />";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
+5
-1
@@ -142,7 +142,11 @@ echo('</a>. Copyright © 2006-'. date("Y"). ' by Adam Armstrong. All rights
|
||||
|
||||
if ($config['page_gen'])
|
||||
{
|
||||
echo('<br />MySQL: Cell '.($db_stats['fetchcell']+0).'/'.($db_stats['fetchcell_sec']+0).'s Row '.($db_stats['fetchrow']+0).'/'.($db_stats['fetchrow_sec']+0).'s Rows '.($db_stats['fetchrows']+0).'/'.($db_stats['fetchrows_sec']+0).'s Column '.($db_stats['fetchcol']+0).'/'.($db_stats['fetchcol_sec']+0));
|
||||
echo('<br />MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,2).'s'.
|
||||
' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,2).'s'.
|
||||
' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,2).'s'.
|
||||
' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,2).'s');
|
||||
|
||||
echo('<br />Generated in ' . $gentime . ' seconds.');
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,20 @@ if ($_GET['optc'] == thumbs)
|
||||
if ($_GET['opta'] == "details") { $port_details = 1; }
|
||||
echo("<div style='margin: 0px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
|
||||
$i = "1";
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])) as $interface)
|
||||
|
||||
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++;
|
||||
|
||||
Reference in New Issue
Block a user