diff --git a/doc/Extensions/Component.md b/doc/Extensions/Component.md index 40331981d..5fcf3838f 100644 --- a/doc/Extensions/Component.md +++ b/doc/Extensions/Component.md @@ -307,11 +307,11 @@ To see an example of how the component module can used, please see the following - Cisco CBQoS - includes/discovery/cisco-cbqos.inc.php - - includes/poller/cisco-cbqos.inc.php + - includes/polling/cisco-cbqos.inc.php - html/includes/graphs/device/cbqos_traffic.inc.php - Cisco OTV - includes/discovery/cisco-otv.inc.php - - includes/poller/applications/cisco-otv.inc.php + - includes/polling/cisco-otv.inc.php - html/includes/graphs/device/cisco-otv-mac.inc.php - - html/pages/device/apps/cisco-otv.inc.php + - html/pages/routing/cisco-otv.inc.php diff --git a/html/includes/graphs/device/cisco-otv-mac.inc.php b/html/includes/graphs/device/cisco-otv-mac.inc.php new file mode 100644 index 000000000..691bfd10d --- /dev/null +++ b/html/includes/graphs/device/cisco-otv-mac.inc.php @@ -0,0 +1,62 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options['filter']['type'] = array('=','Cisco-OTV'); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'MAC Addresses Now Min Max\\n'"; +$rrd_additions = ""; + +$count = 0; +foreach ($components as $id => $array) { + if ($array['otvtype'] == 'endpoint') { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$array['endpoint']."-mac.rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; + } + + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; + } + else { + $color = $config['graph_colours']['oranges'][$count-7]; + } + + $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 .= " GPRINT:DS" . $count . ":LAST:%4.0lf%s "; + $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%4.0lf%s "; + $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%4.0lf%s\\\l "; + $count++; + } + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} +else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/graphs/device/cisco-otv-vlan.inc.php b/html/includes/graphs/device/cisco-otv-vlan.inc.php new file mode 100644 index 000000000..1116e056c --- /dev/null +++ b/html/includes/graphs/device/cisco-otv-vlan.inc.php @@ -0,0 +1,62 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options['filter']['type'] = array('=','Cisco-OTV'); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'VLANs Now Min Max\\n'"; +$rrd_additions = ""; + +$count = 0; +foreach ($components as $id => $array) { + if ($array['otvtype'] == 'overlay') { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("cisco-otv-".$array['label']."-vlan.rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; + } + + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; + } + else { + $color = $config['graph_colours']['oranges'][$count-7]; + } + + $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 .= " GPRINT:DS" . $count . ":LAST:%4.0lf%s "; + $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%4.0lf%s "; + $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%4.0lf%s\\\l "; + $count++; + } + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} +else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 74ae6f7a1..4c22ad08b 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -420,7 +420,13 @@ $routing_count['ospf'] = dbFetchCell("SELECT COUNT(ospf_instance_id) FROM `ospf_ $routing_count['cef'] = dbFetchCell("SELECT COUNT(cef_switching_id) from `cef_switching`"); $routing_count['vrf'] = dbFetchCell("SELECT COUNT(vrf_id) from `vrfs`"); -if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { +require_once "../includes/component.php"; +$component = new component(); +$options['type'] = 'Cisco-OTV'; +$otv = $component->getComponents(null,$options); +$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") { ?> '); + $separator = 0; + } + echo('
  • Cisco OTV
  • '); + $separator++; + } + // BGP Sessions if ($_SESSION['userlevel'] >= '5' && $routing_count['bgp']) { if ($separator) { diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 94a296822..fd5900401 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -210,6 +210,16 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { $routing_tabs[] = 'vrf'; } + require_once "../includes/component.php"; + $component = new component(); + $options['type'] = 'Cisco-OTV'; + $options['filter']['device_id'] = array('=',$device['device_id']); + $otv = $component->getComponents(null,$options); + $device_routing_count['cisco-otv'] = count($otv); + if ($device_routing_count['cisco-otv'] > 0) { + $routing_tabs[] = 'cisco-otv'; + } + if (is_array($routing_tabs)) { echo '
  • diff --git a/html/pages/device/routing.inc.php b/html/pages/device/routing.inc.php index e4be54617..c58fe17a8 100644 --- a/html/pages/device/routing.inc.php +++ b/html/pages/device/routing.inc.php @@ -20,6 +20,7 @@ $type_text['bgp'] = 'BGP'; $type_text['cef'] = 'CEF'; $type_text['ospf'] = 'OSPF'; $type_text['vrf'] = 'VRFs'; +$type_text['cisco-otv'] = 'OTV'; print_optionbar_start(); diff --git a/html/pages/device/routing/cisco-otv.inc.php b/html/pages/device/routing/cisco-otv.inc.php new file mode 100644 index 000000000..602f67abd --- /dev/null +++ b/html/pages/device/routing/cisco-otv.inc.php @@ -0,0 +1,94 @@ +getComponents($device['device_id'],$options); +$components = $components[$device['device_id']]; + +global $config; +?> +
    +
    +

    Overlay's & Adjacencies

    +
    +
    + $overlay) { + if ($overlay['otvtype'] == 'overlay') { + if ($overlay['status'] == 1) { + $overlay_status = "Normal"; + $gli = ""; + } + else { + $overlay_status = "".$overlay['error']." - Alert"; + $gli = "list-group-item-danger"; + } +?> + - + + +
    +
    + +
    +
    +

    AED Enabled VLAN's

    +
    +
    + +
    +
    + +
    +
    +

    MAC Addresses

    +
    +
    + +
    +
    diff --git a/html/pages/routing.inc.php b/html/pages/routing.inc.php index 0a7fcb335..848c655e2 100644 --- a/html/pages/routing.inc.php +++ b/html/pages/routing.inc.php @@ -16,6 +16,7 @@ $type_text['bgp'] = 'BGP'; $type_text['cef'] = 'CEF'; $type_text['ospf'] = 'OSPF'; $type_text['vrf'] = 'VRFs'; +$type_text['cisco-otv'] = 'OTV'; print_optionbar_start(); @@ -53,6 +54,7 @@ switch ($vars['protocol']) { case 'vrf': case 'cef': case 'ospf': + case 'cisco-otv': include 'pages/routing/'.$vars['protocol'].'.inc.php'; break; diff --git a/html/pages/routing/cisco-otv.inc.php b/html/pages/routing/cisco-otv.inc.php new file mode 100644 index 000000000..00ca33bdd --- /dev/null +++ b/html/pages/routing/cisco-otv.inc.php @@ -0,0 +1,58 @@ +getComponents(null,$options); + +foreach ($COMPONENTS as $DEVICE_ID => $COMP) { + $LINK = generate_url(array('page' => 'device', 'device' => $DEVICE_ID, 'tab' => 'routing', 'proto' => 'cisco-otv')); +?> +
    + +
    + $OVERLAY) { + if ($OVERLAY['otvtype'] == 'overlay') { + if ($OVERLAY['status'] == 1) { + $OVERLAY_STATUS = "Normal"; + $GLI = ""; + } + else { + $OVERLAY_STATUS = "".$OVERLAY['error']." - Alert"; + $GLI = "list-group-item-danger"; + } + ?> + - + + +
    +
    + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os_group'] == 'cisco') { + + // Define some error messages + $error_vpn = array(); + $error_vpn[0] = "Other"; + $error_vpn[1] = "Configuration changed"; + $error_vpn[2] = "Control Group information is unavailable"; + $error_vpn[3] = "Data Group range information is unavailable"; + $error_vpn[4] = "Join or Source interface information is unavailable"; + $error_vpn[5] = "VPN name is unavailable"; + $error_vpn[6] = "IP address is missing for Join Interface"; + $error_vpn[7] = "Join Interface is down"; + $error_vpn[8] = "Overlay is administratively shutdown"; + $error_vpn[9] = "Overlay is in delete hold down phase"; + $error_vpn[10] = "VPN is reinitializing"; + $error_vpn[11] = "Site ID information is unavailable"; + $error_vpn[12] = "Site ID mismatch has occurred"; + $error_vpn[13] = "IP address is missing for Source Interface"; + $error_vpn[14] = "Source interface is down"; + $error_vpn[15] = "Changing site identifier"; + $error_vpn[16] = "Changing control group"; + $error_vpn[17] = "Device ID information is unavailable"; + $error_vpn[18] = "Changing device ID"; + $error_vpn[19] = "Cleanup in progress"; + + $error_aed = array(); + $error_aed[0] = "Other"; + $error_aed[1] = "Overlay is Down"; + $error_aed[2] = "Site ID is not configured"; + $error_aed[3] = "Site ID mismatch"; + $error_aed[4] = "Version mismatch"; + $error_aed[5] = "Site VLAN is Down"; + $error_aed[6] = "No extended VLAN is operationally up"; + $error_aed[7] = "No Overlay Adjacency is up"; + $error_aed[8] = "LSPDB sync incomplete"; + $error_aed[9] = "Overlay state down event in progress"; + $error_aed[10] = "ISIS control group sync pending"; + + $error_overlay = array(); + $error_overlay[1] = "active"; + $error_overlay[2] = "notInService"; + $error_overlay[3] = "notReady"; + $error_overlay[4] = "createAndGo"; + $error_overlay[5] = "createAndWait"; + $error_overlay[6] = "destroy"; + + $module = 'Cisco-OTV'; + echo $module.': '; + + require_once 'includes/component.php'; + $component = new component(); + $components = $component->getComponents($device['device_id'],array('type'=>$module)); + + // We only care about our device id. + $components = $components[$device['device_id']]; + + // Begin our master array, all other values will be processed into this array. + $tblOTV = array(); + $tblEndpoints = array(); + + // Let's gather some data.. + $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); + $tblAdjacentDevName = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1.4', 0); + + /* + * False == no object found - this is not an error, there is no QOS configured + * null == timeout or something else that caused an error, there may be QOS configured but we couldn't get it. + */ + if ( is_null($tblOverlayEntry) || is_null($tblAdjacencyDatabaseEntry) || is_null($tblAdjacentDevName) ) { + // We have to error here or we will end up deleting all our components. + echo "Error\n"; + } + else { + // No Error, lets process things. + + // 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) { + $result = array(); + $message = false; + $result['index'] = $index; + $result['label'] = $name; + if ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.15'][$index] == 1) { + $result['transport'] = 'Multicast'; + } + else { + $result['transport'] = 'Unicast'; + } + $result['otvtype'] = 'overlay'; + $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]; + 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"; + } + $result['aed_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$index]; + 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"; + } + $result['overlay_state'] = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$index]; + 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"; + } + + // If we have set a message, we have an error, activate alert. + if ($message !== false) { + $result['error'] = $message; + $result['status'] = 0; + } + else { + $result['error'] = ""; + $result['status'] = 1; + } + + // Let's log some debugging + d_echo("\n\nOverlay: ".$result['label']."\n"); + d_echo(" Index: ".$result['index']."\n"); + d_echo(" UID: ".$result['UID']."\n"); + d_echo(" Transport: ".$result['transport']."\n"); + d_echo(" Type: ".$result['otvtype']."\n"); + d_echo(" Status: ".$result['status']."\n"); + d_echo(" Message: ".$result['error']."\n"); + + // Add the result to the parent array. + $tblOTV[] = $result; + } + + // Add each adjacency to the array. + 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); + $result = array(); + $result['index'] = $matches[1]; + $result['endpoint'] = $matches[2]; + $tblEndpoints[$value] = true; + $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['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$result['index'].'.1.4.'.$result['endpoint']]; + $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) { + $message .= "Adjacency is Down\n"; + } + + // If we have set a message, we have an error, activate alert. + if ($message !== false) { + $result['error'] = $message; + $result['status'] = 0; + } + else { + $result['error'] = ""; + $result['status'] = 1; + } + + // Set a default name, if for some unknown reason we cant find the parent VPN. + $result['label'] = "Unknown (".$result['index'].") - ".$value; + // We need to search the existing array to build the name + foreach ($tblOTV as $item) { + if (($item['otvtype'] == 'overlay') && ($item['index'] == $result['index'])) { + $result['label'] = $item['label']." - ".$value; + } + } + + // Let's log some debugging + d_echo("\n\nAdjacency: ".$result['label']."\n"); + d_echo(" Endpoint: ".$result['endpoint']."\n"); + d_echo(" Index: ".$result['index']."\n"); + d_echo(" UID: ".$result['UID']."\n"); + d_echo(" Status: ".$result['status']."\n"); + d_echo(" Message: ".$result['error']."\n"); + + // Add the result to the parent array. + $tblOTV[] = $result; + } + + // We retain a list of all endpoints to tie the RRD to. + foreach ($tblEndpoints as $k => $v) { + $result['label'] = "Endpoint: ".$k; + $result['otvtype'] = 'endpoint'; + $result['endpoint'] = $k; + $result['UID'] = $result['otvtype']."-".$k; + + // Let's log some debugging + d_echo("\n\nEndpoint: ".$result['label']."\n"); + d_echo(" UID: ".$result['UID']."\n"); + d_echo(" Type: ".$result['otvtype']."\n"); + + // Add the result to the parent array. + $tblOTV[] = $result; + } + + /* + * Ok, we have our 2 array's (Components and SNMP) now we need + * to compare and see what needs to be added/updated. + * + * Let's loop over the SNMP data to see if we need to ADD or UPDATE any components. + */ + foreach ($tblOTV as $key => $array) { + $component_key = false; + + // Loop over our components to determine if the component exists, or we need to add it. + foreach ($components as $compid => $child) { + if ($child['UID'] === $array['UID']) { + $component_key = $compid; + } + } + + if (!$component_key) { + // The component doesn't exist, we need to ADD it - ADD. + $new_component = $component->createComponent($device['device_id'],$module); + $component_key = key($new_component); + $components[$component_key] = array_merge($new_component[$component_key], $array); + echo "+"; + } + else { + // The component does exist, merge the details in - UPDATE. + $components[$component_key] = array_merge($components[$component_key], $array); + echo "."; + } + + } + + /* + * Loop over the Component data to see if we need to DELETE any components. + */ + foreach ($components as $key => $array) { + // Guilty until proven innocent + $found = false; + + foreach ($tblOTV as $k => $v) { + if ($array['UID'] == $v['UID']) { + // Yay, we found it... + $found = true; + } + } + + if ($found === false) { + // The component has not been found. we should delete it. + echo "-"; + $component->deleteComponent($key); + } + } + + // Write the Components back to the DB. + $component->setComponentPrefs($device['device_id'],$components); + echo "\n"; + + } // End if not error + +} diff --git a/includes/polling/cisco-otv.inc.php b/includes/polling/cisco-otv.inc.php new file mode 100644 index 000000000..1c1fa4aa1 --- /dev/null +++ b/includes/polling/cisco-otv.inc.php @@ -0,0 +1,206 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os_group'] == "cisco") { + + // Define some error messages + $error_vpn = array(); + $error_vpn[0] = "Other"; + $error_vpn[1] = "Configuration changed"; + $error_vpn[2] = "Control Group information is unavailable"; + $error_vpn[3] = "Data Group range information is unavailable"; + $error_vpn[4] = "Join or Source interface information is unavailable"; + $error_vpn[5] = "VPN name is unavailable"; + $error_vpn[6] = "IP address is missing for Join Interface"; + $error_vpn[7] = "Join Interface is down"; + $error_vpn[8] = "Overlay is administratively shutdown"; + $error_vpn[9] = "Overlay is in delete hold down phase"; + $error_vpn[10] = "VPN is reinitializing"; + $error_vpn[11] = "Site ID information is unavailable"; + $error_vpn[12] = "Site ID mismatch has occurred"; + $error_vpn[13] = "IP address is missing for Source Interface"; + $error_vpn[14] = "Source interface is down"; + $error_vpn[15] = "Changing site identifier"; + $error_vpn[16] = "Changing control group"; + $error_vpn[17] = "Device ID information is unavailable"; + $error_vpn[18] = "Changing device ID"; + $error_vpn[19] = "Cleanup in progress"; + + $error_aed = array(); + $error_aed[0] = "Other"; + $error_aed[1] = "Overlay is Down"; + $error_aed[2] = "Site ID is not configured"; + $error_aed[3] = "Site ID mismatch"; + $error_aed[4] = "Version mismatch"; + $error_aed[5] = "Site VLAN is Down"; + $error_aed[6] = "No extended VLAN is operationally up"; + $error_aed[7] = "No Overlay Adjacency is up"; + $error_aed[8] = "LSPDB sync incomplete"; + $error_aed[9] = "Overlay state down event in progress"; + $error_aed[10] = "ISIS control group sync pending"; + + $error_overlay = array(); + $error_overlay[1] = "active"; + $error_overlay[2] = "notInService"; + $error_overlay[3] = "notReady"; + $error_overlay[4] = "createAndGo"; + $error_overlay[5] = "createAndWait"; + $error_overlay[6] = "destroy"; + + $module = 'Cisco-OTV'; + + require_once 'includes/component.php'; + $component = new component(); + $options['filter']['type'] = array('=',$module); + $options['filter']['disabled'] = array('=',0); + $components = $component->getComponents($device['device_id'],$options); + + // We only care about our device id. + $components = $components[$device['device_id']]; + + // Only collect SNMP data if we have enabled components + if (count($components > 0)) { + // Let's gather the stats.. + $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); + $tblRouteNextHopAddr = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.5.1.1.8', 0); + $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. + $count_mac = array(); + foreach ($tblRouteNextHopAddr as $k => $v) { + $count_mac[$v]++; + } + // Let's log some debugging + d_echo("\n\nMAC Addresses: ".print_r($count_mac,TRUE)); + + // Loop through the components and extract the data. + foreach ($components as $key => &$array) { + + if ($array['otvtype'] == 'overlay') { + // Let's check the various status' of the overlay + $message = false; + $vpn_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$array['index']]; + 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']]]; + } + $aed_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$array['index']]; + 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']]]; + } + $overlay_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$array['index']]; + 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']]]; + } + + // If we have set a message, we have an error, activate alert. + if ($message !== false) { + $array['error'] = $message; + $array['status'] = 0; + } + else { + $array['error'] = ""; + $array['status'] = 1; + } + + // Time to graph the count of the active VLAN's on this overlay. + $count_vlan = 0; + foreach ($tblVlanEdgeDevIsAed['1.3.6.1.4.1.9.9.810.1.2.2.1.6'][$array['index']] as $v) { + if ($v == 1) { + $count_vlan++; + } + } + + // Let's log some debugging + d_echo("\n\nOverlay Component: ".$key."\n"); + d_echo(" Label: ".$array['label']."\n"); + d_echo(" Index: ".$array['index']."\n"); + d_echo(" Status: ".$array['status']."\n"); + d_echo(" Message: ".$array['error']."\n"); + d_echo(" VLAN Count: ".$count_vlan."\n"); + + $filename = "cisco-otv-".$array['label']."-vlan.rrd"; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + + if (!file_exists ($rrd_filename)) { + rrdtool_create ($rrd_filename, " DS:count:GAUGE:600:0:U" . $config['rrd_rra']); + } + $rrd['count'] = $count_vlan; + + // Update RRD + rrdtool_update ($rrd_filename, $rrd); + + } + 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']]; + $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) { + $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']) { + $message .= "Adjacency has been reset\n"; + } + + // If we have set a message, we have an error, activate alert. + if ($message !== false) { + $array['error'] = $message; + $array['status'] = 0; + } + else { + $array['error'] = ""; + $array['status'] = 1; + } + + // Let's log some debugging + d_echo("\n\nAdjacency Component: ".$key."\n"); + d_echo(" Label: ".$array['label']."\n"); + d_echo(" Index: ".$array['index']."\n"); + d_echo(" Status: ".$array['status']."\n"); + d_echo(" Message: ".$array['error']."\n"); + } + elseif ($array['otvtype'] == 'endpoint') { + if (isset($count_mac[$array['endpoint']])) { + $rrd['count'] = $count_mac[$array['endpoint']]; + } + else { + $rrd['count'] = "0"; + } + + // Let's log some debugging + d_echo("\n\nEndpoint Component: ".$key."\n"); + d_echo(" Label: ".$array['label']."\n"); + d_echo(" MAC Count: ".$rrd['count']."\n"); + + $filename = "cisco-otv-".$array['endpoint']."-mac.rrd"; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + + if (!file_exists ($rrd_filename)) { + rrdtool_create ($rrd_filename, " DS:count:GAUGE:600:0:U" . $config['rrd_rra']); + } + + // Update RRD + rrdtool_update ($rrd_filename, $rrd); + + } // End If + + } // End foreach components + + // Write the Components back to the DB. + $component->setComponentPrefs($device['device_id'],$components); + + echo $module." "; + } // end if count components + + // Clean-up after yourself! + unset($components, $component, $module); +} \ No newline at end of file