Add global MIB association table

This commit is contained in:
Paul Gear
2015-12-06 19:25:24 +10:00
parent 2244a5f31d
commit 6fae9874b0
3 changed files with 72 additions and 10 deletions

View File

@@ -169,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) {

View File

@@ -22,14 +22,25 @@ $columns = array(
'last_modified',
);
$params = array(
if (isset($_POST['device_id'])) {
// device_id supplied - get details for a single device
// used by device MIB page
$params = array(
$_POST['device_id'],
);
// start of sql definition
$sql = 'SELECT * FROM `device_mibs`';
$wheresql = ' WHERE `device_id` = ?';
);
$sql = 'SELECT * FROM `device_mibs`';
$wheresql = ' WHERE `device_id` = ?';
$sortcolumns = 3;
}
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;
}
// all columns are searchable - search across them
if (isset($searchPhrase) && !empty($searchPhrase)) {
@@ -45,9 +56,9 @@ if (empty($total)) {
$total = 0;
}
// sort by first three columns by default
// set up default sort
if (!isset($sort) || empty($sort)) {
$sort = implode(', ', array_map("quote_sql_word", array_slice($columns, 0, 3)));
$sort = implode(', ', array_map("quote_sql_word", array_slice($columns, 0, $sortcolumns)));
}
$sql .= " ORDER BY $sort";

View File

@@ -0,0 +1,49 @@
<?php
/*
* LibreNMS global MIB association viewer
*
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
*
* Author: Paul Gear
*
* 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.
*/
?>
<h4>MIB associations for all devices</h4>
<div class="table-responsive">
<table id="mibs" class="table table-hover table-condensed mibs">
<thead>
<tr>
<th data-column-id="hostname">Hostname</th>
<th data-column-id="module">Module</th>
<th data-column-id="mib">MIB</th>
<th data-column-id="included_by">Included by</th>
<th data-column-id="last_modified">Last Modified</th>
</tr>
</thead>
</table>
</div>
<script>
var grid = $("#mibs").bootgrid({
ajax: true,
rowCount: [50,100,250,-1],
post: function ()
{
return {
id: "device_mibs",
};
},
url: "/ajax_table.php",
formatters: {
},
templates: {
}
});
</script>