Example #1
0
function delete_components()
{
    global $config;
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $cid = $router['component'];
    $COMPONENT = new LibreNMS\Component();
    if ($COMPONENT->deleteComponent($cid)) {
        // Edit Success.
        $code = 200;
        $status = 'ok';
        $message = '';
    } else {
        // Edit Failure.
        $code = 500;
        $status = 'error';
        $message = 'Components could not be deleted.';
    }
    $output = array('status' => "{$status}", 'err-msg' => $message);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
Example #2
0
 $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';
 $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) {
Example #3
0
<?php

/*
 * LibreNMS module to display Cisco Class-Based QoS Details
 *
 * Copyright (c) 2015 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();
$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 = rrd_name($device['hostname'], array('cisco', 'otv', $array['label'], 'vlan'));
        if (file_exists($rrd_filename)) {
            // Stack the area on the second and subsequent DS's
            $stack = "";
            if ($count != 0) {
                $stack = ":STACK ";
Example #4
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.
Example #5
0
<?php

$OBJCOMP = new LibreNMS\Component();
$common_output[] = '
<div>
    <table id="component-status" class="table table-hover table-condensed table-striped">
        <thead>
            <tr>
                <th data-column-id="status" data-order="desc">Status</th>
                <th data-column-id="count">Count</th>
            </tr>
        </thead>
        <tbody>
';
foreach ($OBJCOMP->getComponentStatus() as $k => $v) {
    if ($k == 0) {
        $status = 'Ok';
        $color = 'green';
    } elseif ($k == 1) {
        $status = 'Warning';
        $color = 'grey';
    } else {
        $status = 'Critical';
        $color = 'red';
    }
    $common_output[] .= '
            <tr>
                <td><p class="text-left ' . $color . '">' . $status . '</p></td>
                <td><p class="text-left ' . $color . '">' . $v . '</p></td>
            </tr>
';
Example #6
0
                echo '</ul></li>';
            } else {
                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']) {
Example #7
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) {
Example #8
0
<?php

/*
 * LibreNMS module to capture Cisco Class-Based QoS Details
 *
 * Copyright (c) 2015 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.
 */
if ($device['os_group'] == "cisco") {
    $module = 'Cisco-CBQOS';
    $component = new LibreNMS\Component();
    $options['filter']['type'] = array('=', $module);
    $options['filter']['disabled'] = array('=', 0);
    $options['filter']['ignore'] = 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..
        $tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2);
        // Loop through the components and extract the data.
        foreach ($components as $key => $array) {
            $type = $array['qos-type'];
            // Get data from the class table.
            if ($type == 2) {
Example #9
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 = "";
Example #10
0
<?php

$row = 1;
$device_id = $_POST['device_id'];
$OBJCOMP = new LibreNMS\Component();
// Add a filter if supplied
if (isset($searchPhrase) && !empty($searchPhrase)) {
    $options['filter']['label'] = array('LIKE', $searchPhrase);
}
// 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";
Example #11
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];