- Changed upper case variables to lower case.

This commit is contained in:
Aaron Daniels
2016-01-26 23:31:07 +10:00
parent bf37312bdc
commit e54e22b56e
7 changed files with 184 additions and 185 deletions

View File

@@ -12,19 +12,19 @@
*/ */
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=','Cisco-CBQOS'); $options['filter']['type'] = array('=','Cisco-CBQOS');
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); $components = $component->getComponents($device['device_id'],$options);
// We only care about our device id. // We only care about our device id.
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
// Determine a policy to show. // Determine a policy to show.
if (!isset($vars['policy'])) { if (!isset($vars['policy'])) {
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) {
// Found the first policy // Found the first policy
$vars['policy'] = $ID; $vars['policy'] = $id;
continue; continue;
} }
} }
@@ -35,34 +35,34 @@ $rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'";
$rrd_additions = ""; $rrd_additions = "";
$COUNT = 0; $count = 0;
foreach ($COMPONENTS as $ID => $ARRAY) { 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'])) { 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"); $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd");
if (file_exists($rrd_filename)) { if (file_exists($rrd_filename)) {
// Stack the area on the second and subsequent DS's // Stack the area on the second and subsequent DS's
$STACK = ""; $stack = "";
if ($COUNT != 0) { if ($count != 0) {
$STACK = ":STACK "; $stack = ":STACK ";
} }
// Grab a color from the array. // Grab a color from the array.
if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { if ( isset($config['graph_colours']['mixed'][$count]) ) {
$COLOR = $config['graph_colours']['mixed'][$COUNT]; $color = $config['graph_colours']['mixed'][$count];
} }
else { else {
$COLOR = $config['graph_colours']['oranges'][$COUNT-7]; $color = $config['graph_colours']['oranges'][$count-7];
} }
$rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":bufferdrops:AVERAGE ";
$rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; $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 . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack;
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l ";
$COUNT++; $count++;
} }
} }
} }

View File

@@ -12,19 +12,19 @@
*/ */
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=','Cisco-CBQOS'); $options['filter']['type'] = array('=','Cisco-CBQOS');
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); $components = $component->getComponents($device['device_id'],$options);
// We only care about our device id. // We only care about our device id.
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
// Determine a policy to show. // Determine a policy to show.
if (!isset($vars['policy'])) { if (!isset($vars['policy'])) {
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) {
// Found the first policy // Found the first policy
$vars['policy'] = $ID; $vars['policy'] = $id;
continue; continue;
} }
} }
@@ -35,34 +35,34 @@ $rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'";
$rrd_additions = ""; $rrd_additions = "";
$COUNT = 0; $count = 0;
foreach ($COMPONENTS as $ID => $ARRAY) { 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'])) { 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"); $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd");
if (file_exists($rrd_filename)) { if (file_exists($rrd_filename)) {
// Stack the area on the second and subsequent DS's // Stack the area on the second and subsequent DS's
$STACK = ""; $stack = "";
if ($COUNT != 0) { if ($count != 0) {
$STACK = ":STACK "; $stack = ":STACK ";
} }
// Grab a color from the array. // Grab a color from the array.
if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { if ( isset($config['graph_colours']['mixed'][$count]) ) {
$COLOR = $config['graph_colours']['mixed'][$COUNT]; $color = $config['graph_colours']['mixed'][$count];
} }
else { else {
$COLOR = $config['graph_colours']['oranges'][$COUNT-7]; $color = $config['graph_colours']['oranges'][$count-7];
} }
$rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":qosdrops:AVERAGE "; $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":qosdrops:AVERAGE ";
$rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; $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 . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack;
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l ";
$COUNT++; $count++;
} }
} }
} }

View File

