mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
Merge pull request #2536 from paulgear/mib-poller-alpha2
MIB-based poller alpha2
This commit is contained in:
@@ -49,6 +49,13 @@ if ($device['serial']) {
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if ($device['sysObjectID']) {
|
||||
echo '<tr>
|
||||
<td>Object ID</td>
|
||||
<td>'.$device['sysObjectID'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if ($device['sysContact']) {
|
||||
echo '<tr>
|
||||
<td>Contact</td>';
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS custom graphing
|
||||
*
|
||||
* Author: Paul Gear
|
||||
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.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.
|
||||
*/
|
||||
|
||||
// FIXME: Dummy implementation which only supports ruckuswireless processor & mempool
|
||||
|
||||
$i = 0;
|
||||
$rrd_list = array();
|
||||
if ($subtype == 'processor') {
|
||||
$rrd_list[0] = array(
|
||||
'area' => 1,
|
||||
'ds' => 'mibval',
|
||||
'descr' => 'CPU Utilization',
|
||||
'filename' => rrd_name($device['hostname'], array('ruckusZDSystemStats-CPUUtil-0')),
|
||||
);
|
||||
}
|
||||
|
||||
if ($subtype == 'mempool') {
|
||||
$rrd_list[0] = array(
|
||||
'area' => 1,
|
||||
'ds' => 'mibval',
|
||||
'descr' => 'Memory Utilization',
|
||||
'filename' => rrd_name($device['hostname'], array('ruckusZDSystemStats-MemoryUtil-0')),
|
||||
);
|
||||
}
|
||||
|
||||
$units = '%%';
|
||||
$colours = 'mixed';
|
||||
$scale_min = '0';
|
||||
$scale_max = '100';
|
||||
$nototal = 1;
|
||||
|
||||
require_once 'includes/graphs/generic_multi_line.inc.php';
|
||||
@@ -13,25 +13,35 @@
|
||||
*/
|
||||
|
||||
$rrd_list = array();
|
||||
$prefix = rrd_name($device['hostname'], array($subtype, ''), '');
|
||||
foreach (glob($prefix.'*.rrd') as $filename) {
|
||||
$prefix = rrd_name($device['hostname'], array($subtype, ''), '');
|
||||
$filenames = glob($prefix."*.rrd");
|
||||
$count = count($filenames);
|
||||
foreach ($filenames as $filename) {
|
||||
// find out what * expanded to
|
||||
$globpart = str_replace($prefix, '', $filename);
|
||||
// take off the prefix
|
||||
$instance = substr($globpart, 0, -4);
|
||||
// take off ".rrd"
|
||||
$globpart = str_replace($prefix, '', $filename); // take off the prefix
|
||||
$instance = substr($globpart, 0, -4); // take off ".rrd"
|
||||
$ds = array();
|
||||
$mibparts = explode('-', $subtype);
|
||||
$mibvar = end($mibparts);
|
||||
$ds['ds'] = name_shorten($mibvar);
|
||||
$ds['ds'] = 'mibval';
|
||||
$ds['descr'] = "$mibvar-$instance";
|
||||
$ds['filename'] = $filename;
|
||||
$rrd_list[] = $ds;
|
||||
}
|
||||
|
||||
$colours = 'mixed';
|
||||
$scale_min = '0';
|
||||
$nototal = 0;
|
||||
$simple_rrd = true;
|
||||
|
||||
require 'includes/graphs/generic_multi_line.inc.php';
|
||||
// If there are multiple matching files, use a stacked graph instead of a line graph
|
||||
if ($count > 1) {
|
||||
$nototal = 1;
|
||||
$divider = $count;
|
||||
$text_orig = 1;
|
||||
$colours = 'manycolours';
|
||||
include "includes/graphs/generic_multi_simplex_seperated.inc.php";
|
||||
}
|
||||
else {
|
||||
$colours = 'mixed';
|
||||
$nototal = 0;
|
||||
include "includes/graphs/generic_multi_line.inc.php";
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ foreach ($procs as $proc) {
|
||||
|
||||
$unit_text = 'Load %';
|
||||
|
||||
$units = '%';
|
||||
$units = '';
|
||||
$total_units = '%';
|
||||
$colours = 'mixed';
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ foreach ($rrd_list as $rrd) {
|
||||
}
|
||||
|
||||
$colour = $config['graph_colours'][$colours][$iter];
|
||||
if (!empty($rrd['area']) && empty($rrd['areacolour'])) {
|
||||
$rrd['areacolour'] = $colour."20";
|
||||
}
|
||||
|
||||
$ds = $rrd['ds'];
|
||||
$filename = $rrd['filename'];
|
||||
@@ -69,8 +72,8 @@ foreach ($rrd_list as $rrd) {
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.2lf%s GPRINT:'.$id.'min:MIN:%5.2lf%s';
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.2lf%s GPRINT:'.$id.":AVERAGE:'%5.2lf%s\\n'";
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.2lf%s'.$units.' GPRINT:'.$id.'min:MIN:%5.2lf%s'.$units;
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.2lf%s'.$units.' GPRINT:'.$id.":AVERAGE:'%5.2lf%s$units\\n'";
|
||||
|
||||
$i++;
|
||||
$iter++;
|
||||
|
||||
@@ -43,12 +43,15 @@ if ($auth !== true && $auth != 1) {
|
||||
|
||||
require $config['install_dir']."/html/includes/graphs/$type/auth.inc.php";
|
||||
|
||||
if ($auth === true && is_file($config['install_dir']."/html/includes/graphs/$type/$subtype.inc.php")) {
|
||||
include $config['install_dir']."/html/includes/graphs/$type/$subtype.inc.php";
|
||||
if ($auth === true && is_custom_graph($type, $subtype, $device)) {
|
||||
include($config['install_dir'] . "/html/includes/graphs/custom.inc.php");
|
||||
}
|
||||
else if ($auth === true && is_mib_graph($type, $subtype)) {
|
||||
include $config['install_dir']."/html/includes/graphs/$type/mib.inc.php";
|
||||
}
|
||||
elseif ($auth === true && is_file($config['install_dir']."/html/includes/graphs/$type/$subtype.inc.php")) {
|
||||
include $config['install_dir']."/html/includes/graphs/$type/$subtype.inc.php";
|
||||
}
|
||||
else {
|
||||
graph_error("$type*$subtype ");
|
||||
// Graph Template Missing");
|
||||
|
||||
@@ -110,6 +110,8 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv6'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> IPv6 Search</a></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'mac'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> MAC Search</a></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'arp'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> ARP Tables</a></li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'mibs'))); ?>"><i class="fa fa-file-text-o fa-fw fa-lg"></i> MIB definitions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
@@ -167,6 +169,8 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
}
|
||||
echo '
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li><a href='.generate_url(array('page'=>'mib_assoc')).'><i class="fa fa-file-text-o fa-fw fa-lg"></i> MIB associations</a></li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
';
|
||||
|
||||
if ($config['navbar']['manage_groups']['hide'] === 0) {
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS device MIB association browser
|
||||
*
|
||||
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
|
||||
*
|
||||
* by Paul Gear
|
||||
* based on code by Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* in commit 054bf3ae209f34a2c3bc8968300722004903df1b
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$columns = array(
|
||||
'module',
|
||||
'mib',
|
||||
'included_by',
|
||||
'last_modified',
|
||||
);
|
||||
|
||||
if (isset($_POST['device_id'])) {
|
||||
// device_id supplied - get details for a single device
|
||||
// used by device MIB page
|
||||
$params = array(
|
||||
$_POST['device_id'],
|
||||
);
|
||||
$sql = 'SELECT * FROM `device_mibs`';
|
||||
$wheresql = ' WHERE `device_id` = ?';
|
||||
$sortcolumns = 3;
|
||||
$count_sql = "SELECT COUNT(*) FROM `device_mibs`".$wheresql;
|
||||
}
|
||||
else {
|
||||
// device_id not supplied - get details for a all devices
|
||||
// used by all device MIBs page
|
||||
$params = array();
|
||||
$sql = 'SELECT `d`.`hostname` as `hostname`, `dm`.* FROM `devices` `d`, `device_mibs` `dm`';
|
||||
$wheresql = ' WHERE `d`.`device_id` = `dm`.`device_id`';
|
||||
array_unshift($columns, 'hostname');
|
||||
$sortcolumns = 4;
|
||||
$count_sql = "SELECT COUNT(*) FROM `devices` `d`, `device_mibs` `dm`".$wheresql;
|
||||
}
|
||||
|
||||
// all columns are searchable - search across them
|
||||
if (isset($searchPhrase) && !empty($searchPhrase)) {
|
||||
$searchsql = implode(' OR ', array_map("search_phrase_column", array_map("mres", $columns)));
|
||||
$wheresql .= " AND ( $searchsql )";
|
||||
}
|
||||
$sql .= $wheresql;
|
||||
|
||||
// get total
|
||||
$total = dbFetchCell($count_sql, $params);
|
||||
if (empty($total)) {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
// set up default sort
|
||||
if (!isset($sort) || empty($sort)) {
|
||||
$sort = implode(', ', array_map("mres", array_slice($columns, 0, $sortcolumns)));
|
||||
}
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
// select only the required rows
|
||||
if (isset($current)) {
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
// load data from database into response array
|
||||
$response = array();
|
||||
foreach (dbFetchRows($sql, $params) as $mib) {
|
||||
$mibrow = array();
|
||||
foreach ($columns as $col) {
|
||||
$mibrow[$col] = $mib[$col];
|
||||
}
|
||||
if (!isset($_POST['device_id'])) {
|
||||
$device = device_by_id_cache($mib['device_id']);
|
||||
$mibrow['hostname'] = generate_device_link($device,
|
||||
$mib['hostname'], array('tab' => 'mib'));
|
||||
}
|
||||
$response[] = $mibrow;
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS device MIB OID browser
|
||||
*
|
||||
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
|
||||
*
|
||||
* by Paul Gear
|
||||
* based on code by Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* in commit 054bf3ae209f34a2c3bc8968300722004903df1b
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$columns = array(
|
||||
'module',
|
||||
'mib',
|
||||
'object_type',
|
||||
'oid',
|
||||
'value',
|
||||
'numvalue',
|
||||
'last_modified',
|
||||
);
|
||||
|
||||
|
||||
$params = array(
|
||||
$_POST['device_id'],
|
||||
);
|
||||
|
||||
// start of sql definition
|
||||
$sql = 'SELECT * FROM `device_oids`';
|
||||
|
||||
$wheresql = ' WHERE `device_id` = ?';
|
||||
|
||||
// all columns are searchable - search across them
|
||||
if (isset($searchPhrase) && !empty($searchPhrase)) {
|
||||
$searchsql = implode(' OR ', array_map("search_phrase_column", array_map("mres", $columns)));
|
||||
$wheresql .= " AND ( $searchsql )";
|
||||
}
|
||||
$sql .= $wheresql;
|
||||
|
||||
// get total
|
||||
$count_sql = "SELECT COUNT(*) FROM `device_oids`".$wheresql;
|
||||
$total = dbFetchCell($count_sql, $params);
|
||||
if (empty($total)) {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
// sort by first three columns by default
|
||||
if (!isset($sort) || empty($sort)) {
|
||||
$sort = implode(', ', array_map("mres", array_slice($columns, 0, 3)));
|
||||
}
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
// select only the required rows
|
||||
if (isset($current)) {
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
// load data from database into response array
|
||||
$response = array();
|
||||
foreach (dbFetchRows($sql, $params) as $mib) {
|
||||
$mibrow = array();
|
||||
foreach ($columns as $col) {
|
||||
$mibrow[$col] = $mib[$col];
|
||||
}
|
||||
$response[] = $mibrow;
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS MIB definition browser
|
||||
*
|
||||
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
|
||||
*
|
||||
* by Paul Gear
|
||||
* based on code by Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* in commit 054bf3ae209f34a2c3bc8968300722004903df1b
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$columns = array(
|
||||
'module',
|
||||
'mib',
|
||||
'object_type',
|
||||
'oid',
|
||||
'syntax',
|
||||
'description',
|
||||
'max_access',
|
||||
'status',
|
||||
'included_by',
|
||||
'last_modified',
|
||||
);
|
||||
|
||||
|
||||
// start of sql definition
|
||||
$sql = 'SELECT * FROM `mibdefs`';
|
||||
|
||||
// all columns are searchable - search across them
|
||||
if (isset($searchPhrase) && !empty($searchPhrase)) {
|
||||
$searchsql = implode(' OR ', array_map("search_phrase_column", array_map("mres", $columns)));
|
||||
$wheresql .= " WHERE ( $searchsql )";
|
||||
$sql .= $wheresql;
|
||||
}
|
||||
|
||||
// get total
|
||||
$count_sql = "SELECT COUNT(`object_type`) FROM `mibdefs`".$wheresql;
|
||||
$total = dbFetchCell($count_sql);
|
||||
if (empty($total)) {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
// sort by first three columns by default
|
||||
if (!isset($sort) || empty($sort)) {
|
||||
$sort = implode(', ', array_map("mres", array_slice($columns, 0, 3)));
|
||||
}
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
// select only the required rows
|
||||
if (isset($current)) {
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
// load data from database into response array
|
||||
$response = array();
|
||||
foreach (dbFetchRows($sql) as $mib) {
|
||||
$mibrow = array();
|
||||
foreach ($columns as $col) {
|
||||
$mibrow[$col] = $mib[$col];
|
||||
}
|
||||
$response[] = $mibrow;
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
Reference in New Issue
Block a user