2010-09-03 18:26:59 +00:00
|
|
|
#!/usr/bin/env php
|
2009-10-28 13:49:37 +00:00
|
|
|
<?php
|
2012-05-09 10:01:42 +00:00
|
|
|
/**
|
2019-07-18 13:36:02 +00:00
|
|
|
* poller.php
|
|
|
|
*
|
|
|
|
* -Description-
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2011-03-15 15:12:16 +00:00
|
|
|
*
|
2019-07-18 13:36:02 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-02-08 23:29:04 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2013-10-28 19:01:36 +00:00
|
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
2020-09-21 12:54:51 +00:00
|
|
|
*
|
2019-07-18 13:36:02 +00:00
|
|
|
* Modified 4/17/19
|
|
|
|
* @author Heath Barnhart <hbarnhart@kanren.net>
|
2011-03-15 15:12:16 +00:00
|
|
|
*/
|
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
|
|
|
$init_modules = ['polling', 'alerts', 'laravel'];
|
2016-11-21 20:12:59 +00:00
|
|
|
require __DIR__ . '/includes/init.php';
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
$options = getopt('h:rfpdvm:q');
|
2015-07-13 18:10:26 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
c_echo('%RWarning: poller.php is deprecated!%n Use %9lnms device:poll%n instead.' . PHP_EOL . PHP_EOL);
|
2015-07-13 18:10:26 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
if (empty($options['h'])) {
|
2011-03-27 10:21:19 +00:00
|
|
|
echo "-h <device id> | <device hostname wildcard> Poll single device\n";
|
2023-10-04 21:32:02 +00:00
|
|
|
echo "-h odd Poll odd numbered devices\n";
|
|
|
|
echo "-h even Poll even numbered devices\n";
|
2018-07-12 20:30:39 +00:00
|
|
|
echo "-h all Poll all devices\n\n";
|
2011-04-13 09:29:44 +00:00
|
|
|
echo "Debugging and testing options:\n";
|
2018-07-12 20:30:39 +00:00
|
|
|
echo "-r Do not create or update RRDs\n";
|
|
|
|
echo "-f Do not insert data into InfluxDB\n";
|
|
|
|
echo "-p Do not insert data into Prometheus\n";
|
|
|
|
echo "-d Enable debugging output\n";
|
|
|
|
echo "-v Enable verbose debugging output\n";
|
|
|
|
echo "-m Specify module(s) to be run. Comma separate modules, submodules may be added with /\n";
|
2023-10-04 21:32:02 +00:00
|
|
|
echo "-q Quiet, minimal output /\n";
|
2009-10-28 13:49:37 +00:00
|
|
|
echo "\n";
|
|
|
|
echo "No polling type specified!\n";
|
|
|
|
exit;
|
2011-03-27 10:21:19 +00:00
|
|
|
}
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
$arguments = [
|
|
|
|
'device spec' => $options['h'],
|
|
|
|
'--verbose' => isset($options['v']) ? 3 : (isset($options['d']) ? 2 : 1),
|
|
|
|
];
|
2017-04-22 13:10:15 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
if (isset($options['m'])) {
|
|
|
|
$arguments['--modules'] = $options['m'];
|
2010-08-21 12:54:42 +00:00
|
|
|
}
|
2010-06-23 19:17:06 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
if (isset($options['q'])) {
|
|
|
|
$arguments['--quiet'] = true;
|
2011-05-03 12:22:04 +00:00
|
|
|
}
|
2011-03-08 17:14:32 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
if (isset($options['r']) || isset($options['f']) || isset($options['p'])) {
|
|
|
|
$arguments['--no-data'] = true;
|
2016-11-23 06:57:19 +00:00
|
|
|
}
|
2010-11-24 11:32:53 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
$return = Artisan::call('device:poll', $arguments);
|
2018-06-30 11:19:49 +00:00
|
|
|
|
2023-10-04 21:32:02 +00:00
|
|
|
exit($return);
|