mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added ability to filter devices by type and os for Oxizied api call
This commit is contained in:
@ -40,3 +40,10 @@ You will need to configure default credentials for your devices, LibreNMS doesn'
|
||||
```
|
||||
|
||||
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?"
|
||||
|
||||
It's also possible to exclude certain device types and OS' from being output via the API. This is currently only possible via config.php:
|
||||
|
||||
```php
|
||||
$config['oxidized']['ignore_types'] = array('server');
|
||||
$config['oxidized']['ignore_os'] = array('linux');
|
||||
```
|
||||
|
@ -890,12 +890,14 @@ function get_inventory() {
|
||||
|
||||
|
||||
function list_oxidized() {
|
||||
// return details of a single device
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$app->response->headers->set('Content-Type', 'application/json');
|
||||
|
||||
$devices = array();
|
||||
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) {
|
||||
$device_types = "'".implode("','", $config['oxidized']['ignore_types'])."'";
|
||||
$device_os = "'".implode("','", $config['oxidized']['ignore_os'])."'";
|
||||
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) AND (`type` NOT IN ($device_types) AND `os` NOT IN ($device_os))") as $device) {
|
||||
$devices[] = $device;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user