@@ -12,19 +12,19 @@
*/ */
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=','Cisco-CBQOS'); $options['filter']['type'] = array('=','Cisco-CBQOS');
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); $components = $component->getComponents($device['device_id'],$options);
// We only care about our device id. // We only care about our device id.
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
// Determine a policy to show. // Determine a policy to show.
if (!isset($vars['policy'])) { if (!isset($vars['policy'])) {
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) {
// Found the first policy // Found the first policy
$vars['policy'] = $ID; $vars['policy'] = $id;
continue; continue;
} }
} }
@@ -35,34 +35,34 @@ $rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'";
$rrd_additions = ""; $rrd_additions = "";
$COUNT = 0; $count = 0;
foreach ($COMPONENTS as $ID => $ARRAY) { 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'])) { 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"); $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd");
if (file_exists($rrd_filename)) { if (file_exists($rrd_filename)) {
// Stack the area on the second and subsequent DS's // Stack the area on the second and subsequent DS's
$STACK = ""; $stack = "";
if ($COUNT != 0) { if ($count != 0) {
$STACK = ":STACK "; $stack = ":STACK ";
} }
// Grab a color from the array. // Grab a color from the array.
if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { if ( isset($config['graph_colours']['mixed'][$count]) ) {
$COLOR = $config['graph_colours']['mixed'][$COUNT]; $color = $config['graph_colours']['mixed'][$count];
} }
else { else {
$COLOR = $config['graph_colours']['oranges'][$COUNT-7]; $color = $config['graph_colours']['oranges'][$count-7];
} }
$rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":postbits:AVERAGE "; $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":postbits:AVERAGE ";
$rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; $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 . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack;
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
$rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l ";
$COUNT++; $count++;
} }
} }
} }

View File

