diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index 7fb605571..19ba60f15 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -38,3 +38,5 @@ You will need to configure default credentials for your devices, LibreNMS doesn' headers: X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed' ``` + +If you have devices which you do not wish to appear in Oxidized then you can edit those devices in Device -> Edit -> Misc and enable "Exclude from Oxidized?" diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 37bf96d98..83bcb8929 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -888,7 +888,7 @@ function list_oxidized() { $app->response->headers->set('Content-Type', 'application/json'); $devices = array(); - foreach (dbFetchRows("SELECT hostname,os FROM `devices` WHERE `status`='1'") as $device) { + foreach (dbFetchRows("SELECT hostname,os FROM `devices` LEFT JOIN devices_attribs AS `DA` ON devices.device_id = DA.device_id AND `DA`.attrib_type='override_Oxidized_disable' WHERE `status`='1' AND (DA.attrib_value = 'false' OR DA.attrib_value IS NULL)") as $device) { $devices[] = $device; } diff --git a/html/includes/forms/override-config.inc.php b/html/includes/forms/override-config.inc.php new file mode 100644 index 000000000..6004710dc --- /dev/null +++ b/html/includes/forms/override-config.inc.php @@ -0,0 +1,48 @@ + + * + * 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 (is_admin() === false) { + $response = array( + 'status' => 'error', + 'message' => 'Need to be admin', + ); + echo _json_encode($response); + exit; +} + +$device['device_id'] = mres($_POST['device_id']); +$attrib = mres($_POST['attrib']); +$state = mres($_POST['state']); +$status = 'error'; +$message = 'Error with config'; + +if (empty($device['device_id'])) { + $message = 'No device passed'; +} +else { + if ($state == true) { + set_dev_attrib($device, $attrib, $state); + } + else { + del_dev_attrib($device, $attrib); + } + $status = 'ok'; + $message = 'Config has been updated'; +} + +$response = array( + 'status' => $status, + 'message' => $message, +); +echo _json_encode($response); diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 003d3a6f0..e29c1d863 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1167,3 +1167,15 @@ function alert_details($details) { }//end alert_details() +function dynamic_override_config($type, $name, $device) { + $attrib_val = get_dev_attrib($device,$name); + if ($attrib_val == 'true') { + $checked = 'checked'; + } + else { + $checked = ''; + } + if ($type == 'checkbox') { + return ''; + } +}//end dynamic_override_config() diff --git a/html/js/librenms.js b/html/js/librenms.js new file mode 100644 index 000000000..cd9af4fd6 --- /dev/null +++ b/html/js/librenms.js @@ -0,0 +1,26 @@ +$(document).ready(function() { + $("[name='override_config']").bootstrapSwitch('offColor','danger'); + $('input[name="override_config"]').on('switchChange.bootstrapSwitch', function(event, state) { + event.preventDefault(); + var $this = $(this); + var attrib = $this.data('attrib'); + var device_id = $this.data('device_id'); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state }, + dataType: 'json', + success: function(data) { + if (data.status == 'ok') { + toastr.success(data.message); + } + else { + toastr.error(data.message); + } + }, + error: function() { + toastr.error('Could not set this override'); + } + }); + }); +}); diff --git a/html/pages/device/edit.inc.php b/html/pages/device/edit.inc.php index 86cc6d490..47d61d8fc 100644 --- a/html/pages/device/edit.inc.php +++ b/html/pages/device/edit.inc.php @@ -36,6 +36,7 @@ else { } $panes['storage'] = 'Storage'; + $panes['misc'] = 'Misc'; print_optionbar_start(); @@ -64,6 +65,8 @@ else { print_optionbar_end(); + echo ''; + if (is_file("pages/device/edit/".mres($vars['section']).".inc.php")) { require "pages/device/edit/".mres($vars['section']).".inc.php"; } diff --git a/html/pages/device/edit/misc.inc.php b/html/pages/device/edit/misc.inc.php new file mode 100644 index 000000000..5f66c88fd --- /dev/null +++ b/html/pages/device/edit/misc.inc.php @@ -0,0 +1,13 @@ + +
+ +
+ '.dynamic_override_config('checkbox','override_Oxidized_disable', $device).' +
+
+ +'; +