From 9826e0915affa483819af008c0b0006c0e503252 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Thu, 14 Jul 2016 17:46:50 +1000 Subject: [PATCH 1/2] - Added more colours to the array and added better debugging. --- .../graphs/port/cbqos_bufferdrops.inc.php | 13 ++++++++----- html/includes/graphs/port/cbqos_qosdrops.inc.php | 13 ++++++++----- html/includes/graphs/port/cbqos_traffic.inc.php | 15 +++++++++------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/html/includes/graphs/port/cbqos_bufferdrops.inc.php b/html/includes/graphs/port/cbqos_bufferdrops.inc.php index ea33507623..6f76eaa2a3 100644 --- a/html/includes/graphs/port/cbqos_bufferdrops.inc.php +++ b/html/includes/graphs/port/cbqos_bufferdrops.inc.php @@ -13,6 +13,7 @@ require_once "../includes/component.php"; $component = new component(); +$options = array(); $options['filter']['type'] = array('=','Cisco-CBQOS'); $components = $component->getComponents($device['device_id'],$options); @@ -35,6 +36,7 @@ $rrd_options .= " -l 0 -E "; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_additions = ""; +$colours = array_merge($config['graph_colours']['mixed'],$config['graph_colours']['manycolours'],$config['graph_colours']['manycolours']); $count = 0; foreach ($components as $id => $array) { if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { @@ -47,17 +49,17 @@ foreach ($components as $id => $array) { $stack = ":STACK "; } - // Grab a color from the array. - if ( isset($config['graph_colours']['mixed'][$count]) ) { - $color = $config['graph_colours']['mixed'][$count]; + // Grab a colour from the array. + if ( isset($colours[$count]) ) { + $colour = $colours[$count]; } else { - $color = $config['graph_colours']['oranges'][$count-7]; + d_echo("
Error: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count."
"); } $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; - $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; @@ -69,6 +71,7 @@ foreach ($components as $id => $array) { if ($rrd_additions == "") { // We didn't add any data points. + d_echo("
No DS to add
"); } else { $rrd_options .= $rrd_additions; diff --git a/html/includes/graphs/port/cbqos_qosdrops.inc.php b/html/includes/graphs/port/cbqos_qosdrops.inc.php index 36f856eed5..12d4ab5b66 100644 --- a/html/includes/graphs/port/cbqos_qosdrops.inc.php +++ b/html/includes/graphs/port/cbqos_qosdrops.inc.php @@ -13,6 +13,7 @@ require_once "../includes/component.php"; $component = new component(); +$options = array(); $options['filter']['type'] = array('=','Cisco-CBQOS'); $components = $component->getComponents($device['device_id'],$options); @@ -35,6 +36,7 @@ $rrd_options .= " -l 0 -E "; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_additions = ""; +$colours = array_merge($config['graph_colours']['mixed'],$config['graph_colours']['manycolours'],$config['graph_colours']['manycolours']); $count = 0; foreach ($components as $id => $array) { if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { @@ -47,17 +49,17 @@ foreach ($components as $id => $array) { $stack = ":STACK "; } - // Grab a color from the array. - if ( isset($config['graph_colours']['mixed'][$count]) ) { - $color = $config['graph_colours']['mixed'][$count]; + // Grab a colour from the array. + if ( isset($colours[$count]) ) { + $colour = $colours[$count]; } else { - $color = $config['graph_colours']['oranges'][$count-7]; + d_echo("
Error: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count."
"); } $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":qosdrops:AVERAGE "; $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; - $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; @@ -69,6 +71,7 @@ foreach ($components as $id => $array) { if ($rrd_additions == "") { // We didn't add any data points. + d_echo("
No DS to add
"); } else { $rrd_options .= $rrd_additions; diff --git a/html/includes/graphs/port/cbqos_traffic.inc.php b/html/includes/graphs/port/cbqos_traffic.inc.php index eabd919094..3f16c145a2 100644 --- a/html/includes/graphs/port/cbqos_traffic.inc.php +++ b/html/includes/graphs/port/cbqos_traffic.inc.php @@ -13,6 +13,7 @@ require_once "../includes/component.php"; $component = new component(); +$options = array(); $options['filter']['type'] = array('=','Cisco-CBQOS'); $components = $component->getComponents($device['device_id'],$options); @@ -35,6 +36,7 @@ $rrd_options .= " -l 0 -E "; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_additions = ""; +$colours = array_merge($config['graph_colours']['mixed'],$config['graph_colours']['manycolours'],$config['graph_colours']['manycolours']); $count = 0; foreach ($components as $id => $array) { if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { @@ -47,17 +49,17 @@ foreach ($components as $id => $array) { $stack = ":STACK "; } - // Grab a color from the array. - if ( isset($config['graph_colours']['mixed'][$count]) ) { - $color = $config['graph_colours']['mixed'][$count]; + // Grab a colour from the array. + if ( isset($colours[$count]) ) { + $colour = $colours[$count]; } else { - $color = $config['graph_colours']['oranges'][$count-7]; + d_echo("
Error: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count."
"); } $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":postbits:AVERAGE "; $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; - $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; @@ -68,7 +70,8 @@ foreach ($components as $id => $array) { } if ($rrd_additions == "") { - // We didn't add any data points. + // We didn't add any data sources. + d_echo("
No DS to add
"); } else { $rrd_options .= $rrd_additions; From 6f6b18cbc97404223b9259186107af68dfbcf6ff Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Fri, 15 Jul 2016 07:03:08 +1000 Subject: [PATCH 2/2] - Add the ability to only graph a single class map - Add links to the classes on the policy selector. --- .../graphs/port/cbqos_bufferdrops.inc.php | 73 +++++++++++++------ .../graphs/port/cbqos_qosdrops.inc.php | 73 +++++++++++++------ .../graphs/port/cbqos_traffic.inc.php | 73 +++++++++++++------ html/pages/device/port/cbqos.inc.php | 19 ++++- 4 files changed, 167 insertions(+), 71 deletions(-) diff --git a/html/includes/graphs/port/cbqos_bufferdrops.inc.php b/html/includes/graphs/port/cbqos_bufferdrops.inc.php index 6f76eaa2a3..b08d97e9fc 100644 --- a/html/includes/graphs/port/cbqos_bufferdrops.inc.php +++ b/html/includes/graphs/port/cbqos_bufferdrops.inc.php @@ -38,36 +38,63 @@ $rrd_additions = ""; $colours = array_merge($config['graph_colours']['mixed'],$config['graph_colours']['manycolours'],$config['graph_colours']['manycolours']); $count = 0; + +d_echo("
Policy: ".$vars['policy']);
+d_echo("\nSP-OBJ: ".$components[$vars['policy']]['sp-obj']);
 foreach ($components as $id => $array) {
+    $addtograph = false;
+
+    // We only care about children of the selected policy.
     if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) {
-        $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd");
 
-        if (file_exists($rrd_filename)) {
-            // Stack the area on the second and subsequent DS's
-            $stack = "";
-            if ($count != 0) {
-                $stack = ":STACK ";
+        // Are we trying to only graph a single class?
+        if (isset($vars['class'])) {
+            // Yes, is this the selected class
+            if ($vars['class'] == $id) {
+                $addtograph = true;
             }
-
-            // Grab a colour from the array.
-            if ( isset($colours[$count]) ) {
-                $colour = $colours[$count];
-            }
-            else {
-                d_echo("
Error: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count."
"); - } - - $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; - $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; - $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; - $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; - - $count++; } + else { + // No, Graph everything + $addtograph = true; + } + + // Add the class map to the graph + if ($addtograph === true) { + d_echo("\n Class: ".$components[$id]['label']."\t+ added to the graph"); + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; + } + + // Grab a colour from the array. + if ( isset($colours[$count]) ) { + $colour = $colours[$count]; + } + else { + d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count); + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; + $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; + + $count++; + } // End if file exists + } + else { + d_echo("\n Class: ".$components[$id]['label']."\t- NOT added to the graph"); + } // End if addtograph } } +d_echo("
"); if ($rrd_additions == "") { // We didn't add any data points. diff --git a/html/includes/graphs/port/cbqos_qosdrops.inc.php b/html/includes/graphs/port/cbqos_qosdrops.inc.php index 12d4ab5b66..850ae866bf 100644 --- a/html/includes/graphs/port/cbqos_qosdrops.inc.php +++ b/html/includes/graphs/port/cbqos_qosdrops.inc.php @@ -38,36 +38,63 @@ $rrd_additions = ""; $colours = array_merge($config['graph_colours']['mixed'],$config['graph_colours']['manycolours'],$config['graph_colours']['manycolours']); $count = 0; + +d_echo("
Policy: ".$vars['policy']);
+d_echo("\nSP-OBJ: ".$components[$vars['policy']]['sp-obj']);
 foreach ($components as $id => $array) {
+    $addtograph = false;
+
+    // We only care about children of the selected policy.
     if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) {
-        $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd");
 
-        if (file_exists($rrd_filename)) {
-            // Stack the area on the second and subsequent DS's
-            $stack = "";
-            if ($count != 0) {
-                $stack = ":STACK ";
+        // Are we trying to only graph a single class?
+        if (isset($vars['class'])) {
+            // Yes, is this the selected class
+            if ($vars['class'] == $id) {
+                $addtograph = true;
             }
-
-            // Grab a colour from the array.
-            if ( isset($colours[$count]) ) {
-                $colour = $colours[$count];
-            }
-            else {
-                d_echo("
Error: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count."
"); - } - - $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":qosdrops:AVERAGE "; - $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; - $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; - $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; - - $count++; } + else { + // No, Graph everything + $addtograph = true; + } + + // Add the class map to the graph + if ($addtograph === true) { + d_echo("\n Class: ".$components[$id]['label']."\t+ added to the graph"); + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; + } + + // Grab a colour from the array. + if ( isset($colours[$count]) ) { + $colour = $colours[$count]; + } + else { + d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count); + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":qosdrops:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; + $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; + + $count++; + } // End if file exists + } + else { + d_echo("\n Class: ".$components[$id]['label']."\t- NOT added to the graph"); + } // End if addtograph } } +d_echo("
"); if ($rrd_additions == "") { // We didn't add any data points. diff --git a/html/includes/graphs/port/cbqos_traffic.inc.php b/html/includes/graphs/port/cbqos_traffic.inc.php index 3f16c145a2..995a077311 100644 --- a/html/includes/graphs/port/cbqos_traffic.inc.php +++ b/html/includes/graphs/port/cbqos_traffic.inc.php @@ -38,36 +38,63 @@ $rrd_additions = ""; $colours = array_merge($config['graph_colours']['mixed'],$config['graph_colours']['manycolours'],$config['graph_colours']['manycolours']); $count = 0; + +d_echo("
Policy: ".$vars['policy']);
+d_echo("\nSP-OBJ: ".$components[$vars['policy']]['sp-obj']);
 foreach ($components as $id => $array) {
+    $addtograph = false;
+
+    // We only care about children of the selected policy.
     if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) {
-        $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd");
 
-        if (file_exists($rrd_filename)) {
-            // Stack the area on the second and subsequent DS's
-            $stack = "";
-            if ($count != 0) {
-                $stack = ":STACK ";
+        // Are we trying to only graph a single class?
+        if (isset($vars['class'])) {
+            // Yes, is this the selected class
+            if ($vars['class'] == $id) {
+                $addtograph = true;
             }
-
-            // Grab a colour from the array.
-            if ( isset($colours[$count]) ) {
-                $colour = $colours[$count];
-            }
-            else {
-                d_echo("
Error: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count."
"); - } - - $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":postbits:AVERAGE "; - $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; - $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; - $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; - - $count++; } + else { + // No, Graph everything + $addtograph = true; + } + + // Add the class map to the graph + if ($addtograph === true) { + d_echo("\n Class: ".$components[$id]['label']."\t+ added to the graph"); + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; + } + + // Grab a colour from the array. + if ( isset($colours[$count]) ) { + $colour = $colours[$count]; + } + else { + d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count); + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":postbits:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; + $rrd_additions .= " AREA:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; + + $count++; + } // End if file exists + } + else { + d_echo("\n Class: ".$components[$id]['label']."\t- NOT added to the graph"); + } // End if addtograph } } +d_echo("
"); if ($rrd_additions == "") { // We didn't add any data sources. diff --git a/html/pages/device/port/cbqos.inc.php b/html/pages/device/port/cbqos.inc.php index 5db763cfeb..f74baa0840 100644 --- a/html/pages/device/port/cbqos.inc.php +++ b/html/pages/device/port/cbqos.inc.php @@ -23,10 +23,16 @@ function find_child($components,$parent,$level) { echo "
  • "; if ($array['qos-type'] == 1) { // Its a policy, we need to make it a link. - echo('' . $array['label'] . ''); + $linkvars = array_merge($vars, array('policy' => $id)); + unset($linkvars['class']); + echo('' . $array['label'] . ''); + } + elseif ($array['qos-type'] == 2) { + // Its a class, we need to make it a link. + echo('' . $array['label'] . ''); } else { - // No policy, no link + // Unknown, no link echo $array['label']; } if (isset($array['match'])) { @@ -102,16 +108,25 @@ foreach ($components as $id => $array) { echo "
    "; echo "
    Traffic by CBQoS Class - ".$components[$vars['policy']]['label']."
    "; $graph_array['policy'] = $vars['policy']; + if (isset($vars['class'])) { + $graph_array['class'] = $vars['class']; + } $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']; + if (isset($vars['class'])) { + $graph_array['class'] = $vars['class']; + } $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']; + if (isset($vars['class'])) { + $graph_array['class'] = $vars['class']; + } $graph_type = 'port_cbqos_qosdrops'; include 'includes/print-interface-graphs.inc.php'; echo "
    \n\n";