@@ -11,29 +11,29 @@
* the source code distribution for details. * the source code distribution for details.
*/ */
function find_child($COMPONENTS,$parent,$level) { function find_child($components,$parent,$level) {
global $vars; global $vars;
foreach($COMPONENTS as $ID => $ARRAY) { foreach($components as $id => $array) {
if ($ARRAY['qos-type'] == 3) { if ($array['qos-type'] == 3) {
continue; continue;
} }
if (($ARRAY['parent'] == $COMPONENTS[$parent]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$parent]['sp-id'])) { if (($array['parent'] == $components[$parent]['sp-obj']) && ($array['sp-id'] == $components[$parent]['sp-id'])) {
echo "<ul>"; echo "<ul>";
echo "<li>"; echo "<li>";
if ($ARRAY['qos-type'] == 1) { if ($array['qos-type'] == 1) {
// Its a policy, we need to make it a link. // Its a policy, we need to make it a link.
echo('<a href="' . generate_url($vars, array('policy' => $ID)) . '">' . $ARRAY['label'] . '</a>'); echo('<a href="' . generate_url($vars, array('policy' => $id)) . '">' . $array['label'] . '</a>');
} }
else { else {
// No policy, no link // No policy, no link
echo $ARRAY['label']; echo $array['label'];
} }
if (isset($ARRAY['match'])) { if (isset($array['match'])) {
echo ' ('.$ARRAY['match'].')'; echo ' ('.$array['match'].')';
} }
find_child($COMPONENTS,$ID,$level+1); find_child($components,$id,$level+1);
echo "</li>"; echo "</li>";
echo "</ul>"; echo "</ul>";
@@ -44,23 +44,19 @@ function find_child($COMPONENTS,$parent,$level) {
$rrdarr = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd'); $rrdarr = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd');
if (!empty($rrdarr)) { if (!empty($rrdarr)) {
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=','Cisco-CBQOS'); $options['filter']['type'] = array('=','Cisco-CBQOS');
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); $components = $component->getComponents($device['device_id'],$options);
// We only care about our device id. // We only care about our device id.
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
if (isset($vars['policy'])) { if (!isset($vars['policy'])) {
// if a policy is set try to use it. // not set, find the first parent and use it.
$graph_array['policy'] = $vars['policy']; foreach ($components as $id => $array) {
} if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) {
else {
// if not, 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 // Found the first policy
$graph_array['policy'] = $ID; $vars['policy'] = $id;
continue; continue;
} }
} }
@@ -70,17 +66,17 @@ if (!empty($rrdarr)) {
// Display the ingress policy at the top of the page. // Display the ingress policy at the top of the page.
echo "<div class='col-md-6'><ul class='mktree' id='ingress'>"; echo "<div class='col-md-6'><ul class='mktree' id='ingress'>";
echo '<div><strong><i class="fa fa-sign-in"></i>&nbsp;Ingress Policy:</strong></div>'; echo '<div><strong><i class="fa fa-sign-in"></i>&nbsp;Ingress Policy:</strong></div>';
$FOUND = false; $found = false;
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['direction'] == 1) && ($ARRAY['parent'] == 0) ) { if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['direction'] == 1) && ($array['parent'] == 0) ) {
echo "<li class='liOpen'>"; echo "<li class='liOpen'>";
echo('<a href="' . generate_url($vars, array('policy' => $ID)) . '">' . $ARRAY['label'] . '</a>'); echo('<a href="' . generate_url($vars, array('policy' => $id)) . '">' . $array['label'] . '</a>');
find_child($COMPONENTS,$ID,1); find_child($components,$id,1);
echo "</li>"; echo "</li>";
$FOUND = true; $found = true;
} }
} }
if (!$FOUND) { if (!$found) {
// No Ingress policies // No Ingress policies
echo '<div><i>No Policies</i></div>'; echo '<div><i>No Policies</i></div>';
} }
@@ -89,40 +85,43 @@ if (!empty($rrdarr)) {
// Display the egress policy at the top of the page. // Display the egress policy at the top of the page.
echo "<div class='col-md-6'><ul class='mktree' id='egress'>"; echo "<div class='col-md-6'><ul class='mktree' id='egress'>";
echo '<div><strong><i class="fa fa-sign-out"></i>&nbsp;Egress Policy:</strong></div>'; echo '<div><strong><i class="fa fa-sign-out"></i>&nbsp;Egress Policy:</strong></div>';
$FOUND = false; $found = false;
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['direction'] == 2) && ($ARRAY['parent'] == 0) ) { if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['direction'] == 2) && ($array['parent'] == 0) ) {
echo "<li class='liOpen'>"; echo "<li class='liOpen'>";
echo('<a href="' . generate_url($vars, array('policy' => $ID)) . '">' . $ARRAY['label'] . '</a>'); echo('<a href="' . generate_url($vars, array('policy' => $id)) . '">' . $array['label'] . '</a>');
find_child($COMPONENTS,$ID,1); find_child($components,$id,1);
echo "</li>"; echo "</li>";
$FOUND = true; $found = true;
} }
} }
if (!$FOUND) { if (!$found) {
// No Egress policies // No Egress policies
echo '<div><i>No Policies</i></div>'; echo '<div><i>No Policies</i></div>';
} }
echo "</ul></div>\n\n"; echo "</ul></div>\n\n";
// Let's make sure the policy we are trying to access actually exists. // Let's make sure the policy we are trying to access actually exists.
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ID == $graph_array['policy']) ) { if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($id == $vars['policy']) ) {
// The policy exists. // The policy exists.
echo "<div class='col-md-12'>&nbsp;</div>\n\n"; echo "<div class='col-md-12'>&nbsp;</div>\n\n";
// Display each graph row. // Display each graph row.
echo "<div class='col-md-12'>"; echo "<div class='col-md-12'>";
echo "<div class='graphhead'>Traffic by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."</div>"; echo "<div class='graphhead'>Traffic by CBQoS Class - ".$components[$vars['policy']]['label']."</div>";
$graph_array['policy'] = $vars['policy'];
$graph_type = 'port_cbqos_traffic'; $graph_type = 'port_cbqos_traffic';
include 'includes/print-interface-graphs.inc.php'; include 'includes/print-interface-graphs.inc.php';
echo "<div class='graphhead'>QoS Drops by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."</div>"; echo "<div class='graphhead'>QoS Drops by CBQoS Class - ".$components[$vars['policy']]['label']."</div>";
$graph_array['policy'] = $vars['policy'];
$graph_type = 'port_cbqos_bufferdrops'; $graph_type = 'port_cbqos_bufferdrops';
include 'includes/print-interface-graphs.inc.php'; include 'includes/print-interface-graphs.inc.php';
echo "<div class='graphhead'>Buffer Drops by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."</div>"; echo "<div class='graphhead'>Buffer Drops by CBQoS Class - ".$components[$vars['policy']]['label']."</div>";
$graph_array['policy'] = $vars['policy'];
$graph_type = 'port_cbqos_qosdrops'; $graph_type = 'port_cbqos_qosdrops';
include 'includes/print-interface-graphs.inc.php'; include 'includes/print-interface-graphs.inc.php';
echo "</div>\n\n"; echo "</div>\n\n";

View File

@@ -13,15 +13,15 @@
if ($device['os_group'] == 'cisco') { if ($device['os_group'] == 'cisco') {
$MODULE = 'Cisco-CBQOS'; $module = 'Cisco-CBQOS';
echo $MODULE.': '; echo $module.': ';
require_once 'includes/component.php'; require_once 'includes/component.php';
$COMPONENT = new component(); $component = new component();
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],array('type'=>$MODULE)); $components = $component->getComponents($device['device_id'],array('type'=>$module));
// We only care about our device id. // We only care about our device id.
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
// Begin our master array, all other values will be processed into this array. // Begin our master array, all other values will be processed into this array.
@@ -49,68 +49,68 @@ if ($device['os_group'] == 'cisco') {
foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'] as $spid => $array) { foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'] as $spid => $array) {
foreach ($array as $spobj => $index) { foreach ($array as $spobj => $index) {
$RESULT = array(); $result = array();
// Produce a unique reproducible index for this entry. // Produce a unique reproducible index for this entry.
$RESULT['UID'] = hash('crc32', $spid."-".$spobj); $result['UID'] = hash('crc32', $spid."-".$spobj);
// Now that we have a valid identifiers, lets add some more data // Now that we have a valid identifiers, lets add some more data
$RESULT['sp-id'] = $spid; $result['sp-id'] = $spid;
$RESULT['sp-obj'] = $spobj; $result['sp-obj'] = $spobj;
// Add the Type, Policy-map, Class-map, etc. // Add the Type, Policy-map, Class-map, etc.
$type = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$spobj]; $type = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$spobj];
$RESULT['qos-type'] = $type; $result['qos-type'] = $type;
// Add the Parent, this lets us work out our hierarchy for display later. // Add the Parent, this lets us work out our hierarchy for display later.
$RESULT['parent'] = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid][$spobj]; $result['parent'] = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid][$spobj];
$RESULT['direction'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.3'][$spid]; $result['direction'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.3'][$spid];
$RESULT['ifindex'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.4'][$spid]; $result['ifindex'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.4'][$spid];
// Gather different data depending on the type. // Gather different data depending on the type.
switch ($type) { switch ($type) {
case 1: case 1:
// Policy-map, get data from that table. // Policy-map, get data from that table.
d_echo("\nIndex: ".$index."\n"); d_echo("\nIndex: ".$index."\n");
d_echo(" UID: ".$RESULT['UID']."\n"); d_echo(" UID: ".$result['UID']."\n");
d_echo(" SPID.SPOBJ: ".$RESULT['sp-id'].".".$RESULT['sp-obj']."\n"); d_echo(" SPID.SPOBJ: ".$result['sp-id'].".".$result['sp-obj']."\n");
d_echo(" If-Index: ".$RESULT['ifindex']."\n"); d_echo(" If-Index: ".$result['ifindex']."\n");
d_echo(" Type: 1 - Policy-Map\n"); d_echo(" Type: 1 - Policy-Map\n");
$RESULT['label'] = $tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.1'][$index]; $result['label'] = $tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.1'][$index];
if ($tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index] != "") { if ($tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index] != "") {
$RESULT['label'] .= " - ".$tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index]; $result['label'] .= " - ".$tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index];
} }
d_echo(" Label: ".$RESULT['label']."\n"); d_echo(" Label: ".$result['label']."\n");
break; break;
case 2: case 2:
// Class-map, get data from that table. // Class-map, get data from that table.
d_echo("\nIndex: ".$index."\n"); d_echo("\nIndex: ".$index."\n");
d_echo(" UID: ".$RESULT['UID']."\n"); d_echo(" UID: ".$result['UID']."\n");
d_echo(" SPID.SPOBJ: ".$RESULT['sp-id'].".".$RESULT['sp-obj']."\n"); d_echo(" SPID.SPOBJ: ".$result['sp-id'].".".$result['sp-obj']."\n");
d_echo(" If-Index: ".$RESULT['ifindex']."\n"); d_echo(" If-Index: ".$result['ifindex']."\n");
d_echo(" Type: 2 - Class-Map\n"); d_echo(" Type: 2 - Class-Map\n");
$RESULT['label'] = $tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.1'][$index]; $result['label'] = $tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.1'][$index];
if($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index] != "") { if($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index] != "") {
$RESULT['label'] .= " - ".$tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index]; $result['label'] .= " - ".$tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index];
} }
d_echo(" Label: ".$RESULT['label']."\n"); d_echo(" Label: ".$result['label']."\n");
if ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 2) { if ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 2) {
$RESULT['map-type'] = 'Match-All'; $result['map-type'] = 'Match-All';
} }
elseif ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 3) { elseif ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 3) {
$RESULT['map-type'] = 'Match-Any'; $result['map-type'] = 'Match-Any';
} }
else { else {
$RESULT['map-type'] = 'None'; $result['map-type'] = 'None';
} }
// Find a child, this will be a type 3 // Find a child, this will be a type 3
foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid] as $ID => $VALUE) { foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid] as $id => $value) {
if ($VALUE == $RESULT['sp-obj']) { if ($value == $result['sp-obj']) {
// We have our child, import the match // We have our child, import the match
if ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$ID] == 3) { if ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$id] == 3) {
$RESULT['match'] = $RESULT['map-type'].": ".$tblcbQosMatchStmtCfg['1.3.6.1.4.1.9.9.166.1.8.1.1.1'][$tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'][$spid][$ID]]; $result['match'] = $result['map-type'].": ".$tblcbQosMatchStmtCfg['1.3.6.1.4.1.9.9.166.1.8.1.1.1'][$tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'][$spid][$id]];
d_echo(" Match: ".$RESULT['match']."\n"); d_echo(" Match: ".$result['match']."\n");
} }
} }
} }
@@ -119,7 +119,7 @@ if ($device['os_group'] == 'cisco') {
continue 2; continue 2;
} }
$tblCBQOS[] = $RESULT; $tblCBQOS[] = $result;
} }
} }
@@ -130,25 +130,25 @@ if ($device['os_group'] == 'cisco') {
* Let's loop over the SNMP data to see if we need to ADD or UPDATE any components. * Let's loop over the SNMP data to see if we need to ADD or UPDATE any components.
*/ */
foreach ($tblCBQOS as $key => $array) { foreach ($tblCBQOS as $key => $array) {
$COMPONENT_KEY = false; $component_key = false;
// Loop over our components to determine if the component exists, or we need to add it. // Loop over our components to determine if the component exists, or we need to add it.
foreach ($COMPONENTS as $COMPID => $CHILD) { foreach ($components as $compid => $child) {
if ($CHILD['UID'] === $array['UID']) { if ($child['UID'] === $array['UID']) {
$COMPONENT_KEY = $COMPID; $component_key = $compid;
} }
} }
if (!$COMPONENT_KEY) { if (!$component_key) {
// The component doesn't exist, we need to ADD it - ADD. // The component doesn't exist, we need to ADD it - ADD.
$NEW_COMPONENT = $COMPONENT->createComponent($device['device_id'],$MODULE); $new_component = $component->createComponent($device['device_id'],$module);
$COMPONENT_KEY = key($NEW_COMPONENT); $component_key = key($new_component);
$COMPONENTS[$COMPONENT_KEY] = array_merge($NEW_COMPONENT[$COMPONENT_KEY], $array); $components[$component_key] = array_merge($new_component[$component_key], $array);
echo "+"; echo "+";
} }
else { else {
// The component does exist, merge the details in - UPDATE. // The component does exist, merge the details in - UPDATE.
$COMPONENTS[$COMPONENT_KEY] = array_merge($COMPONENTS[$COMPONENT_KEY], $array); $components[$component_key] = array_merge($components[$component_key], $array);
echo "."; echo ".";
} }
@@ -157,26 +157,26 @@ if ($device['os_group'] == 'cisco') {
/* /*
* Loop over the Component data to see if we need to DELETE any components. * Loop over the Component data to see if we need to DELETE any components.
*/ */
foreach ($COMPONENTS as $key => $array) { foreach ($components as $key => $array) {
// Guilty until proven innocent // Guilty until proven innocent
$FOUND = false; $found = false;
foreach ($tblCBQOS as $k => $v) { foreach ($tblCBQOS as $k => $v) {
if ($array['UID'] == $v['UID']) { if ($array['UID'] == $v['UID']) {
// Yay, we found it... // Yay, we found it...
$FOUND = true; $found = true;
} }
} }
if ($FOUND === false) { if ($found === false) {
// The component has not been found. we should delete it. // The component has not been found. we should delete it.
echo "-"; echo "-";
$COMPONENT->deleteComponent($key); $component->deleteComponent($key);
} }
} }
// Write the Components back to the DB. // Write the Components back to the DB.
$COMPONENT->setComponentPrefs($device['device_id'],$COMPONENTS); $component->setComponentPrefs($device['device_id'],$components);
echo "\n"; echo "\n";
} // End if not error } // End if not error

View File

@@ -13,31 +13,31 @@
if ($device['os_group'] == "cisco") { if ($device['os_group'] == "cisco") {
$MODULE = 'Cisco-CBQOS'; $module = 'Cisco-CBQOS';
require_once 'includes/component.php'; require_once 'includes/component.php';
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=',$MODULE); $options['filter']['type'] = array('=',$module);
$options['filter']['disabled'] = array('=',0); $options['filter']['disabled'] = array('=',0);
$options['filter']['ignore'] = array('=',0); $options['filter']['ignore'] = array('=',0);
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); $components = $component->getComponents($device['device_id'],$options);
// We only care about our device id. // We only care about our device id.
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
// Only collect SNMP data if we have enabled components // Only collect SNMP data if we have enabled components
if (count($COMPONENTS > 0)) { if (count($components > 0)) {
// Let's gather the stats.. // Let's gather the stats..
$tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2); $tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2);
// Loop through the components and extract the data. // Loop through the components and extract the data.
foreach ($COMPONENTS as $KEY => $ARRAY) { foreach ($components as $key => $array) {
$TYPE = $ARRAY['qos-type']; $type = $array['qos-type'];
// Get data from the class table. // Get data from the class table.
if ($TYPE == 2) { if ($type == 2) {
// Let's make sure the RRD is setup for this class. // Let's make sure the rrd is setup for this class.
$filename = "port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"; $filename = "port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename);
if (!file_exists ($rrd_filename)) { if (!file_exists ($rrd_filename)) {
@@ -45,28 +45,28 @@ if ($device['os_group'] == "cisco") {
} }
// Let's print some debugging info. // Let's print some debugging info.
d_echo("\n\nComponent: ".$KEY."\n"); d_echo("\n\nComponent: ".$key."\n");
d_echo(" Class-Map: ".$ARRAY['label']."\n"); d_echo(" Class-Map: ".$array['label']."\n");
d_echo(" SPID.SPOBJ: ".$ARRAY['sp-id'].".".$ARRAY['sp-obj']."\n"); d_echo(" SPID.SPOBJ: ".$array['sp-id'].".".$array['sp-obj']."\n");
d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']]."\n");
d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']]."\n");
d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']]."\n");
$RRD['postbytes'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; $rrd['postbytes'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']];
$RRD['bufferdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; $rrd['bufferdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']];
$RRD['qosdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; $rrd['qosdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']];
// Update RRD // Update rrd
rrdtool_update ($rrd_filename, $RRD); rrdtool_update ($rrd_filename, $rrd);
// Clean-up after yourself! // Clean-up after yourself!
unset($filename, $rrd_filename); unset($filename, $rrd_filename);
} }
} // End foreach components } // End foreach components
echo $MODULE." "; echo $module." ";
} // end if count components } // end if count components
// Clean-up after yourself! // Clean-up after yourself!
unset($TYPE, $COMPONENTS, $COMPONENT, $options, $MODULE); unset($type, $components, $component, $options, $module);
} }

View File

@@ -1293,9 +1293,9 @@ function register_mibs($device, $mibs, $included_by)
* @internal param $string * @internal param $string
* @return array * @return array
*/ */
function snmpwalk_array_num($device,$OID,$indexes=1) { function snmpwalk_array_num($device,$oid,$indexes=1) {
$array = array(); $array = array();
$string = snmp_walk($device, $OID, '-Osqn'); $string = snmp_walk($device, $oid, '-Osqn');
if ( $string === false) { if ( $string === false) {
// False means: No Such Object. // False means: No Such Object.