Added ability to filter devices by type and os for Oxizied api call

This commit is contained in:
laf 2015-12-02 20:22:38 +00:00
parent ebec58ac00
commit 6dfc186bb5
2 changed files with 11 additions and 2 deletions

View File

@ -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');
```

View File

@ -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;
}