- Changed upper case variables to lower case.

This commit is contained in:
Aaron Daniels
2016-01-28 07:04:12 +10:00
parent 8f4dbb5338
commit d96e2216a7
8 changed files with 253 additions and 247 deletions
@@ -12,44 +12,44 @@
*/ */
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=','Cisco-OTV'); $options['filter']['type'] = array('=','Cisco-OTV');
$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']];
include "includes/graphs/common.inc.php"; include "includes/graphs/common.inc.php";
$rrd_options .= " -l 0 -E "; $rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'MAC Addresses Now Min Max\\n'"; $rrd_options .= " COMMENT:'MAC Addresses Now Min Max\\n'";
$rrd_additions = ""; $rrd_additions = "";
$COUNT = 0; $count = 0;
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ($ARRAY['otvtype'] == 'endpoint') { if ($array['otvtype'] == 'endpoint') {
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$ARRAY['endpoint']."-mac.rrd"); $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$array['endpoint']."-mac.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 . ":count:AVERAGE "; $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":count:AVERAGE ";
$rrd_additions .= " AREA:DS" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['endpoint'],0,15),15) . "'" . $STACK; $rrd_additions .= " AREA:DS" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['endpoint'],0,15),15) . "'" . $stack;
$rrd_additions .= " GPRINT:DS" . $COUNT . ":LAST:%4.0lf%s "; $rrd_additions .= " GPRINT:DS" . $count . ":LAST:%4.0lf%s ";
$rrd_additions .= " GPRINT:DS" . $COUNT . ":MIN:%4.0lf%s "; $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%4.0lf%s ";
$rrd_additions .= " GPRINT:DS" . $COUNT . ":MAX:%4.0lf%s\\\l "; $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%4.0lf%s\\\l ";
$COUNT++; $count++;
} }
} }
} }
@@ -12,44 +12,44 @@
*/ */
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['filter']['type'] = array('=','Cisco-OTV'); $options['filter']['type'] = array('=','Cisco-OTV');
$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']];
include "includes/graphs/common.inc.php"; include "includes/graphs/common.inc.php";
$rrd_options .= " -l 0 -E "; $rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'VLANs Now Min Max\\n'"; $rrd_options .= " COMMENT:'VLANs Now Min Max\\n'";
$rrd_additions = ""; $rrd_additions = "";
$COUNT = 0; $count = 0;
foreach ($COMPONENTS as $ID => $ARRAY) { foreach ($components as $id => $array) {
if ($ARRAY['otvtype'] == 'overlay') { if ($array['otvtype'] == 'overlay') {
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$ARRAY['label']."-vlan.rrd"); $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$array['label']."-vlan.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 . ":count:AVERAGE "; $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":count:AVERAGE ";
$rrd_additions .= " AREA:DS" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; $rrd_additions .= " AREA:DS" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack;
$rrd_additions .= " GPRINT:DS" . $COUNT . ":LAST:%4.0lf%s "; $rrd_additions .= " GPRINT:DS" . $count . ":LAST:%4.0lf%s ";
$rrd_additions .= " GPRINT:DS" . $COUNT . ":MIN:%4.0lf%s "; $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%4.0lf%s ";
$rrd_additions .= " GPRINT:DS" . $COUNT . ":MAX:%4.0lf%s\\\l "; $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%4.0lf%s\\\l ";
$COUNT++; $count++;
} }
} }
} }
+3 -3
View File
@@ -421,10 +421,10 @@ $routing_count['cef'] = dbFetchCell("SELECT COUNT(cef_switching_id) from `cef_s
$routing_count['vrf'] = dbFetchCell("SELECT COUNT(vrf_id) from `vrfs`"); $routing_count['vrf'] = dbFetchCell("SELECT COUNT(vrf_id) from `vrfs`");
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['type'] = 'Cisco-OTV'; $options['type'] = 'Cisco-OTV';
$OTV = $COMPONENT->getComponents(null,$options); $otv = $component->getComponents(null,$options);
$routing_count['cisco-otv'] = count($OTV); $routing_count['cisco-otv'] = count($otv);
if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']+$routing_count['cisco-otv']) > "0") { if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']+$routing_count['cisco-otv']) > "0") {
+3 -3
View File
@@ -211,11 +211,11 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
} }
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options['type'] = 'Cisco-OTV'; $options['type'] = 'Cisco-OTV';
$options['filter']['device_id'] = array('=',$device['device_id']); $options['filter']['device_id'] = array('=',$device['device_id']);
$OTV = $COMPONENT->getComponents(null,$options); $otv = $component->getComponents(null,$options);
$device_routing_count['cisco-otv'] = count($OTV); $device_routing_count['cisco-otv'] = count($otv);
if ($device_routing_count['cisco-otv'] > 0) { if ($device_routing_count['cisco-otv'] > 0) {
$routing_tabs[] = 'cisco-otv'; $routing_tabs[] = 'cisco-otv';
} }
+20 -20
View File
@@ -1,12 +1,12 @@
<?php <?php
require_once "../includes/component.php"; require_once "../includes/component.php";
$COMPONENT = new component(); $component = new component();
$options = array(); $options = array();
$options['filter']['ignore'] = array('=',0); $options['filter']['ignore'] = array('=',0);
$options['type'] = 'Cisco-OTV'; $options['type'] = 'Cisco-OTV';
$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); $components = $component->getComponents($device['device_id'],$options);
$COMPONENTS = $COMPONENTS[$device['device_id']]; $components = $components[$device['device_id']];
global $config; global $config;
?> ?>
@@ -17,32 +17,32 @@ global $config;
<div class="panel list-group"> <div class="panel list-group">
<?php <?php
// Loop over each component, pulling out the Overlays. // Loop over each component, pulling out the Overlays.
foreach ($COMPONENTS as $OID => $OVERLAY) { foreach ($components as $oid => $overlay) {
if ($OVERLAY['otvtype'] == 'overlay') { if ($overlay['otvtype'] == 'overlay') {
if ($OVERLAY['status'] == 1) { if ($overlay['status'] == 1) {
$OVERLAY_STATUS = "<span class='green pull-right'>Normal</span>"; $overlay_status = "<span class='green pull-right'>Normal</span>";
$GLI = ""; $gli = "";
} }
else { else {
$OVERLAY_STATUS = "<span class='pull-right'>".$OVERLAY['error']." - <span class='red'>Alert</span></span>"; $overlay_status = "<span class='pull-right'>".$overlay['error']." - <span class='red'>Alert</span></span>";
$GLI = "list-group-item-danger"; $gli = "list-group-item-danger";
} }
?> ?>
<a class="list-group-item <?=$GLI?>" data-toggle="collapse" data-target="#<?=$OVERLAY['index']?>" data-parent="#overlays"><?=$OVERLAY['label']?> - <?=$OVERLAY['transport']?> <?=$OVERLAY_STATUS?></a> <a class="list-group-item <?=$gli?>" data-toggle="collapse" data-target="#<?=$overlay['index']?>" data-parent="#overlays"><?=$overlay['label']?> - <?=$overlay['transport']?> <?=$overlay_status?></a>
<div id="<?=$OVERLAY['index']?>" class="sublinks collapse"> <div id="<?=$overlay['index']?>" class="sublinks collapse">
<?php <?php
foreach ($COMPONENTS as $AID => $ADJACENCY) { foreach ($components as $aid => $adjacency) {
if (($ADJACENCY['otvtype'] == 'adjacency') && ($ADJACENCY['index'] == $OVERLAY['index'])) { if (($adjacency['otvtype'] == 'adjacency') && ($adjacency['index'] == $overlay['index'])) {
if ($ADJACENCY['status'] == 1) { if ($adjacency['status'] == 1) {
$ADJ_STATUS = "<span class='green pull-right'>Normal</span>"; $adj_status = "<span class='green pull-right'>Normal</span>";
$GLI = ""; $gli = "";
} }
else { else {
$ADJ_STATUS = "<span class='pull-right'>".$ADJACENCY['error']." - <span class='red'>Alert</span></span>"; $adj_status = "<span class='pull-right'>".$adjacency['error']." - <span class='red'>Alert</span></span>";
$GLI = "list-group-item-danger"; $gli = "list-group-item-danger";
} }
?> ?>
<a class="list-group-item <?=$GLI?> small"><span class="glyphicon glyphicon-chevron-right"></span> <?=$ADJACENCY['label']?> - <?=$ADJACENCY['endpoint']?> <?=$ADJ_STATUS?></a> <a class="list-group-item <?=$gli?> small"><span class="glyphicon glyphicon-chevron-right"></span> <?=$adjacency['label']?> - <?=$adjacency['endpoint']?> <?=$adj_status?></a>
<?php <?php
} }
} }
+104 -101
View File
@@ -14,55 +14,58 @@
if ($device['os_group'] == 'cisco') { if ($device['os_group'] == 'cisco') {
// Define some error messages // Define some error messages
$ERROR_VPN[0] = "Other"; $error_vpn = array();
$ERROR_VPN[1] = "Configuration changed"; $error_vpn[0] = "Other";
$ERROR_VPN[2] = "Control Group information is unavailable"; $error_vpn[1] = "Configuration changed";
$ERROR_VPN[3] = "Data Group range information is unavailable"; $error_vpn[2] = "Control Group information is unavailable";
$ERROR_VPN[4] = "Join or Source interface information is unavailable"; $error_vpn[3] = "Data Group range information is unavailable";
$ERROR_VPN[5] = "VPN name is unavailable"; $error_vpn[4] = "Join or Source interface information is unavailable";
$ERROR_VPN[6] = "IP address is missing for Join Interface"; $error_vpn[5] = "VPN name is unavailable";
$ERROR_VPN[7] = "Join Interface is down"; $error_vpn[6] = "IP address is missing for Join Interface";
$ERROR_VPN[8] = "Overlay is administratively shutdown"; $error_vpn[7] = "Join Interface is down";
$ERROR_VPN[9] = "Overlay is in delete hold down phase"; $error_vpn[8] = "Overlay is administratively shutdown";
$ERROR_VPN[10] = "VPN is reinitializing"; $error_vpn[9] = "Overlay is in delete hold down phase";
$ERROR_VPN[11] = "Site ID information is unavailable"; $error_vpn[10] = "VPN is reinitializing";
$ERROR_VPN[12] = "Site ID mismatch has occurred"; $error_vpn[11] = "Site ID information is unavailable";
$ERROR_VPN[13] = "IP address is missing for Source Interface"; $error_vpn[12] = "Site ID mismatch has occurred";
$ERROR_VPN[14] = "Source interface is down"; $error_vpn[13] = "IP address is missing for Source Interface";
$ERROR_VPN[15] = "Changing site identifier"; $error_vpn[14] = "Source interface is down";
$ERROR_VPN[16] = "Changing control group"; $error_vpn[15] = "Changing site identifier";
$ERROR_VPN[17] = "Device ID information is unavailable"; $error_vpn[16] = "Changing control group";
$ERROR_VPN[18] = "Changing device ID"; $error_vpn[17] = "Device ID information is unavailable";
$ERROR_VPN[19] = "Cleanup in progress"; $error_vpn[18] = "Changing device ID";
$error_vpn[19] = "Cleanup in progress";
$ERROR_AED[0] = "Other"; $error_aed = array();
$ERROR_AED[1] = "Overlay is Down"; $error_aed[0] = "Other";
$ERROR_AED[2] = "Site ID is not configured"; $error_aed[1] = "Overlay is Down";
$ERROR_AED[3] = "Site ID mismatch"; $error_aed[2] = "Site ID is not configured";
$ERROR_AED[4] = "Version mismatch"; $error_aed[3] = "Site ID mismatch";
$ERROR_AED[5] = "Site VLAN is Down"; $error_aed[4] = "Version mismatch";
$ERROR_AED[6] = "No extended VLAN is operationally up"; $error_aed[5] = "Site VLAN is Down";
$ERROR_AED[7] = "No Overlay Adjacency is up"; $error_aed[6] = "No extended VLAN is operationally up";
$ERROR_AED[8] = "LSPDB sync incomplete"; $error_aed[7] = "No Overlay Adjacency is up";
$ERROR_AED[9] = "Overlay state down event in progress"; $error_aed[8] = "LSPDB sync incomplete";
$ERROR_AED[10] = "ISIS control group sync pending"; $error_aed[9] = "Overlay state down event in progress";
$error_aed[10] = "ISIS control group sync pending";
$ERROR_OVERLAY[1] = "active"; $error_overlay = array();
$ERROR_OVERLAY[2] = "notInService"; $error_overlay[1] = "active";
$ERROR_OVERLAY[3] = "notReady"; $error_overlay[2] = "notInService";
$ERROR_OVERLAY[4] = "createAndGo"; $error_overlay[3] = "notReady";
$ERROR_OVERLAY[5] = "createAndWait"; $error_overlay[4] = "createAndGo";
$ERROR_OVERLAY[6] = "destroy"; $error_overlay[5] = "createAndWait";
$error_overlay[6] = "destroy";
$MODULE = 'Cisco-OTV'; $module = 'Cisco-OTV';
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.
$tblOTV = array(); $tblOTV = array();
@@ -86,92 +89,92 @@ if ($device['os_group'] == 'cisco') {
// Add each overlay to the array. // Add each overlay to the array.
foreach ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.2'] as $index => $name) { foreach ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.2'] as $index => $name) {
$RESULT = array(); $result = array();
$message = false; $message = false;
$RESULT['index'] = $index; $result['index'] = $index;
$RESULT['label'] = $name; $result['label'] = $name;
if ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.15'][$index] == 1) { if ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.15'][$index] == 1) {
$RESULT['transport'] = 'Multicast'; $result['transport'] = 'Multicast';
} }
else { else {
$RESULT['transport'] = 'Unicast'; $result['transport'] = 'Unicast';
} }
$RESULT['otvtype'] = 'overlay'; $result['otvtype'] = 'overlay';
$RESULT['UID'] = $RESULT['otvtype']."-".$RESULT['index']; $result['UID'] = $result['otvtype']."-".$result['index'];
$RESULT['vpn_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$index]; $result['vpn_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$index];
if ($RESULT['vpn_state'] != 2) { if ($result['vpn_state'] != 2) {
$message .= "VPN Down: ".$ERROR_VPN[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$index]]."\n"; $message .= "VPN Down: ".$error_vpn[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$index]]."\n";
} }
$RESULT['aed_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$index]; $result['aed_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$index];
if ($RESULT['aed_state'] == 2) { if ($result['aed_state'] == 2) {
$message .= "AED Down: ".$ERROR_AED[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.14'][$index]]."\n"; $message .= "AED Down: ".$error_aed[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.14'][$index]]."\n";
} }
$RESULT['overlay_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$index]; $result['overlay_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$index];
if ($RESULT['overlay_state'] == 2) { if ($result['overlay_state'] == 2) {
$message .= "Overlay Down: ".$ERROR_OVERLAY[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.24'][$index]]."\n"; $message .= "Overlay Down: ".$error_overlay[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.24'][$index]]."\n";
} }
// If we have set a message, we have an error, activate alert. // If we have set a message, we have an error, activate alert.
if ($message !== false) { if ($message !== false) {
$RESULT['error'] = $message; $result['error'] = $message;
$RESULT['status'] = 0; $result['status'] = 0;
} }
else { else {
$RESULT['error'] = ""; $result['error'] = "";
$RESULT['status'] = 1; $result['status'] = 1;
} }
// Add the result to the parent array. // Add the result to the parent array.
$tblOTV[] = $RESULT; $tblOTV[] = $result;
} }
// Add each adjacency to the array. // Add each adjacency to the array.
foreach ($tblAdjacentDevName as $key => $value) { foreach ($tblAdjacentDevName as $key => $value) {
preg_match('/^1.3.6.1.4.1.9.9.810.1.3.1.1.4.(\d+).1.4.(\d+.\d+.\d+.\d+)$/', $key, $MATCHES); preg_match('/^1.3.6.1.4.1.9.9.810.1.3.1.1.4.(\d+).1.4.(\d+.\d+.\d+.\d+)$/', $key, $matches);
$RESULT = array(); $result = array();
$RESULT['index'] = $MATCHES[1]; $result['index'] = $matches[1];
$RESULT['endpoint'] = $MATCHES[2]; $result['endpoint'] = $matches[2];
$tblEndpoints[$value] = true; $tblEndpoints[$value] = true;
$RESULT['otvtype'] = 'adjacency'; $result['otvtype'] = 'adjacency';
$RESULT['UID'] = $RESULT['otvtype']."-".$RESULT['index']."-".str_replace(' ', '', $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.3.'.$RESULT['index'].'.1.4.'.$RESULT['endpoint']]); $result['UID'] = $result['otvtype']."-".$result['index']."-".str_replace(' ', '', $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.3.'.$result['index'].'.1.4.'.$result['endpoint']]);
$RESULT['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$RESULT['index'].'.1.4.'.$RESULT['endpoint']]; $result['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$result['index'].'.1.4.'.$result['endpoint']];
$message = false; $message = false;
if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.5.'.$RESULT['index'].'.1.4.'.$RESULT['endpoint']] != 1) { if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.5.'.$result['index'].'.1.4.'.$result['endpoint']] != 1) {
$message .= "Adjacency is Down\n"; $message .= "Adjacency is Down\n";
} }
// If we have set a message, we have an error, activate alert. // If we have set a message, we have an error, activate alert.
if ($message !== false) { if ($message !== false) {
$RESULT['error'] = $message; $result['error'] = $message;
$RESULT['status'] = 0; $result['status'] = 0;
} }
else { else {
$RESULT['error'] = ""; $result['error'] = "";
$RESULT['status'] = 1; $result['status'] = 1;
} }
// Set a default name, if for some unknown reason we cant find the parent VPN. // Set a default name, if for some unknown reason we cant find the parent VPN.
$RESULT['label'] = "Unknown (".$RESULT['index'].") - ".$value; $result['label'] = "Unknown (".$result['index'].") - ".$value;
// We need to search the existing array to build the name // We need to search the existing array to build the name
foreach ($tblOTV as $ITEM) { foreach ($tblOTV as $item) {
if (($ITEM['otvtype'] == 'overlay') && ($ITEM['index'] == $RESULT['index'])) { if (($item['otvtype'] == 'overlay') && ($item['index'] == $result['index'])) {
$RESULT['label'] = $ITEM['label']." - ".$value; $result['label'] = $item['label']." - ".$value;
} }
} }
// Add the result to the parent array. // Add the result to the parent array.
$tblOTV[] = $RESULT; $tblOTV[] = $result;
} }
// We retain a list of all endpoints to tie the RRD to. // We retain a list of all endpoints to tie the RRD to.
foreach ($tblEndpoints as $K => $V) { foreach ($tblEndpoints as $k => $v) {
$RESULT['label'] = "Endpoint: ".$K; $result['label'] = "Endpoint: ".$k;
$RESULT['otvtype'] = 'endpoint'; $result['otvtype'] = 'endpoint';
$RESULT['endpoint'] = $K; $result['endpoint'] = $k;
$RESULT['UID'] = $RESULT['otvtype']."-".$K; $result['UID'] = $result['otvtype']."-".$k;
// Add the result to the parent array. // Add the result to the parent array.
$tblOTV[] = $RESULT; $tblOTV[] = $result;
} }
/* /*
@@ -181,25 +184,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 ($tblOTV as $key => $array) { foreach ($tblOTV 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 ".";
} }
@@ -208,26 +211,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 ($tblOTV as $k => $v) { foreach ($tblOTV 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
+83 -80
View File
@@ -14,59 +14,62 @@
if ($device['os_group'] == "cisco") { if ($device['os_group'] == "cisco") {
// Define some error messages // Define some error messages
$ERROR_VPN[0] = "Other"; $error_vpn = array();
$ERROR_VPN[1] = "Configuration changed"; $error_vpn[0] = "Other";
$ERROR_VPN[2] = "Control Group information is unavailable"; $error_vpn[1] = "Configuration changed";
$ERROR_VPN[3] = "Data Group range information is unavailable"; $error_vpn[2] = "Control Group information is unavailable";
$ERROR_VPN[4] = "Join or Source interface information is unavailable"; $error_vpn[3] = "Data Group range information is unavailable";
$ERROR_VPN[5] = "VPN name is unavailable"; $error_vpn[4] = "Join or Source interface information is unavailable";
$ERROR_VPN[6] = "IP address is missing for Join Interface"; $error_vpn[5] = "VPN name is unavailable";
$ERROR_VPN[7] = "Join Interface is down"; $error_vpn[6] = "IP address is missing for Join Interface";
$ERROR_VPN[8] = "Overlay is administratively shutdown"; $error_vpn[7] = "Join Interface is down";
$ERROR_VPN[9] = "Overlay is in delete hold down phase"; $error_vpn[8] = "Overlay is administratively shutdown";
$ERROR_VPN[10] = "VPN is reinitializing"; $error_vpn[9] = "Overlay is in delete hold down phase";
$ERROR_VPN[11] = "Site ID information is unavailable"; $error_vpn[10] = "VPN is reinitializing";
$ERROR_VPN[12] = "Site ID mismatch has occurred"; $error_vpn[11] = "Site ID information is unavailable";
$ERROR_VPN[13] = "IP address is missing for Source Interface"; $error_vpn[12] = "Site ID mismatch has occurred";
$ERROR_VPN[14] = "Source interface is down"; $error_vpn[13] = "IP address is missing for Source Interface";
$ERROR_VPN[15] = "Changing site identifier"; $error_vpn[14] = "Source interface is down";
$ERROR_VPN[16] = "Changing control group"; $error_vpn[15] = "Changing site identifier";
$ERROR_VPN[17] = "Device ID information is unavailable"; $error_vpn[16] = "Changing control group";
$ERROR_VPN[18] = "Changing device ID"; $error_vpn[17] = "Device ID information is unavailable";
$ERROR_VPN[19] = "Cleanup in progress"; $error_vpn[18] = "Changing device ID";
$error_vpn[19] = "Cleanup in progress";
$ERROR_AED[0] = "Other"; $error_aed = array();
$ERROR_AED[1] = "Overlay is Down"; $error_aed[0] = "Other";
$ERROR_AED[2] = "Site ID is not configured"; $error_aed[1] = "Overlay is Down";
$ERROR_AED[3] = "Site ID mismatch"; $error_aed[2] = "Site ID is not configured";
$ERROR_AED[4] = "Version mismatch"; $error_aed[3] = "Site ID mismatch";
$ERROR_AED[5] = "Site VLAN is Down"; $error_aed[4] = "Version mismatch";
$ERROR_AED[6] = "No extended VLAN is operationally up"; $error_aed[5] = "Site VLAN is Down";
$ERROR_AED[7] = "No Overlay Adjacency is up"; $error_aed[6] = "No extended VLAN is operationally up";
$ERROR_AED[8] = "LSPDB sync incomplete"; $error_aed[7] = "No Overlay Adjacency is up";
$ERROR_AED[9] = "Overlay state down event in progress"; $error_aed[8] = "LSPDB sync incomplete";
$ERROR_AED[10] = "ISIS control group sync pending"; $error_aed[9] = "Overlay state down event in progress";
$error_aed[10] = "ISIS control group sync pending";
$ERROR_OVERLAY[1] = "active"; $error_overlay = array();
$ERROR_OVERLAY[2] = "notInService"; $error_overlay[1] = "active";
$ERROR_OVERLAY[3] = "notReady"; $error_overlay[2] = "notInService";
$ERROR_OVERLAY[4] = "createAndGo"; $error_overlay[3] = "notReady";
$ERROR_OVERLAY[5] = "createAndWait"; $error_overlay[4] = "createAndGo";
$ERROR_OVERLAY[6] = "destroy"; $error_overlay[5] = "createAndWait";
$error_overlay[6] = "destroy";
$MODULE = 'Cisco-OTV'; $module = 'Cisco-OTV';
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);
$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..
$tblOverlayEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.1.1'); $tblOverlayEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.1.1');
$tblAdjacencyDatabaseEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1', 0); $tblAdjacencyDatabaseEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1', 0);
@@ -74,89 +77,89 @@ if ($device['os_group'] == "cisco") {
$tblVlanEdgeDevIsAed = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.2.1.6', 2); $tblVlanEdgeDevIsAed = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.2.1.6', 2);
// Let's create an array of each remote OTV endpoint and the count of MAC addresses that are reachable via. // Let's create an array of each remote OTV endpoint and the count of MAC addresses that are reachable via.
$COUNT_MAC = array(); $count_mac = array();
foreach ($tblRouteNextHopAddr as $k => $v) { foreach ($tblRouteNextHopAddr as $k => $v) {
$COUNT_MAC[$v]++; $count_mac[$v]++;
} }
// 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) {
if ($ARRAY['otvtype'] == 'overlay') { if ($array['otvtype'] == 'overlay') {
// Let's check the varius status' of the overlay // Let's check the varius status' of the overlay
$message = false; $message = false;
$vpn_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$ARRAY['index']]; $vpn_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$array['index']];
if ($vpn_state != 2) { if ($vpn_state != 2) {
$message .= "VPN Down: ".$ERROR_VPN[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$ARRAY['index']]]; $message .= "VPN Down: ".$error_vpn[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$array['index']]];
} }
$aed_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$ARRAY['index']]; $aed_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$array['index']];
if ($aed_state == 2) { if ($aed_state == 2) {
$message .= "AED Down: ".$ERROR_AED[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.14'][$ARRAY['index']]]; $message .= "AED Down: ".$error_aed[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.14'][$array['index']]];
} }
$overlay_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$ARRAY['index']]; $overlay_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$array['index']];
if ($overlay_state == 2) { if ($overlay_state == 2) {
$message .= "Overlay Down: ".$ERROR_OVERLAY[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.24'][$ARRAY['index']]]; $message .= "Overlay Down: ".$error_overlay[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.24'][$array['index']]];
} }
// If we have set a message, we have an error, activate alert. // If we have set a message, we have an error, activate alert.
if ($message !== false) { if ($message !== false) {
$ARRAY['error'] = $message; $array['error'] = $message;
$ARRAY['status'] = 0; $array['status'] = 0;
} }
else { else {
$ARRAY['error'] = ""; $array['error'] = "";
$ARRAY['status'] = 1; $array['status'] = 1;
} }
// Time to graph the count of the active VLAN's on this overlay. // Time to graph the count of the active VLAN's on this overlay.
$COUNT_VLAN = 0; $count_vlan = 0;
foreach ($tblVlanEdgeDevIsAed['1.3.6.1.4.1.9.9.810.1.2.2.1.6'][$ARRAY['index']] as $v) { foreach ($tblVlanEdgeDevIsAed['1.3.6.1.4.1.9.9.810.1.2.2.1.6'][$array['index']] as $v) {
if ($v == 1) { if ($v == 1) {
$COUNT_VLAN++; $count_vlan++;
} }
} }
$filename = "cisco-otv-".$ARRAY['label']."-vlan.rrd"; $filename = "cisco-otv-".$array['label']."-vlan.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)) {
rrdtool_create ($rrd_filename, " DS:count:GAUGE:600:0:U" . $config['rrd_rra']); rrdtool_create ($rrd_filename, " DS:count:GAUGE:600:0:U" . $config['rrd_rra']);
} }
$RRD['count'] = $COUNT_VLAN; $rrd['count'] = $count_vlan;
// Update RRD // Update RRD
rrdtool_update ($rrd_filename, $RRD); rrdtool_update ($rrd_filename, $rrd);
} }
elseif ($ARRAY['otvtype'] == 'adjacency') { elseif ($array['otvtype'] == 'adjacency') {
$ARRAY['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$ARRAY['index'].'.1.4.'.$ARRAY['endpoint']]; $array['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$array['index'].'.1.4.'.$array['endpoint']];
$message = false; $message = false;
if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.5.'.$ARRAY['index'].'.1.4.'.$ARRAY['endpoint']] != 1) { if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.5.'.$array['index'].'.1.4.'.$array['endpoint']] != 1) {
$message .= "Adjacency is Down\n"; $message .= "Adjacency is Down\n";
} }
if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$ARRAY['index'].'.1.4.'.$ARRAY['endpoint']] < $ARRAY['uptime']) { if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$array['index'].'.1.4.'.$array['endpoint']] < $array['uptime']) {
$message .= "Adjacency has been reset\n"; $message .= "Adjacency has been reset\n";
} }
// If we have set a message, we have an error, activate alert. // If we have set a message, we have an error, activate alert.
if ($message !== false) { if ($message !== false) {
$ARRAY['error'] = $message; $array['error'] = $message;
$ARRAY['status'] = 0; $array['status'] = 0;
} }
else { else {
$ARRAY['error'] = ""; $array['error'] = "";
$ARRAY['status'] = 1; $array['status'] = 1;
} }
} }
elseif ($ARRAY['otvtype'] == 'endpoint') { elseif ($array['otvtype'] == 'endpoint') {
if (isset($COUNT_MAC[$ARRAY['endpoint']])) { if (isset($count_mac[$array['endpoint']])) {
$RRD['count'] = $COUNT_MAC[$ARRAY['endpoint']]; $rrd['count'] = $count_mac[$array['endpoint']];
} }
else { else {
$RRD['count'] = "0"; $rrd['count'] = "0";
} }
$filename = "cisco-otv-".$ARRAY['endpoint']."-mac.rrd"; $filename = "cisco-otv-".$array['endpoint']."-mac.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)) {
@@ -164,18 +167,18 @@ if ($device['os_group'] == "cisco") {
} }
// Update RRD // Update RRD
rrdtool_update ($rrd_filename, $RRD); rrdtool_update ($rrd_filename, $rrd);
} // End If } // End If
} // End foreach components } // End foreach components
// 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 $MODULE." "; echo $module." ";
} // end if count components } // end if count components
// Clean-up after yourself! // Clean-up after yourself!
unset($COMPONENTS, $COMPONENT, $MODULE); unset($components, $component, $module);
} }
+2 -2
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.