mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
@@ -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
|
||||
|
||||
|
||||
62
html/includes/graphs/device/cisco-otv-mac.inc.php
Normal file
62
html/includes/graphs/device/cisco-otv-mac.inc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to display Cisco Class-Based QoS Details
|
||||
*
|
||||
* Copyright (c) 2015 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
62
html/includes/graphs/device/cisco-otv-vlan.inc.php
Normal file
62
html/includes/graphs/device/cisco-otv-vlan.inc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to display Cisco Class-Based QoS Details
|
||||
*
|
||||
* Copyright (c) 2015 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
@@ -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") {
|
||||
|
||||
?>
|
||||
<li class="dropdown">
|
||||
@@ -443,6 +449,16 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
|
||||
$separator++;
|
||||
}
|
||||
|
||||
// Cisco OTV Links
|
||||
if ($_SESSION['userlevel'] >= '5' && $routing_count['cisco-otv']) {
|
||||
if ($separator) {
|
||||
echo(' <li role="presentation" class="divider"></li>');
|
||||
$separator = 0;
|
||||
}
|
||||
echo('<li><a href="routing/protocol=cisco-otv/"><i class="fa fa-exchange fa-fw fa-lg"></i> Cisco OTV </a></li>');
|
||||
$separator++;
|
||||
}
|
||||
|
||||
// BGP Sessions
|
||||
if ($_SESSION['userlevel'] >= '5' && $routing_count['bgp']) {
|
||||
if ($separator) {
|
||||
|
||||
@@ -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 '<li class="'.$select['routing'].'">
|
||||
<a href="'.generate_device_url($device, array('tab' => 'routing')).'">
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
94
html/pages/device/routing/cisco-otv.inc.php
Normal file
94
html/pages/device/routing/cisco-otv.inc.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
require_once "../includes/component.php";
|
||||
$component = new component();
|
||||
$options = array();
|
||||
$options['filter']['ignore'] = array('=',0);
|
||||
$options['type'] = 'Cisco-OTV';
|
||||
$components = $component->getComponents($device['device_id'],$options);
|
||||
$components = $components[$device['device_id']];
|
||||
|
||||
global $config;
|
||||
?>
|
||||
<div class="panel panel-default" id="overlays">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Overlay's & Adjacencies</h3>
|
||||
</div>
|
||||
<div class="panel list-group">
|
||||
<?php
|
||||
// Loop over each component, pulling out the Overlays.
|
||||
foreach ($components as $oid => $overlay) {
|
||||
if ($overlay['otvtype'] == 'overlay') {
|
||||
if ($overlay['status'] == 1) {
|
||||
$overlay_status = "<span class='green pull-right'>Normal</span>";
|
||||
$gli = "";
|
||||
}
|
||||
else {
|
||||
$overlay_status = "<span class='pull-right'>".$overlay['error']." - <span class='red'>Alert</span></span>";
|
||||
$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>
|
||||
<div id="<?=$overlay['index']?>" class="sublinks collapse">
|
||||
<?php
|
||||
foreach ($components as $aid => $adjacency) {
|
||||
if (($adjacency['otvtype'] == 'adjacency') && ($adjacency['index'] == $overlay['index'])) {
|
||||
if ($adjacency['status'] == 1) {
|
||||
$adj_status = "<span class='green pull-right'>Normal</span>";
|
||||
$gli = "";
|
||||
}
|
||||
else {
|
||||
$adj_status = "<span class='pull-right'>".$adjacency['error']." - <span class='red'>Alert</span></span>";
|
||||
$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>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" id="vlanperoverlay">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">AED Enabled VLAN's</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?php
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['type'] = 'device_cisco-otv-vlan';
|
||||
require 'includes/print-graphrow.inc.php';
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" id="macperendpoint">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">MAC Addresses</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?php
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['type'] = 'device_cisco-otv-mac';
|
||||
require 'includes/print-graphrow.inc.php';
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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;
|
||||
|
||||
|
||||
58
html/pages/routing/cisco-otv.inc.php
Normal file
58
html/pages/routing/cisco-otv.inc.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
require_once "../includes/component.php";
|
||||
$COMPONENT = new component();
|
||||
$options = array();
|
||||
$options['filter']['ignore'] = array('=',0);
|
||||
$options['type'] = 'Cisco-OTV';
|
||||
$COMPONENTS = $COMPONENT->getComponents(null,$options);
|
||||
|
||||
foreach ($COMPONENTS as $DEVICE_ID => $COMP) {
|
||||
$LINK = generate_url(array('page' => 'device', 'device' => $DEVICE_ID, 'tab' => 'routing', 'proto' => 'cisco-otv'));
|
||||
?>
|
||||
<div class="panel panel-default" id="overlays-<?=$DEVICE_ID?>">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><a href="<?=$LINK?>"><?=gethostbyid($DEVICE_ID)?> - Overlay's & Adjacencies</a></h3>
|
||||
</div>
|
||||
<div class="panel list-group">
|
||||
<?php
|
||||
// Loop over each component, pulling out the Overlays.
|
||||
foreach ($COMP as $OID => $OVERLAY) {
|
||||
if ($OVERLAY['otvtype'] == 'overlay') {
|
||||
if ($OVERLAY['status'] == 1) {
|
||||
$OVERLAY_STATUS = "<span class='green pull-right'>Normal</span>";
|
||||
$GLI = "";
|
||||
}
|
||||
else {
|
||||
$OVERLAY_STATUS = "<span class='pull-right'>".$OVERLAY['error']." - <span class='red'>Alert</span></span>";
|
||||
$GLI = "list-group-item-danger";
|
||||
}
|
||||
?>
|
||||
<a class="list-group-item <?=$GLI?>" data-toggle="collapse" data-target="#<?=$OVERLAY['index']?>" data-parent="#overlays-<?=$DEVICE_ID?>"><?=$OVERLAY['label']?> - <?=$OVERLAY['transport']?> <?=$OVERLAY_STATUS?></a>
|
||||
<div id="<?=$OVERLAY['index']?>" class="sublinks collapse">
|
||||
<?php
|
||||
foreach ($COMP as $AID => $ADJACENCY) {
|
||||
if (($ADJACENCY['otvtype'] == 'adjacency') && ($ADJACENCY['index'] == $OVERLAY['index'])) {
|
||||
if ($ADJACENCY['status'] == 1) {
|
||||
$ADJ_STATUS = "<span class='green pull-right'>Normal</span>";
|
||||
$GLI = "";
|
||||
}
|
||||
else {
|
||||
$ADJ_STATUS = "<span class='pull-right'>".$ADJACENCY['error']." - <span class='red'>Alert</span></span>";
|
||||
$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>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@@ -712,6 +712,7 @@ $config['poller_modules']['mib'] = 0;
|
||||
$config['poller_modules']['cisco-voice'] = 1;
|
||||
$config['poller_modules']['cisco-cbqos'] = 1;
|
||||
$config['poller_modules']['stp'] = 1;
|
||||
$config['poller_modules']['cisco-otv'] = 1;
|
||||
|
||||
// List of discovery modules. Need to be in this array to be
|
||||
// considered for execution.
|
||||
@@ -745,6 +746,7 @@ $config['discovery_modules']['services'] = 1;
|
||||
$config['discovery_modules']['charge'] = 1;
|
||||
$config['discovery_modules']['cisco-cbqos'] = 0;
|
||||
$config['discovery_modules']['stp'] = 1;
|
||||
$config['discovery_modules']['cisco-otv'] = 1;
|
||||
|
||||
$config['modules_compat']['rfc1628']['liebert'] = 1;
|
||||
$config['modules_compat']['rfc1628']['netmanplus'] = 1;
|
||||
|
||||
260
includes/discovery/cisco-otv.inc.php
Normal file
260
includes/discovery/cisco-otv.inc.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to capture Cisco OTV Details
|
||||
*
|
||||
* Copyright (c) 2015 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* 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
|
||||
|
||||
}
|
||||
206
includes/polling/cisco-otv.inc.php
Normal file
206
includes/polling/cisco-otv.inc.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to capture Cisco Class-Based QoS Details
|
||||
*
|
||||
* Copyright (c) 2015 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user