mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Cisco OTV
Implements the CISCO-OTV-MIB to retrieve OTV counters from Cisco devices. This collects information on the configured Overlays and Adjacencies Statistics are collected for the amount of VLAN's on each overlay and the amount of MAC addresses available over each OTV endpoint. OTV alerts are collected and generated if the appropriate alerting rules exist. Data is displayed under routing at both the global and device level. Includes function snmpwalk_array_num, which performs a numeric SNMPWalk and returns an array containing $count indexes One Index: From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27.18']['655360'] = 0 Two Indexes: From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27']['18']['655360'] = 0 And so on...
This commit is contained in:
@@ -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
|
||||
}
|
@@ -711,6 +711,7 @@ $config['poller_modules']['cisco-asa-firewall'] = 1;
|
||||
$config['poller_modules']['mib'] = 0;
|
||||
$config['poller_modules']['cisco-voice'] = 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.
|
||||
@@ -743,6 +744,7 @@ $config['discovery_modules']['ucd-diskio'] = 1;
|
||||
$config['discovery_modules']['services'] = 1;
|
||||
$config['discovery_modules']['charge'] = 1;
|
||||
$config['discovery_modules']['stp'] = 1;
|
||||
$config['discovery_modules']['cisco-otv'] = 1;
|
||||
|
||||
$config['modules_compat']['rfc1628']['liebert'] = 1;
|
||||
$config['modules_compat']['rfc1628']['netmanplus'] = 1;
|
||||
|
235
includes/discovery/cisco-otv.inc.php
Normal file
235
includes/discovery/cisco-otv.inc.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?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[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[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[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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// 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
|
||||
|
||||
}
|
181
includes/polling/cisco-otv.inc.php
Normal file
181
includes/polling/cisco-otv.inc.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?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[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[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[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]++;
|
||||
}
|
||||
|
||||
// Loop through the components and extract the data.
|
||||
foreach ($COMPONENTS as $KEY => &$ARRAY) {
|
||||
|
||||
if ($ARRAY['otvtype'] == 'overlay') {
|
||||
// Let's check the varius 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++;
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
elseif ($ARRAY['otvtype'] == 'endpoint') {
|
||||
if (isset($COUNT_MAC[$ARRAY['endpoint']])) {
|
||||
$RRD['count'] = $COUNT_MAC[$ARRAY['endpoint']];
|
||||
}
|
||||
else {
|
||||
$RRD['count'] = "0";
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
@@ -1268,4 +1268,70 @@ function register_mibs($device, $mibs, $included_by)
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
} // register_mibs
|
||||
|
||||
/**
|
||||
* SNMPWalk_array_num - performs a numeric SNMPWalk and returns an array containing $count indexes
|
||||
* One Index:
|
||||
* From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0
|
||||
* To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27.18']['655360'] = 0
|
||||
* Two Indexes:
|
||||
* From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0
|
||||
* To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27']['18']['655360'] = 0
|
||||
* And so on...
|
||||
* Think snmpwalk_cache_*_oid but for numeric data.
|
||||
*
|
||||
* Why is this useful?
|
||||
* Some SNMP data contains a single index (eg. ifIndex in IF-MIB) and some is dual indexed
|
||||
* (eg. PolicyIndex/ObjectsIndex in CISCO-CLASS-BASED-QOS-MIB).
|
||||
* The resulting array allows us to easily access the top level index we want and iterate over the data from there.
|
||||
*
|
||||
* @param $device
|
||||
* @param $OID
|
||||
* @param int $indexes
|
||||
* @internal param $string
|
||||
* @return array
|
||||
*/
|
||||
function snmpwalk_array_num($device,$OID,$indexes=1) {
|
||||
$array = array();
|
||||
$string = snmp_walk($device, $OID, '-Osqn');
|
||||
|
||||
if ( $string === false) {
|
||||
// False means: No Such Object.
|
||||
return false;
|
||||
}
|
||||
if ($string == "") {
|
||||
// Empty means SNMP timeout or some such.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Let's turn the string into something we can work with.
|
||||
foreach (explode("\n", $string) as $line) {
|
||||
if ($line[0] == '.') {
|
||||
// strip the leading . if it exists.
|
||||
$line = substr($line,1);
|
||||
}
|
||||
list($key, $value) = explode(' ', $line, 2);
|
||||
$prop_id = explode('.', $key);
|
||||
$value = trim($value);
|
||||
|
||||
// if we have requested more levels that exist, set to the max.
|
||||
if ($indexes > count($prop_id)) {
|
||||
$indexes = count($prop_id)-1;
|
||||
}
|
||||
|
||||
for ($i=0;$i<$indexes;$i++) {
|
||||
// Pop the index off.
|
||||
$index = array_pop($prop_id);
|
||||
$value = array($index => $value);
|
||||
}
|
||||
|
||||
// Rebuild our key
|
||||
$key = implode('.',$prop_id);
|
||||
|
||||
// Add the entry to the master array
|
||||
$array = array_replace_recursive($array,array($key => $value));
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
Reference in New Issue
Block a user