From f18fa9e455e9daa15d7b0f3600642c3a31e41cbf Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 23 Feb 2016 16:52:37 +1000 Subject: [PATCH] - Pre-Init the $options array. In some scenarios $options was already set with a previous filter. - Remove RRD file checking, test for existance of components instead. --- html/pages/device/port.inc.php | 11 +- html/pages/device/port/cbqos.inc.php | 155 +++++++++++++-------------- 2 files changed, 80 insertions(+), 86 deletions(-) diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index d1682ee56d..ae6668f557 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -87,9 +87,14 @@ if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port[' $menu_options['vlans'] = 'VLANs'; } -// Are there any CBQoS rrd's for this ifIndex? -$cbqos = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd'); -if (!empty($cbqos)) { +// Are there any CBQoS components for this device? +require_once "../includes/component.php"; +$component = new component(); +$options = array(); // Re-init array in case it has been declared previously. +$options['filter']['type'] = array('=','Cisco-CBQOS'); +$components = $component->getComponents($device['device_id'],$options); +$components = $components[$device['device_id']]; // We only care about our device id. +if (count($components) > 0) { $menu_options['cbqos'] = 'CBQoS'; } diff --git a/html/pages/device/port/cbqos.inc.php b/html/pages/device/port/cbqos.inc.php index e85d3de253..5db763cfeb 100644 --- a/html/pages/device/port/cbqos.inc.php +++ b/html/pages/device/port/cbqos.inc.php @@ -41,90 +41,79 @@ function find_child($components,$parent,$level) { } } -$rrdarr = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd'); -if (!empty($rrdarr)) { - require_once "../includes/component.php"; - $component = new component(); - $options['filter']['type'] = array('=','Cisco-CBQOS'); - $components = $component->getComponents($device['device_id'],$options); - - // We only care about our device id. - $components = $components[$device['device_id']]; - - if (!isset($vars['policy'])) { - // not set, find the first parent and use it. - foreach ($components as $id => $array) { - if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) { - // Found the first policy - $vars['policy'] = $id; - continue; - } - } - } - echo "\n\n"; - - // Display the ingress policy at the top of the page. - echo "
'; - - // Display the egress policy at the top of the page. - echo "
\n\n"; - - // Let's make sure the policy we are trying to access actually exists. - foreach ($components as $id => $array) { - if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($id == $vars['policy']) ) { - // The policy exists. - - echo "
 
\n\n"; - - // Display each graph row. - echo "
"; - echo "
Traffic by CBQoS Class - ".$components[$vars['policy']]['label']."
"; - $graph_array['policy'] = $vars['policy']; - $graph_type = 'port_cbqos_traffic'; - include 'includes/print-interface-graphs.inc.php'; - - echo "
QoS Drops by CBQoS Class - ".$components[$vars['policy']]['label']."
"; - $graph_array['policy'] = $vars['policy']; - $graph_type = 'port_cbqos_bufferdrops'; - include 'includes/print-interface-graphs.inc.php'; - - echo "
Buffer Drops by CBQoS Class - ".$components[$vars['policy']]['label']."
"; - $graph_array['policy'] = $vars['policy']; - $graph_type = 'port_cbqos_qosdrops'; - include 'includes/print-interface-graphs.inc.php'; - echo "
\n\n"; + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) { + // Found the first policy + $vars['policy'] = $id; + continue; } } } +echo "\n\n"; + +// Display the ingress policy at the top of the page. +echo "
'; + +// Display the egress policy at the top of the page. +echo "
\n\n"; + +// Let's make sure the policy we are trying to access actually exists. +foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($id == $vars['policy']) ) { + // The policy exists. + + echo "
 
\n\n"; + + // Display each graph row. + echo "
"; + echo "
Traffic by CBQoS Class - ".$components[$vars['policy']]['label']."
"; + $graph_array['policy'] = $vars['policy']; + $graph_type = 'port_cbqos_traffic'; + include 'includes/print-interface-graphs.inc.php'; + + echo "
QoS Drops by CBQoS Class - ".$components[$vars['policy']]['label']."
"; + $graph_array['policy'] = $vars['policy']; + $graph_type = 'port_cbqos_bufferdrops'; + include 'includes/print-interface-graphs.inc.php'; + + echo "
Buffer Drops by CBQoS Class - ".$components[$vars['policy']]['label']."
"; + $graph_array['policy'] = $vars['policy']; + $graph_type = 'port_cbqos_qosdrops'; + include 'includes/print-interface-graphs.inc.php'; + echo "
\n\n"; + } +}