ℹ️ Your data is safe here... unless you make the SNIP gods angry. And let's just say they have a really bad sense of humor.

From Dziadziumil, 6 Months ago, written in Plain Text.
Embed
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4.  * poller.php
  5.  *
  6.  * -Description-
  7.  *
  8.  * This program is free software: you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation, either version 3 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program.  If not, see <https>.
  20.  *
  21.  * @copyright  (C) 2006 - 2012 Adam Armstrong
  22.  *
  23.  * Modified 4/17/19
  24.  * @author Heath Barnhart <hbarnhart>
  25.  */
  26. $init_modules = ['polling', 'alerts', 'laravel'];
  27. require __DIR__ . '/includes/init.php';
  28.  
  29. $options = getopt('h:rfpdvm:q');
  30.  
  31. c_echo('%RWarning: poller.php is deprecated!%n Use %9lnms device:poll%n instead.' . PHP_EOL . PHP_EOL);
  32.  
  33. if (empty($options['h'])) {
  34.     echo "-h <device> | <device>  Poll single device\n";
  35.     echo "-h odd             Poll odd numbered devices\n";
  36.     echo "-h even            Poll even numbered devices\n";
  37.     echo "-h all             Poll all devices\n\n";
  38.     echo "Debugging and testing options:\n";
  39.     echo "-r                 Do not create or update RRDs\n";
  40.     echo "-f                 Do not insert data into InfluxDB\n";
  41.     echo "-p                 Do not insert data into Prometheus\n";
  42.     echo "-d                 Enable debugging output\n";
  43.     echo "-v                 Enable verbose debugging output\n";
  44.     echo "-m                 Specify module(s) to be run. Comma separate modules, submodules may be added with /\n";
  45.     echo "-q                 Quiet, minimal output /\n";
  46.     echo "\n";
  47.     echo "No polling type specified!\n";
  48.     exit;
  49. }
  50.  
  51. $arguments = [
  52.     'device spec' => $options['h'],
  53.     '--verbose' => isset($options['v']) ? 3 : (isset($options['d']) ? 2 : 1),
  54. ];
  55.  
  56. if (isset($options['m'])) {
  57.     $arguments['--modules'] = $options['m'];
  58. }
  59.  
  60. if (isset($options['q'])) {
  61.     $arguments['--quiet'] = true;
  62. }
  63.  
  64. if (isset($options['r']) || isset($options['f']) || isset($options['p'])) {
  65.     $arguments['--no-data'] = true;
  66. }
  67.  
  68. $return = Artisan::call('device:poll', $arguments);
captcha