mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add MIB browser
This commit is contained in:
@@ -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">
|
||||
|
||||
91
html/includes/table/mibs.inc.php
Normal file
91
html/includes/table/mibs.inc.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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',
|
||||
);
|
||||
|
||||
function search_phrase_column($c)
|
||||
{
|
||||
global $searchPhrase;
|
||||
return "$c LIKE '%$searchPhrase%'";
|
||||
}
|
||||
|
||||
function quote_sql_word($c)
|
||||
{
|
||||
return "`$c`";
|
||||
}
|
||||
|
||||
|
||||
// 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("quote_sql_word", $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("quote_sql_word", 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,
|
||||
'sql' => $sql,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
36
html/pages/mibs.inc.php
Normal file
36
html/pages/mibs.inc.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<h4><i class="fa fa-file-text-o"></i> Loaded MIB definitions</h4>
|
||||
<div class="table-responsive">
|
||||
<table id="mibs" class="table table-hover table-condensed mibs">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="module">Module</th>
|
||||
<th data-column-id="mib">MIB</th>
|
||||
<th data-column-id="object_type">Object Type</th>
|
||||
<th data-column-id="oid">Object Id</th>
|
||||
<th data-column-id="syntax">Syntax</th>
|
||||
<th data-column-id="description">Description</th>
|
||||
<th data-column-id="max_access">Maximum Access</th>
|
||||
<th data-column-id="status">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var grid = $("#mibs").bootgrid({
|
||||
ajax: true,
|
||||
rowCount: [50,100,250,-1],
|
||||
post: function ()
|
||||
{
|
||||
return {
|
||||
id: "mibs",
|
||||
view: '<?php echo $vars['view']; ?>'
|
||||
};
|
||||
},
|
||||
url: "/ajax_table.php",
|
||||
formatters: {
|
||||
},
|
||||
templates: {
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user