diff --git a/doc/API/API-Docs.md b/doc/API/API-Docs.md index f4d3ed1cb..7bf1526cb 100644 --- a/doc/API/API-Docs.md +++ b/doc/API/API-Docs.md @@ -440,7 +440,7 @@ Output: ### Function: `list_oxidized` [`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 diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index 38297dbbc..6bb7c2bf4 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -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 sending 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 Oxidized': + +```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. diff --git a/doc/Installation/Installation-(Debian-Ubuntu).md b/doc/Installation/Installation-(Debian-Ubuntu).md index fce129201..23fb2b17e 100644 --- a/doc/Installation/Installation-(Debian-Ubuntu).md +++ b/doc/Installation/Installation-(Debian-Ubuntu).md @@ -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 ### diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index ddfdc2cc1..4d89ca1cb 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -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 diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index deb557fd9..9b213e611 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -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; } diff --git a/html/pages/settings/external.inc.php b/html/pages/settings/external.inc.php index a912ce403..ccade1add 100644 --- a/html/pages/settings/external.inc.php +++ b/html/pages/settings/external.inc.php @@ -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( diff --git a/sql-schema/088.sql b/sql-schema/088.sql new file mode 100644 index 000000000..48ce697f0 --- /dev/null +++ b/sql-schema/088.sql @@ -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');