Exemple #1
0
 $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';
 $component = new LibreNMS\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
Exemple #2
0
<?php

/*
 * LibreNMS module to capture statistics from the CISCO-NTP-MIB
 *
 * Copyright (c) 2016 Aaron Daniels <*****@*****.**>
 *
 * 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.
 */
$module = 'ntp';
$component = new LibreNMS\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.
$tblComponents = array();
// Let's gather some data..
// For Reference:
//      http://www.oidview.com/mibs/9/CISCO-NTP-MIB.html
//      http://www.cisco.com/c/en/us/support/docs/availability/high-availability/19643-ntpm.html
$cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2);
/*
 * False == no object found - this is not an error, no objects exist
 * null  == timeout or something else that caused an error, there may be objects but we couldn't get it.
 */
if (is_null($cntpPeersVarEntry)) {
    // We have to error here or we will end up deleting all our components.
Exemple #3
0
function get_components()
{
    global $config;
    $code = 200;
    $status = 'ok';
    $message = '';
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $hostname = $router['hostname'];
    // Do some filtering if the user requests.
    $options = array();
    // We need to specify the label as this is a LIKE query
    if (isset($_GET['label'])) {
        // set a label like filter
        $options['filter']['label'] = array('LIKE', $_GET['label']);
        unset($_GET['label']);
    }
    // Add the rest of the options with an equals query
    foreach ($_GET as $k => $v) {
        $options['filter'][$k] = array('=', $v);
    }
    // use hostname as device_id if it's all digits
    $device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
    $COMPONENT = new LibreNMS\Component();
    $components = $COMPONENT->getComponents($device_id, $options);
    $output = array('status' => "{$status}", 'err-msg' => $message, 'count' => count($components[$device_id]), 'components' => $components[$device_id]);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
Exemple #4
0
                echo '<li><a href="apps/app=' . $app['app_type'] . '/"><i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i> ' . nicecase($app['app_type']) . ' </a></li>';
            }
        }
    }
    ?>
          </ul>
        </li>
<?php 
}
$routing_count['bgp'] = dbFetchCell("SELECT COUNT(bgpPeer_id) from `bgpPeers` LEFT JOIN devices AS D ON bgpPeers.device_id=D.device_id WHERE D.device_id IS NOT NULL");
$routing_count['ospf'] = dbFetchCell("SELECT COUNT(ospf_instance_id) FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled'");
$routing_count['cef'] = dbFetchCell("SELECT COUNT(cef_switching_id) from `cef_switching`");
$routing_count['vrf'] = dbFetchCell("SELECT COUNT(vrf_id) from `vrfs`");
$component = new LibreNMS\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">
          <a href="routing/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-arrows fa-fw fa-lg fa-nav-icons hidden-md" aria-hidden="true"></i> <span class="hidden-sm">Routing</span></a>
          <ul class="dropdown-menu">
