コード例 #1
0
ファイル: api_functions.inc.php プロジェクト: wiad/librenms
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 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);
}
コード例 #2
0
/*
 * 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.
 */
require_once "../includes/component.php";
$component = new component();
$options['filter']['type'] = array('=', 'Cisco-CBQOS');
$components = $component->getComponents($device['device_id'], $options);
// We only care about our device id.
$components = $components[$device['device_id']];
// Determine a policy to show.
if (!isset($vars['policy'])) {
    foreach ($components as $id => $array) {
        if ($array['qos-type'] == 1 && $array['ifindex'] == $port['ifIndex'] && $array['parent'] == 0) {
            // Found the first policy
            $vars['policy'] = $id;
            continue;
        }
    }
}
include "includes/graphs/common.inc.php";
$rrd_options .= " -l 0 -E ";
$rrd_options .= " COMMENT:'Class-Map              Now      Avg      Max\\n'";
コード例 #3
0
ファイル: device.inc.php プロジェクト: greggcz/librenms
 if ($device_routing_count['ospf']) {
     $routing_tabs[] = 'ospf';
 }
 $device_routing_count['cef'] = dbFetchCell('SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ?', array($device['device_id']));
 if ($device_routing_count['cef']) {
     $routing_tabs[] = 'cef';
 }
 $device_routing_count['vrf'] = @dbFetchCell('SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ?', array($device['device_id']));
 if ($device_routing_count['vrf']) {
     $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')) . '">
         <img src="images/16/arrow_branch.png" align="absmiddle" border="0" /> Routing
         </a>
         </li>';
 }
 $device_pw_count = @dbFetchCell('SELECT COUNT(*) FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']));
 if ($device_pw_count) {
     echo '<li class="' . $select['pseudowires'] . '">
         <a href="' . generate_device_url($device, array('tab' => 'pseudowires')) . '">
コード例 #4
0
/*
 * 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';
    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.
    $tblCBQOS = array();
    // Let's gather some data..
    $tblcbQosServicePolicy = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.1');
    $tblcbQosObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.5', 2);
    $tblcbQosPolicyMapCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.6');
    $tblcbQosClassMapCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.7');
    $tblcbQosMatchStmtCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.8');
    /*
     * 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($tblcbQosServicePolicy) || is_null($tblcbQosObjects) || is_null($tblcbQosPolicyMapCfg) || is_null($tblcbQosClassMapCfg) || is_null($tblcbQosMatchStmtCfg)) {
コード例 #5
0
ファイル: component.inc.php プロジェクト: greggcz/librenms
<?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']);
require_once "../includes/component.php";
$OBJCOMP = new 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?
コード例 #6
0
ファイル: component.inc.php プロジェクト: greggcz/librenms
$row = 1;
$device_id = $_POST['device_id'];
require_once "../includes/component.php";
$OBJCOMP = new 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="alert-select" class="btn btn-default btn-sm" title="Disable alerting on all currently-alerting components">Alerting</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) {
    $response[] = array('id' => $ID, 'type' => $AVP['type'], 'label' => $AVP['label'], 'status' => $AVP['status'] ? "<span name='status_" . $ID . "' class='green'>Normal</span>" : "<span name='status_" . $ID . "' class='red'>Alert</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' : '') . '>');
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => count($COMPONENTS[$device_id]));
echo _json_encode($output);
コード例 #7
0
ファイル: cisco-otv.inc.php プロジェクト: greggcz/librenms
<?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-<?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'] == 1) {
                $OVERLAY_STATUS = "<span class='green pull-right'>Normal</span>";