Files
Tony Murray 3e35ee0e7d Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls)
- Parse coordinates from the location more consistently
- Add settings to webui
- ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~
- Google Maps, Bing, Mapquest, and OpenStreetMap supported initially.
- Default to OpenStreetMap, which doesn't require a key.  They will liberally hand out bans if you exceed 1 query per second though.
- All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate)
- Update all (I think) sql queries to handle the new structure
- Remove final vestiges of override_sysLocation as a device attribute
- Update existing device groups and rules in DB
- Tested all APIs with good/bad location, no/bad/good key, and no connection.
- Cannot fix advanced queries that use location

This blocks #8868

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
2018-11-28 22:49:18 +00:00

127 lines
4.4 KiB
PHP

<?php
$no_refresh = true;
$config_groups = get_config_by_group('external');
$location_conf = [
[
'name' => 'geoloc.engine',
'descr' => 'Geocoding Engine',
'type' => 'select',
'options' => [
['value' => 'google', 'description' => 'Google Maps'],
['value' => 'openstreetmap', 'description' => 'OpenStreetMap'],
['value' => 'mapquest', 'description' => 'MapQuest'],
['value' => 'bing', 'description' => 'Bing Maps'],
]
],
[
'name' => 'geoloc.api_key',
'descr' => 'Geocoding API Key',
'type' => 'text',
'class' => 'geoloc_api_key'
],
];
$oxidized_conf = array(
array('name' => 'oxidized.enabled',
'descr' => 'Enable Oxidized support',
'type' => 'checkbox',
),
array('name' => 'oxidized.url',
'descr' => 'URL to your Oxidized API',
'type' => 'text',
'pattern' => '[a-zA-Z0-9]{1,5}://.*',
'required' => true,
),
array('name' => 'oxidized.features.versioning',
'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',
),
array('name' => 'oxidized.reload_nodes',
'descr' => 'Reload Oxidized nodes list, each time a device is added',
'type' => 'checkbox',
),
);
$unixagent_conf = array(
array('name' => 'unix-agent.port',
'descr' => 'Default unix-agent port',
'type' => 'numeric',
'required' => true,
),
array('name' => 'unix-agent.connection-timeout',
'descr' => 'Connection timeout',
'type' => 'numeric',
'required' => true,
),
array('name' => 'unix-agent.read-timeout',
'descr' => 'Read timeout',
'type' => 'numeric',
'required' => true,
),
);
$rrdtool_conf = array(
array('name' => 'rrdtool',
'descr' => 'Path to rrdtool binary',
'type' => 'text',
),
array('name' => 'rrdtool_tune',
'descr' => 'Tune all rrd port files to use max values',
'type' => 'checkbox',
),
array('name' => 'rrd.step',
'descr' => 'Change the rrd step value (default 300)',
'type' => 'numeric',
'required' => true,
),
array('name' => 'rrd.heartbeat',
'descr' => 'Change the rrd heartbeat value (default 600)',
'type' => 'numeric',
'required' => true,
),
);
$peeringdb_conf = array(
array('name' => 'peeringdb.enabled',
'descr' => 'Enable PeeringDB lookup (data is downloaded with daily.sh)',
'type' => 'checkbox',
),
);
echo '
<div class="panel-group" id="accordion">
<form class="form-horizontal" role="form" action="" method="post">
';
echo generate_dynamic_config_panel('Location Geocoding', $config_groups, $location_conf);
echo generate_dynamic_config_panel('Oxidized integration', $config_groups, $oxidized_conf);
echo generate_dynamic_config_panel('Unix-agent integration', $config_groups, $unixagent_conf);
echo generate_dynamic_config_panel('RRDTool Setup', $config_groups, $rrdtool_conf);
echo generate_dynamic_config_panel('PeeringDB Integration', $config_groups, $peeringdb_conf);
?>
</form>
</div>
<script>
$('#geoloc\\.engine').change(function () {
var engine = this.value;
if (engine === 'openstreetmap') {
$('.geoloc_api_key').hide();
} else {
$('.geoloc_api_key').show();
}
}).change(); // trigger initially
</script>