mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Device Components.
The purpose of this feature is to provide a framework for discovery modules to store information in the database, without needing to add new tables for each feature. This Feature provides: - A database structure to store data. - An API to store and retrieve data from the database. - Integration to the LibreNMS APIv0. - Ability to disable/ignore components. - Default alerting rules. - The API returns $COMPONENT[$device_id][$component_id] to allow pulling of data for multiple devices. The intent is to be able to create 'Applications' the consolidate data from applications covering multiple devices. - Added some developer documentation
This commit is contained in:
@@ -38,6 +38,8 @@ else {
|
||||
$panes['storage'] = 'Storage';
|
||||
$panes['misc'] = 'Misc';
|
||||
|
||||
$panes['component'] = 'Components';
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
unset($sep);
|
||||
|
102
html/pages/device/edit/component.inc.php
Normal file
102
html/pages/device/edit/component.inc.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<span id="message"><small><div class="alert alert-danger">n.b For the first time, please click any button twice.</div></small></span>
|
||||
|
||||
<form id='components' class='form-inline' method='POST'>
|
||||
<table id='table' class='table table-condensed table-responsive table-striped'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id='id'>ID</th>
|
||||
<th data-column-id='type'>Type</th>
|
||||
<th data-column-id='label'>Label</th>
|
||||
<th data-column-id='status'>Status</th>
|
||||
<th data-column-id='disable' data-sortable='false'>Disable</th>
|
||||
<th data-column-id='ignore' data-sortable='false'>Ignore</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<input type='hidden' name='component' value='yes'>
|
||||
<input type='hidden' name='type' value='component'>
|
||||
<input type='hidden' name='device' value='<?php echo $device['device_id'];?>'>
|
||||
</form>
|
||||
<script>
|
||||
// Waiting for the document to be ready.
|
||||
$(document).ready(function() {
|
||||
|
||||
$('form#components').submit(function (event) {
|
||||
|
||||
$('#disable-toggle').click(function (event) {
|
||||
// invert selection on all disable buttons
|
||||
event.preventDefault();
|
||||
$('input[name^="dis_"]').trigger('click');
|
||||
});
|
||||
|
||||
$('#disable-select').click(function (event) {
|
||||
// select all disable buttons
|
||||
event.preventDefault();
|
||||
$('.disable-check').prop('checked', true);
|
||||
});
|
||||
$('#ignore-toggle').click(function (event) {
|
||||
// invert selection on all ignore buttons
|
||||
event.preventDefault();
|
||||
$('input[name^="ign_"]').trigger('click');
|
||||
});
|
||||
$('#ignore-select').click(function (event) {
|
||||
// select all ignore buttons
|
||||
event.preventDefault();
|
||||
$('.ignore-check').prop('checked', true);
|
||||
});
|
||||
$('#alert-select').click(function (event) {
|
||||
// select ignore buttons for all ports which are down
|
||||
event.preventDefault();
|
||||
$('[name^="status_"]').each(function () {
|
||||
var name = $(this).attr('name');
|
||||
var text = $(this).text();
|
||||
if (name && text == 'Alert') {
|
||||
// get the component number from the object name
|
||||
var id = name.split('_')[1];
|
||||
// find its corresponding checkbox and toggle it
|
||||
$('input[name="ign_' + id + '"]').trigger('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#form-reset').click(function (event) {
|
||||
// reset objects in the form to the value when the page was loaded
|
||||
event.preventDefault();
|
||||
$('#components')[0].reset();
|
||||
});
|
||||
$('#save-form').click(function (event) {
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/ajax_form.php",
|
||||
data: $('form#components').serialize(),
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
if (data.status == 'ok') {
|
||||
$("#message").html('<div class="alert alert-info">' + data.message + '</div>')
|
||||
} else {
|
||||
$("#message").html('<div class="alert alert-danger">' + data.message + '</div>');
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
$("#message").html('<div class="alert alert-danger">Error creating config item</div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
var grid = $("#table").bootgrid({
|
||||
ajax: true,
|
||||
rowCount: [50,100,250,-1],
|
||||
post: function ()
|
||||
{
|
||||
return {
|
||||
id: 'component',
|
||||
device_id: "<?php echo $device['device_id']; ?>"
|
||||
};
|
||||
},
|
||||
url: "/ajax_table.php"
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user