<?php 
    $separator = 0;
    if ($_SESSION['userlevel'] >= '5' && $routing_count['vrf']) {
        echo '            <li><a href="routing/protocol=vrf/"><i class="fa fa-arrows-alt fa-fw fa-lg" aria-hidden="true"></i> VRFs</a></li>';
        $separator++;
    }
    if ($_SESSION['userlevel'] >= '5' && $routing_count['ospf']) {
        if ($separator) {
            echo '            <li role="presentation" class="divider"></li>';
Exemple #5
0
<?php

header('Content-type: application/json');
if (is_admin() === false) {
    $response = array('status' => 'error', 'message' => 'Need to be admin');
    echo _json_encode($response);
    exit;
}
$status = 'error';
$message = 'Error with config';
// enable/disable components on devices.
$device_id = intval($_POST['device']);
$OBJCOMP = new LibreNMS\Component();
// Go get the component array.
$COMPONENTS = $OBJCOMP->getComponents($device_id);
// We only care about our device id.
$COMPONENTS = $COMPONENTS[$device_id];
// Track how many updates we are making.
$UPDATE = array();
foreach ($COMPONENTS as $ID => $AVP) {
    // Is the component disabled?
    if (isset($_POST['dis_' . $ID])) {
        // Yes it is, was it disabled before?
        if ($COMPONENTS[$ID]['disabled'] == 0) {
            // No it wasn't, best we disable it then..
            $COMPONENTS[$ID]['disabled'] = 1;
            $UPDATE[$ID] = true;
        }
    } else {
        // No its not, was it disabled before?
        if ($COMPONENTS[$ID]['disabled'] == 1) {
Exemple #6
0
<?php

$COMPONENT = new LibreNMS\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-<?php 
    echo $DEVICE_ID;
    ?>
">
    <div class="panel-heading">
        <h3 class="panel-title"><a href="<?php 
    echo $LINK;
    ?>
"><?php 
    echo 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'] == 0) {
                $OVERLAY_STATUS = "<span class='green pull-right'>Normal</span>";
                $GLI = "";
Exemple #7
0
}
// Add a Sort option
if (!isset($sort) || empty($sort)) {
    // Nothing supplied, default is id ASC.
    $options['sort'] = 'id asc';
} else {
    $options['sort'] = $sort;
}
// Define the Limit parameters
if (isset($current)) {
    $start = $current * $rowCount - $rowCount;
}
if ($rowCount != -1) {
    $options['limit'] = array($start, $rowCount);
}
$COMPONENTS = $OBJCOMP->getComponents($device_id, $options);
$response[] = array('id' => '<button type="submit" id="save-form" class="btn btn-success btn-sm" title="Save current component disable/ignore settings">Save</button><button type="submit" id="form-reset" class="btn btn-danger btn-sm" title="Reset form to when the page was loaded">Reset</button>', 'label' => '&nbsp;', 'status' => '<button type="submit" id="warning-select" class="btn btn-default btn-sm" title="Disable alerting on all currently warning components">Warning</button>&nbsp;<button type="submit" id="critical-select" class="btn btn-default btn-sm" title="Disable alerting on all currently critical components">Critical</button>', 'disable' => '<button type="submit" id="disable-toggle" class="btn btn-default btn-sm" title="Toggle polling for all components">Toggle</button><button type="button" id="disable-select" class="btn btn-default btn-sm" title="Disable polling on all components">Select All</button>', 'ignore' => '<button type="submit" id="ignore-toggle" class="btn btn-default btn-sm" title="Toggle alerting for all components">Toggle</button><button type="button" id="ignore-select" class="btn btn-default btn-sm" title="Disable alerting on all components">Select All</button>');
foreach ($COMPONENTS[$device_id] as $ID => $AVP) {
    if ($AVP['status'] == 0) {
        $class = "green";
        $status = "Ok";
    } elseif ($AVP['status'] == 1) {
        $class = "grey";
        $status = "Warning";
    } else {
        // Critical
        $class = "red";
        $status = "Critical";
    }
    $response[] = array('id' => $ID, 'type' => $AVP['type'], 'label' => $AVP['label'], 'status' => "<span name='status_" . $ID . "' class='" . $class . "'>" . $status . "</span>", 'disable' => '<input type="checkbox" class="disable-check" name="dis_' . $ID . '"' . ($AVP['disabled'] ? 'checked' : '') . '>', 'ignore' => '<input type="checkbox" class="ignore-check" name="ign_' . $ID . '"' . ($AVP['ignore'] ? 'checked' : '') . '>');
}
Exemple #8
0
<?php

/*
 * LibreNMS module to poll hardware components in a Cisco Integrated Management Controller
 *
 * Copyright (c) 2016 Aaron Daniels <*****@*****.**>
 *
 * 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.
 */
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], array('type' => 'Cisco-CIMC'));
// 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 some data..
    $tblUCSObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1', 0);
    // Make sure we have an array of data before we try to iterate over it
    if (is_array($tblUCSObjects)) {
        // First, let's extract any active faults, we will use them later.
        $faults = array();
        foreach ($tblUCSObjects as $oid => $data) {
            if (strstr($oid, '1.3.6.1.4.1.9.9.719.1.1.1.1.5.')) {
                $id = substr($oid, 30);
                $fobj = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.5.' . $id];
                $fobj = preg_replace('/^sys/', '/sys', $fobj);
                $faults[$fobj] = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.11.' . $id];