mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added group support for Oxidized
This commit is contained in:
@@ -440,7 +440,7 @@ Output:
|
||||
|
||||
### <a name="api-route-21">Function: `list_oxidized`</a> [`top`](#top)
|
||||
|
||||
List devices for use with Oxidized.
|
||||
List devices for use with Oxidized. If you have group support enabled then a group will also be returned based on your config.
|
||||
|
||||
Route: /api/v0/oxidized
|
||||
|
||||
|
@@ -18,6 +18,27 @@ We also support config versioning within Oxidized, this will allow you to see th
|
||||
$config['oxidized']['features']['versioning'] = true;
|
||||
```
|
||||
|
||||
Oxidized supports various ways to utilise credentials to login to devices, you can specify global username/password within Oxidized, Group level username/password or per device.
|
||||
We currently support senting groups back to Oxidized so that you can then define group credentials within Oxidized. To enable this support please switch on 'Enable the return of groups to Oxidize':
|
||||
|
||||
```php
|
||||
$config['oxidized']['group_support'] = true;
|
||||
```
|
||||
|
||||
You can set a default group that devices will fall back to with:
|
||||
|
||||
```php
|
||||
$config['oxidized']['default_group'] = 'default';
|
||||
```
|
||||
|
||||
To return a group to Oxidized you can do this by matching a regex for either hostname or location. The order is hostname is matched first, if nothing is found then location is attempted.
|
||||
The first match found will be used. To match on the device hostnames that contain 'lon-sw' or if the location contains 'London' then you would place the following within config.php:
|
||||
|
||||
```php
|
||||
$config['oxidized']['group']['hostname'][] = array('regex' => '/^lon-sw/', 'group' => 'london-switches');
|
||||
$config['oxidized']['group']['location'][] = array('regex' => '/london/', 'group' => 'london-switches');
|
||||
```
|
||||
|
||||
### Feeding Oxidized
|
||||
|
||||
Oxidized has support for feeding devices into it via an API call, support for Oxidized has been added to the LibreNMS API. A sample config for Oxidized is provided below.
|
||||
|
@@ -69,6 +69,7 @@ Adding the above line to `/etc/snmp/snmpd.conf` and running `service snmpd resta
|
||||
|
||||
In `/etc/php5/apache2/php.ini` and `/etc/php5/cli/php.ini`, ensure date.timezone is set to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid
|
||||
examples are: "America/New York", "Australia/Brisbane", "Etc/UTC".
|
||||
Please also ensure that allow_url_fopen is enabled.
|
||||
|
||||
### Adding the librenms-user ###
|
||||
|
||||
|
@@ -127,6 +127,15 @@ Set `httpd` to start on system boot.
|
||||
**CentOS 7**
|
||||
systemctl enable httpd
|
||||
|
||||
You need to configure snmpd appropriately if you have not already done so. An absolute minimal config for snmpd is:
|
||||
|
||||
rocommunity public 127.0.0.1
|
||||
|
||||
Adding the above line to `/etc/snmp/snmpd.conf` and running `service snmpd restart` will activate this config.
|
||||
|
||||
In `/etc/php.ini`, ensure date.timezone is set to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid
|
||||
examples are: "America/New York", "Australia/Brisbane", "Etc/UTC". Please also ensure that allow_url_fopen is enabled.
|
||||
|
||||
Next, add the following to `/etc/httpd/conf.d/librenms.conf`
|
||||
|
||||
```apache
|
||||
|
@@ -904,7 +904,27 @@ function list_oxidized() {
|
||||
$devices = array();
|
||||
$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) {
|
||||
foreach (dbFetchRows("SELECT hostname,os,location FROM `devices` LEFT JOIN devices_attribs AS `DA` ON devices.device_id = DA.device_id AND `DA`.attrib_type='override_Oxidized_disable' WHERE `disabled`='0' AND `ignore` = 0 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) {
|
||||
if ($config['oxidized']['group_support'] == "true") {
|
||||
foreach ($config['oxidized']['group']['hostname'] as $host_group) {
|
||||
if (preg_match($host_group['regex'].'i', $device['hostname'])) {
|
||||
$device['group'] = $host_group['group'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($device['group'])) {
|
||||
foreach ($config['oxidized']['group']['location'] as $host_group) {
|
||||
if (preg_match($host_group['regex'].'i', $device['location'])) {
|
||||
$device['group'] = $host_group['group'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($device['group']) && !empty($config['oxidized']['default_group'])) {
|
||||
$device['group'] = $config['oxidized']['default_group'];
|
||||
}
|
||||
}
|
||||
unset($device['location']);
|
||||
$devices[] = $device;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,14 @@ $oxidized_conf = array(
|
||||
'descr' => 'Enable config versioning access',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array('name' => 'oxidized.group_support',
|
||||
'descr' => 'Enable the return of groups to Oxidized',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array('name' => 'oxidized.default_group',
|
||||
'descr' => 'Set the default group returned',
|
||||
'type' => 'text',
|
||||
),
|
||||
);
|
||||
|
||||
$unixagent_conf = array(
|
||||
|
1
sql-schema/086.sql
Normal file
1
sql-schema/086.sql
Normal file
@@ -0,0 +1 @@
|
||||
INSERT INTO config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('oxidized.default_group','','','Set the default group returned','external',0,'oxidized',0,'0','0'),('oxidized.group_support','false','false','Enable the return of groups to Oxidized','external',0,'oxidized',0,'0','0');
|
Reference in New Issue
Block a user