Merge branch 'master' into config_diff

This commit is contained in:
Tony Murray
2016-02-12 10:36:18 -06:00
23 changed files with 1160 additions and 314 deletions

View File

@@ -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

View File

@@ -73,7 +73,7 @@ Adding the above line to `/etc/snmp/snmpd.conf` and running `service snmpd resta
In `/etc/php5/apache2/php.ini` and `/etc/php5/cli/php.ini`, ensure date.timezone is set to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid
examples are: "America/New York", "Australia/Brisbane", "Etc/UTC".
Please also ensure that allow_url_fopen is enabled.
Please also ensure that `allow_url_fopen` is enabled. Other functions needed for LibreNMS include `exec,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,popen`.
### Adding the librenms-user ###

View File

@@ -135,7 +135,8 @@ You need to configure snmpd appropriately if you have not already done so. An a
Adding the above line to `/etc/snmp/snmpd.conf` and running `service snmpd restart` will activate this config.
In `/etc/php.ini`, ensure date.timezone is set to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid
examples are: "America/New York", "Australia/Brisbane", "Etc/UTC". Please also ensure that allow_url_fopen is enabled.
examples are: "America/New York", "Australia/Brisbane", "Etc/UTC".
Please also ensure that `allow_url_fopen` is enabled. Other functions needed for LibreNMS include `exec,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,popen`.
Next, add the following to `/etc/httpd/conf.d/librenms.conf`

View File

@@ -73,6 +73,8 @@ If the page you are trying to load has a substantial amount of data in it then i
This is usually due to there being blank spaces outside of the `<?php ?>` php tags within config.php. Remove these and retry.
It's also worth removing the final `?>` at the end of config.php as this is not required.
Another reason why it might not be working is if you disabled functions needed by LibreNMS, which include `allow_url_fopen`
and `exec,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,popen`.
#### <a name="faq7"> How do I debug pages not loading correctly?</a>

View File

@@ -4,5 +4,6 @@ if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
$_SESSION['screen_width'] = $_REQUEST['width'];
$_SESSION['screen_height'] = $_REQUEST['height'];
}
header('Content-type: text/plain');
echo $_SESSION['screen_width'];
echo $_SESSION['screen_height'];

View 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;
}

View 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;
}

View File

@@ -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) {

View File

@@ -223,3 +223,24 @@ $(document).on("click", '.collapse-neighbors', function(event)
list.toggle();
continued.toggle();
});
$(document).ready(function() {
var lines = 'on';
$("#linenumbers").button().click(function() {
if (lines == 'on') {
$($('.config').find('ol').get().reverse()).each(function(){
$(this).replaceWith($('<ul>'+$(this).html()+'</ul>'))
lines = 'off';
$('#linenumbers').val('Show line numbers');
});
}
else {
$($('.config').find('ul').get().reverse()).each(function(){
$(this).replaceWith($('<ol>'+$(this).html()+'</ol>'));
lines = 'on';
$('#linenumbers').val('Hide line numbers');
});
}
});
});

View File

@@ -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')).'">
@@ -388,19 +398,25 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
}
echo '<li style="float: right;"><a href="https://'.$device['hostname'].'"><img src="images/16/http.png" alt="https" title="Launch browser to https://'.$device['hostname'].'" border="0" width="16" height="16" target="_blank"></a></li>
<li style="float: right;"><a href="ssh://'.$device['hostname'].'"><img src="images/16/ssh.png" alt="ssh" title="SSH to '.$device['hostname'].'" border="0" width="16" height="16"></a></li>
<li style="float: right;"><a href="telnet://'.$device['hostname'].'"><img src="images/16/telnet.png" alt="telnet" title="Telnet to '.$device['hostname'].'" border="0" width="16" height="16"></a></li>';
echo '<div class="dropdown pull-right">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog"></i>
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="https://'.$device['hostname'].'"><img src="images/16/http.png" alt="https" title="Launch browser to https://'.$device['hostname'].'" border="0" width="16" height="16" target="_blank"> Launch</a></li>
<li><a href="ssh://'.$device['hostname'].'"><img src="images/16/ssh.png" alt="ssh" title="SSH to '.$device['hostname'].'" border="0" width="16" height="16"> SSH</a></li>
<li><a href="telnet://'.$device['hostname'].'"><img src="images/16/telnet.png" alt="telnet" title="Telnet to '.$device['hostname'].'" border="0" width="16" height="16"> Telnet</a></li>';
if (is_admin()) {
echo '<li class="'.$select['edit'].'" style="float: right;">
echo '<li>
<a href="'.generate_device_url($device, array('tab' => 'edit')).'">
<img src="images/16/wrench.png" align="absmiddle" border="0" />
Edit
</a>
</li>';
}
echo '</ul>
</div>';
echo '</ul>';
}//end if
if (device_permitted($device['device_id']) || $check_device == $vars['device']) {

View File

@@ -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();

View 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>

View File

@@ -241,7 +241,10 @@ if (is_admin()) {
// $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
$geshi->set_overall_style('color: black;');
// $geshi->set_line_style('color: #999999');
echo '<div class="config">';
echo '<input id="linenumbers" class="btn btn-primary" type="submit" value="Hide line numbers"/>';
echo $geshi->parse_code();
echo '</div>';
}
}//end if

View File

@@ -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;

View 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
}

View File

@@ -244,6 +244,10 @@ $mail_conf = array(
'descr' => 'From name',
'type' => 'text',
),
array('name' => 'email_from',
'descr' => 'From email address',
'type' => 'text',
),
array('name' => 'email_sendmail_path',
'descr' => 'Sendmail path',
'type' => 'text',

View File

@@ -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;

View 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
}

View File

@@ -1,7 +1,16 @@
<?php
if ($config['enable_bgp']) {
foreach (dbFetchRows('SELECT * FROM bgpPeers WHERE device_id = ?', array($device['device_id'])) as $peer) {
$peers = dbFetchRows('SELECT * FROM bgpPeers WHERE device_id = ?', array($device['device_id']));
if (!empty($peers)) {
if ($device['os'] != 'junos') {
$peer_data_check = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', array(), 'CISCO-BGP4-MIB', $config['mibdir']);
}
foreach ($peers as $peer) {
// Poll BGP Peer
$peer2 = false;
echo 'Checking BGP peer '.$peer['bgpPeerIdentifier'].' ';
@@ -9,8 +18,6 @@ if ($config['enable_bgp']) {
if (!empty($peer['bgpPeerIdentifier'])) {
if (!strstr($peer['bgpPeerIdentifier'], ':') || $device['os'] != 'junos') {
// v4 BGP4 MIB
// FIXME - needs moved to function
$peer_data_check = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', array(), 'CISCO-BGP4-MIB', $config['mibdir']);
if (count($peer_data_check) > 0) {
$peer2 = true;
}
@@ -307,4 +314,5 @@ if ($config['enable_bgp']) {
} //end if
echo "\n";
} //end foreach
} //end if
} //end if

View 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);
}

View File

@@ -203,7 +203,6 @@ function poll_device($device, $options) {
$poll_separator = ', ';
dbUpdate(array('status' => $status, 'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id']));
dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => 'Device is '.($status == '1' ? 'up' : 'down')), 'alerts');
log_event('Device status changed to '.($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down'));
}

View File

@@ -28,7 +28,7 @@ if (strstr($poll_device['sysDescr'], 'Intel64')) {
$hardware = 'Intel x64';
}
if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.1') {
if ($poll_device['sysObjectID'] == 'enterprises.311.1.1.3.1.1') {
if (strstr($poll_device['sysDescr'], 'Build Number: 1057')) {
$version = 'NT 3.51 Workstation';
}
@@ -81,6 +81,10 @@ if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.1') {
$version = '8.1 SP1 (NT 6.2)';
}
if (strstr($poll_device['sysDescr'], 'Version 6.3 (Build 10')) {
$version = '10 (NT 6.3)';
}
}
else if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.2') {
if (strstr($poll_device['sysDescr'], 'Build Number: 1057')) {

View File

@@ -79,7 +79,6 @@ echo "MySQL: ".$versions['mysql_ver']."\n";
echo "RRDTool: ".$versions['rrdtool_ver']."\n";
echo "SNMP: ".$versions['netsnmp_ver']."\n";
// Check php modules we use to make sure they are loaded
$extensions = array('pcre','curl','session','snmp','mcrypt');
foreach ($extensions as $extension) {
@@ -161,6 +160,10 @@ if (!$config['rrdcached']) {
}
}
if (isset($config['rrdcached'])) {
check_rrdcached();
}
// Disk space and permission checks
if (substr(sprintf('%o', fileperms($config['temp_dir'])), -3) != 777) {
print_warn('Your tmp directory ('.$config['temp_dir'].") is not set to 777 so graphs most likely won't be generated");
@@ -176,13 +179,25 @@ if ($space_check < 1) {
}
// Check programs
$bins = array('fping');
$bins = array('fping','rrdtool','snmpwalk','snmpget','snmpbulkwalk');
foreach ($bins as $bin) {
if (!is_file($config[$bin])) {
print_fail("$bin location is incorrect or bin not installed");
}
else {
print_ok("$bin has been found");
}
$disabled_functions = explode(',', ini_get('disable_functions'));
$required_functions = array('exec','passthru','shell_exec','escapeshellarg','escapeshellcmd','proc_close','proc_open','popen');
foreach ($required_functions as $function) {
if (in_array($function, $disabled_functions)) {
print_fail("$function is disabled in php.ini");
}
}
if (!function_exists('openssl_random_pseudo_bytes')) {
print_warn("openssl_random_pseudo_bytes is not being used for user password hashing. This is a recommended function (https://secure.php.net/openssl_random_pseudo_bytes)");
if (!is_readable('/dev/urandom')) {
print_warn("It also looks like we can't use /dev/urandom for user password hashing. We will fall back to generating our own hash - be warned");
}
}
@@ -257,15 +272,7 @@ foreach ($modules as $module) {
print_fail('You have not configured $config[\'rrd_dir\']');
}
else {
list($host,$port) = explode(':',$config['rrdcached']);
$connection = @fsockopen($host, $port);
if (is_resource($connection)) {
fclose($connection);
print_ok('Connection to rrdcached is ok');
}
else {
print_fail('Cannot connect to rrdcached instance');
}
check_rrdcached();
}
}
break;
@@ -317,17 +324,34 @@ foreach ($modules as $module) {
function print_ok($msg) {
echo "[OK] $msg\n";
}//end print_ok()
function print_fail($msg) {
echo "[FAIL] $msg\n";
}//end print_fail()
function print_warn($msg) {
echo "[WARN] $msg\n";
}//end print_warn()
function check_rrdcached() {
global $config;
list($host,$port) = explode(':',$config['rrdcached']);
if ($host == 'unix') {
// Using socket, check that file exists
if (!file_exists($port)) {
print_fail("$port doesn't appear to exist, rrdcached test failed");
}
}
else {
$connection = @fsockopen($host, $port);
if (is_resource($connection)) {
fclose($connection);
}
else {
print_fail('Cannot connect to rrdcached instance');
}
}
}//end check_rrdcached