Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2010-09-03 18:26:59 +00:00
#!/usr/bin/env php
2009-10-28 13:49:37 +00:00
<?php
/**
* 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.
*
* 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-09 00:29:04 +01:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @copyright (C) 2006 - 2012 Adam Armstrong
2020-09-21 14:54:51 +02:00
*
* Modified 4/17/19
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
$init_modules = ['polling', 'alerts', 'laravel'];
require __DIR__ . '/includes/init.php';
2009-10-28 13:49:37 +00:00
2023-10-04 16:32:02 -05:00
$options = getopt('h:rfpdvm:q');
2015-07-13 20:10:26 +02:00
2023-10-04 16:32:02 -05:00
c_echo('%RWarning: poller.php is deprecated!%n Use %9lnms device:poll%n instead.' . PHP_EOL . PHP_EOL);
2015-07-13 20:10:26 +02:00
2023-10-04 16:32:02 -05:00
if (empty($options['h'])) {
echo "-h <device id> | <device hostname wildcard> Poll single device\n";
2023-10-04 16:32:02 -05:00
echo "-h odd Poll odd numbered devices\n";
echo "-h even Poll even numbered devices\n";
echo "-h all Poll all devices\n\n";
2011-04-13 09:29:44 +00:00
echo "Debugging and testing options:\n";
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 16:32:02 -05:00
echo "-q Quiet, minimal output /\n";
2009-10-28 13:49:37 +00:00
echo "\n";
echo "No polling type specified!\n";
exit;
}
2009-10-28 13:49:37 +00:00
2023-10-04 16:32:02 -05:00
$arguments = [
'device spec' => $options['h'],
'--verbose' => isset($options['v']) ? 3 : (isset($options['d']) ? 2 : 1),
];
2023-10-04 16:32:02 -05:00
if (isset($options['m'])) {
$arguments['--modules'] = $options['m'];
2010-08-21 12:54:42 +00:00
}
2023-10-04 16:32:02 -05:00
if (isset($options['q'])) {
$arguments['--quiet'] = true;
}
2023-10-04 16:32:02 -05:00
if (isset($options['r']) || isset($options['f']) || isset($options['p'])) {
$arguments['--no-data'] = true;
}
2010-11-24 11:32:53 +00:00
2023-10-04 16:32:02 -05:00
$return = Artisan::call('device:poll', $arguments);
2023-10-04 16:32:02 -05:00
exit($return);