From e0444bffcfbea0b548e069261e11656ddd99388e Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 4 Oct 2023 16:32:02 -0500 Subject: [PATCH] Deprecate poller.php (#15370) * Deprecate poller.php * Apply fixes from StyleCI * Remove references to poller.php Leave wrapper... * fix python style * update wraper to call lnms device:poll * Quiet output too * make pb happy --------- Co-authored-by: StyleCI Bot --- .github/ISSUE_TEMPLATE/device_bug.yml | 26 +-- LibreNMS/queuemanager.py | 8 +- LibreNMS/wrapper.py | 10 +- app/Console/Commands/FindWarnings.php | 96 ----------- doc/Developing/Getting-Started.md | 2 +- doc/Developing/os/Initial-Detection.md | 2 +- doc/Support/FAQ.md | 2 +- doc/Support/Poller Support.md | 64 +++----- includes/html/output/capture.inc.php | 2 +- includes/polling/functions.inc.php | 217 ------------------------- poller.php | 132 ++------------- routes/console.php | 22 --- 12 files changed, 73 insertions(+), 510 deletions(-) delete mode 100644 app/Console/Commands/FindWarnings.php diff --git a/.github/ISSUE_TEMPLATE/device_bug.yml b/.github/ISSUE_TEMPLATE/device_bug.yml index 6c8b6bf798..91b3946dd8 100644 --- a/.github/ISSUE_TEMPLATE/device_bug.yml +++ b/.github/ISSUE_TEMPLATE/device_bug.yml @@ -6,9 +6,9 @@ body: value: | This issue form is for reporting device ***_BUGS_*** only! - * [Add Device request here](https://community.librenms.org/c/device-requests/12) + * [Add Device request here](https://community.librenms.org/c/device-requests/12) * [I have a question or need support](https://www.librenms.org/#support) - + - type: textarea validations: required: true @@ -23,53 +23,53 @@ body: attributes: value: | ## Environment - + - type: textarea validations: - required: true + required: true attributes: label: Output of ./validate.php description: | Please post the output of running: /opt/librenms/validate.php render: txt - + - type: input attributes: label: What was the last working version of LibreNMS? placeholder: 21.7.0 description: > If known, otherwise leave blank. - + - type: input validations: - required: true + required: true attributes: label: Device info placeholder: Juniper SRX1500 description: > The Brand and model of the device - + - type: markdown attributes: value: | # Details - + - type: textarea validations: - required: true + required: true attributes: label: Discovery output description: | Paste the result of: ./discovery.php -d -h HOSTNAME render: txt - + - type: textarea validations: - required: true + required: true attributes: label: Poller output description: | Paste the result of: - ./poller.php -r -f -p -d -h HOSTNAME + lnms device:poll HOSTNAME -vv --no-data render: txt diff --git a/LibreNMS/queuemanager.py b/LibreNMS/queuemanager.py index 68caefde8c..7a7b85d207 100644 --- a/LibreNMS/queuemanager.py +++ b/LibreNMS/queuemanager.py @@ -539,8 +539,12 @@ class PollerQueueManager(QueueManager): if self.lock(device_id, timeout=self.config.poller.frequency): logger.info("Polling device {}".format(device_id)) - args = ("-d", "-h", device_id) if self.config.debug else ("-h", device_id) - exit_code, output = LibreNMS.call_script("poller.php", args) + args = ( + ("device:poll", device_id, "-vv") + if self.config.debug + else ("device:poll", device_id, "-q") + ) + exit_code, output = LibreNMS.call_script("lnms", args) if self.config.log_output: with open( diff --git a/LibreNMS/wrapper.py b/LibreNMS/wrapper.py index 9c7bbecb0c..439c5be1be 100644 --- a/LibreNMS/wrapper.py +++ b/LibreNMS/wrapper.py @@ -55,7 +55,6 @@ import LibreNMS from LibreNMS.command_runner import command_runner from LibreNMS.config import DBConfig - logger = logging.getLogger(__name__) # Timeout in seconds for any poller / service / discovery action per device @@ -86,6 +85,7 @@ All time related variables are in seconds wrappers = { "service": { "executable": "check-services.php", + "option": "-h", "table_name": "services", "memc_touch_time": 10, "stepping": 300, @@ -94,6 +94,7 @@ wrappers = { }, "discovery": { "executable": "discovery.php", + "option": "-h", "table_name": "devices", "memc_touch_time": 30, "stepping": 300, @@ -101,7 +102,8 @@ wrappers = { "total_exec_time": 21600, }, "poller": { - "executable": "poller.php", + "executable": "lnms", + "option": "device:poll -q", "table_name": "devices", "memc_touch_time": 10, "stepping": 300, @@ -280,7 +282,9 @@ def poll_worker( os.path.dirname(os.path.dirname(os.path.realpath(__file__))), wrappers[wrapper_type]["executable"], ) - command = "/usr/bin/env php {} -h {}".format(executable, device_id) + command = "/usr/bin/env php {} {} {}".format( + executable, wrappers[wrapper_type]["option"], device_id + ) if modules is not None and len(str(modules).strip()): module_str = re.sub("\s", "", str(modules).strip()) command = command + " -m {}".format(module_str) diff --git a/app/Console/Commands/FindWarnings.php b/app/Console/Commands/FindWarnings.php deleted file mode 100644 index 6930d8bc48..0000000000 --- a/app/Console/Commands/FindWarnings.php +++ /dev/null @@ -1,96 +0,0 @@ -argument('regex') ?: '/./'; - $modules = 'core,isis,mempools,mpls,nac,netstats,os,printer-supplies,slas'; - - foreach (glob(base_path('tests/snmpsim/*.snmprec')) as $file) { - if ($this->found) { - break; - } - - $community = basename($file, '.snmprec'); - if (preg_match($regex, $community)) { - $this->addDevice($community); - $this->info($community); - - $process = new Process(['./discovery.php', '-d', '-h', 'snmpsim', '-m', $modules]); - $process->run([$this, 'find']); - - $process = new Process(['./poller.php', '-d', '-h', 'snmpsim', '-m', $modules]); - $process->run([$this, 'find']); - } - } - - return Command::SUCCESS; - } - - public function find(string $type, string $buffer): void - { - if (Str::contains($buffer, ['Warning:', 'Error:'])) { - preg_match_all('/^(Warning|\S*Error): .*$/', $buffer, $matches); - - $this->error(implode(PHP_EOL, $matches[0])); - $this->found = true; - } - } - - private function addDevice(string $community): void - { - $device = Device::firstOrNew(['hostname' => 'snmpsim']); - $device->overwrite_ip = '127.1.6.1'; - $device->port = 1161; - $device->snmpver = 'v2c'; - $device->transport = 'udp'; - $device->community = $community; - $device->last_discovered = null; - $device->status_reason = ''; - $device->save(); - } -} diff --git a/doc/Developing/Getting-Started.md b/doc/Developing/Getting-Started.md index e389572991..60592a7507 100644 --- a/doc/Developing/Getting-Started.md +++ b/doc/Developing/Getting-Started.md @@ -64,7 +64,7 @@ mode by adding a `-d` flag. ```bash ./discovery.php -d -h HOSTNAME -./poller.php -d -h HOSTNAME +lnms device:poll HOSTNAME -vv ``` ### Inspecting variables diff --git a/doc/Developing/os/Initial-Detection.md b/doc/Developing/os/Initial-Detection.md index daf499741c..991cea9c53 100644 --- a/doc/Developing/os/Initial-Detection.md +++ b/doc/Developing/os/Initial-Detection.md @@ -248,7 +248,7 @@ Discovery Polling ```bash -./poller.php -h HOSTNAME +lnms device:poll HOSTNAME ``` At this step we should see all the values retrieved in LibreNMS. diff --git a/doc/Support/FAQ.md b/doc/Support/FAQ.md index 0f7fe7170b..892502484f 100644 --- a/doc/Support/FAQ.md +++ b/doc/Support/FAQ.md @@ -490,7 +490,7 @@ COMMUNITY. Use `snmpwalk` instead of `snmpbulkwalk` for v1 devices. ```bash ./discovery.php -h HOSTNAME -d | ./pbin.sh -./poller.php -h HOSTNAME -r -f -d | ./pbin.sh +lnms device:poll HOSTNAME -vv | ./pbin.sh snmpbulkwalk -OUneb -v2c -c COMMUNITY HOSTNAME . | ./pbin.sh ``` diff --git a/doc/Support/Poller Support.md b/doc/Support/Poller Support.md index 16fa945c9f..153e13d2b7 100644 --- a/doc/Support/Poller Support.md +++ b/doc/Support/Poller Support.md @@ -1,46 +1,32 @@ -# poller.php +# lnms device:poll -This document will explain how to use poller.php to debug issues or +This document will explain how to use `lnms device:poll` to debug issues or manually running to process data. ## Command options ```bash - LibreNMS 2014.master Poller +Description: + Poll data from device(s) as defined by discovery --h | Poll single device --h odd Poll odd numbered devices (same as -i 2 -n 0) --h even Poll even numbered devices (same as -i 2 -n 1) --h all Poll all devices +Usage: + device:poll [options] [--] --i -n Poll as instance of - Instances start at 0. 0-3 for -n 4 +Arguments: + device spec Device spec to poll: device_id, hostname, wildcard (*), odd, even, all -Debugging and testing options: --r Do not create or update RRDs --f Do not insert data into InfluxDB --d Enable debugging output --v Enable verbose debugging output --m Specify module(s) to be run. Comma separate modules, submodules may be added with / +Options: + -m, --modules=MODULES Specify single module to be run. Comma separate modules, submodules may be added with / + -x, --no-data Do not update datastores (RRD, InfluxDB, etc) + -h, --help Display help for the given command. When no command is given display help for the list command + -q, --quiet Do not output any message + -V, --version Display this application version + --ansi|--no-ansi Force (or disable --no-ansi) ANSI output + -n, --no-interaction Do not ask any interactive question + --env[=ENV] The environment the command should run under + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug ``` -`-h` Use this to specify a device via either id or hostname (including -wildcard using *). You can also specify odd and even. all will run -poller against all devices. - -`-i` This can be used to stagger the poller process. - -`-r` This option will suppress the creation or update of RRD files. - -`-d` Enables debugging output (verbose output but with most sensitive -data masked) so that you can see what is happening during a poller -run. This includes things like rrd updates, SQL queries and response -from snmp. - -`-v` Enables verbose debugging output with all data in tact. - -`-m` This enables you to specify the module you want to run for poller. - ## Poller Wrapper We have a `poller-wrapper.py` script by [Job @@ -201,36 +187,36 @@ configured to be ignored by config options. Here are some examples of running poller from within your install directory. ```bash -./poller.php -h localhost +lnms device:poll localhost -./poller.php -h localhost -m ports +lnms device:poll localhost -m ports ``` ## Debugging To provide debugging output you will need to run the poller process -with the `-d` flag. You can do this either against +with the `-vv` flag. You can do this either against all modules, single or multiple modules: All Modules ```bash -./poller.php -h localhost -d +lnms device:poll localhost -vv ``` Single Module ```bash -./poller.php -h localhost -m ports -d +lnms device:poll localhost -m ports -vv ``` Multiple Modules ```bash -./poller.php -h localhost -m ports,entity-physical -d +lnms device:poll localhost -m ports,entity-physical -vv ``` -Using `-d` shouldn't output much sensitive information, `-v` will so +Using `-vv` shouldn't output much sensitive information, `-vvv` will so it is then advisable to sanitise the output before pasting it somewhere as the debug output will contain snmp details amongst other items including port descriptions. diff --git a/includes/html/output/capture.inc.php b/includes/html/output/capture.inc.php index 634566f0a3..b0fe653a57 100644 --- a/includes/html/output/capture.inc.php +++ b/includes/html/output/capture.inc.php @@ -32,7 +32,7 @@ $type = $_REQUEST['type']; switch ($type) { case 'poller': - $cmd = ['php', \LibreNMS\Config::get('install_dir') . '/poller.php', '-h', $hostname, '-r', '-f', '-d']; + $cmd = ['php', \LibreNMS\Config::get('install_dir') . '/lnms', 'device:poll', $hostname, '--no-data', '-vv']; $filename = "poller-$hostname.txt"; break; case 'snmpwalk': diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index b017e92e77..ade69957b7 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -1,8 +1,6 @@ getAttribs(); - - $os = \LibreNMS\OS::make($device); - - unset($array); - - // Start counting device poll time - echo 'Hostname: ' . $device['hostname'] . PHP_EOL; - echo 'Device ID: ' . $device['device_id'] . PHP_EOL; - echo 'OS: ' . $device['os'] . PHP_EOL; - - if (empty($device['overwrite_ip'])) { - $ip = dnslookup($device); - } else { - $ip = $device['overwrite_ip']; - } - - $db_ip = null; - if (! empty($ip)) { - if (empty($device['overwrite_ip'])) { - echo 'Resolved IP: ' . $ip . PHP_EOL; - } else { - echo 'Assigned IP: ' . $ip . PHP_EOL; - } - $db_ip = inet_pton($ip); - } - - if (! empty($db_ip) && inet6_ntop($db_ip) != inet6_ntop($device['ip'])) { - log_event('Device IP changed to ' . $ip, $device, 'system', 3); - dbUpdate(['ip' => $db_ip], 'devices', 'device_id=?', [$device['device_id']]); - } - - if ($os_group = Config::get("os.{$device['os']}.group")) { - $device['os_group'] = $os_group; - echo ' (' . $device['os_group'] . ')'; - } - - echo PHP_EOL . PHP_EOL; - - unset($poll_update); - unset($poll_update_query); - unset($poll_separator); - $poll_update_array = []; - $update_array = []; - - $host_rrd = Rrd::name($device['hostname'], '', ''); - if (Config::get('norrd') !== true && ! is_dir($host_rrd)) { - mkdir($host_rrd); - echo "Created directory : $host_rrd\n"; - } - - $helper = new \LibreNMS\Polling\ConnectivityHelper($deviceModel); - $helper->saveMetrics(); - - if ($helper->isUp()) { - if ($device['snmp_disable']) { - // only non-snmp modules - Config::set('poller_modules', array_intersect_key(Config::get('poller_modules'), [ - 'availability' => true, - 'ipmi' => true, - 'unix-agent' => true, - ])); - } - - // update $device array status - $device['status'] = $deviceModel->status; - $device['status_reason'] = $deviceModel->status_reason; - - /** @var \App\Polling\Measure\MeasurementManager $measurements */ - $measurements = app(\App\Polling\Measure\MeasurementManager::class); - $measurements->checkpoint(); // don't count previous stats - - foreach (Config::get('poller_modules') as $module => $module_status) { - if (! is_file("includes/polling/$module.inc.php")) { - echo "Module $module does not exist, please remove it from your configuration"; - - continue; - } - - $os_module_status = Config::get("os.{$device['os']}.poller_modules.$module"); - d_echo('Modules status: Global' . (isset($module_status) ? ($module_status ? '+ ' : '- ') : ' ')); - d_echo('OS' . (isset($os_module_status) ? ($os_module_status ? '+ ' : '- ') : ' ')); - d_echo('Device' . (isset($device['attribs']['poll_' . $module]) ? ($device['attribs']['poll_' . $module] ? '+ ' : '- ') : ' ')); - if ($force_module === true || - ! empty($device['attribs']['poll_' . $module]) || - ($os_module_status && ! isset($device['attribs']['poll_' . $module])) || - ($module_status && ! isset($os_module_status) && ! isset($device['attribs']['poll_' . $module]))) { - $start_memory = memory_get_usage(); - $module_start = microtime(true); - echo "\n#### Load poller module $module ####\n"; - - try { - include "includes/polling/$module.inc.php"; - } catch (Throwable $e) { - // isolate module exceptions so they don't disrupt the polling process - Log::error("%rError polling $module module for {$device['hostname']}.%n $e", ['color' => true]); - \App\Models\Eventlog::log("Error polling $module module. Check log file for more details.", $device['device_id'], 'poller', Severity::Error); - report($e); - - // Re-throw exception if we're in CI - if (getenv('CI') == true) { - throw $e; - } - } - - $module_time = microtime(true) - $module_start; - $module_mem = (memory_get_usage() - $start_memory); - printf("\n>> Runtime for poller module '%s': %.4f seconds with %s bytes\n", $module, $module_time, $module_mem); - $measurements->printChangedStats(); - echo "#### Unload poller module $module ####\n\n"; - - // save per-module poller stats - $tags = [ - 'module' => $module, - 'rrd_def' => RrdDefinition::make()->addDataset('poller', 'GAUGE', 0), - 'rrd_name' => ['poller-perf', $module], - ]; - $fields = [ - 'poller' => $module_time, - ]; - data_update($device, 'poller-perf', $tags, $fields); - $os->enableGraph('poller_perf'); - - // remove old rrd - $oldrrd = Rrd::name($device['hostname'], ['poller', $module, 'perf']); - if (is_file($oldrrd)) { - unlink($oldrrd); - } - unset($tags, $fields, $oldrrd); - } elseif (isset($device['attribs']['poll_' . $module]) && $device['attribs']['poll_' . $module] == '0') { - echo "Module [ $module ] disabled on host.\n\n"; - } elseif (isset($os_module_status) && $os_module_status == '0') { - echo "Module [ $module ] disabled on os.\n\n"; - } else { - echo "Module [ $module ] disabled globally.\n\n"; - } - } - - // Ping response - if ($helper->canPing()) { - $os->enableGraph('ping_perf'); - } - - $device_time = round(microtime(true) - $device_start, 3); - - // Poller performance - if (! empty($device_time)) { - $tags = [ - 'rrd_def' => RrdDefinition::make()->addDataset('poller', 'GAUGE', 0), - 'module' => 'ALL', - ]; - $fields = [ - 'poller' => $device_time, - ]; - - data_update($device, 'poller-perf', $tags, $fields); - $os->enableGraph('poller_modules_perf'); - } - - if (! $force_module) { - // don't update last_polled time if we are forcing a specific module to be polled - $update_array['last_polled'] = ['NOW()']; - $update_array['last_polled_timetaken'] = $device_time; - - echo 'Enabling graphs: '; - DeviceGraph::deleted(function ($graph) { - echo '-'; - }); - DeviceGraph::created(function ($graph) { - echo '+'; - }); - - $os->persistGraphs(); - echo PHP_EOL; - } - - $updated = false; - if (! empty($update_array)) { - $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', [$device['device_id']]); - } - if ($updated) { - d_echo('Updating ' . $device['hostname'] . PHP_EOL); - } - - echo "\nPolled in $device_time seconds\n"; - - // check if the poll took to long and log an event - if ($device_time > Config::get('rrd.step')) { - log_event('Polling took longer than ' . round(Config::get('rrd.step') / 60, 2) . - ' minutes! This will cause gaps in graphs.', $device, 'system', 5); - } - - unset($storage_cache); - // Clear cache of hrStorage ** MAYBE FIXME? ** - unset($cache); - // Clear cache (unify all things here?) - - return true; // device was polled - } - - return false; // device not polled -}//end poll_device() - /** * Update the application status and output in the database. * diff --git a/poller.php b/poller.php index f62d318a8f..9ffaed5a05 100755 --- a/poller.php +++ b/poller.php @@ -23,69 +23,18 @@ * Modified 4/17/19 * @author Heath Barnhart */ - -use App\Action; -use App\Actions\Device\UpdateDeviceGroupsAction; -use LibreNMS\Alert\AlertRules; -use LibreNMS\Config; -use LibreNMS\Data\Store\Datastore; -use LibreNMS\Util\Debug; - $init_modules = ['polling', 'alerts', 'laravel']; require __DIR__ . '/includes/init.php'; -$poller_start = microtime(true); -Log::setDefaultDriver('console'); -echo Config::get('project_name') . " Poller\n"; +$options = getopt('h:rfpdvm:q'); -$options = getopt('h:m:i:n:r::d::v::a::f::q'); +c_echo('%RWarning: poller.php is deprecated!%n Use %9lnms device:poll%n instead.' . PHP_EOL . PHP_EOL); -if (isset($options['h'])) { - if ($options['h'] == 'odd') { - $options['n'] = '1'; - $options['i'] = '2'; - } elseif ($options['h'] == 'even') { - $options['n'] = '0'; - $options['i'] = '2'; - } elseif ($options['h'] == 'all') { - $where = ' '; - $doing = 'all'; - } elseif ($options['h']) { - if (is_numeric($options['h'])) { - $where = 'AND `device_id` = ' . $options['h']; - $doing = $options['h']; - } else { - if (preg_match('/\*/', $options['h'])) { - $where = "AND `hostname` LIKE '" . str_replace('*', '%', $options['h']) . "'"; - } else { - $where = "AND `hostname` = '" . $options['h'] . "'"; - } - $doing = $options['h']; - } - } -} - -if (isset($options['i']) && $options['i'] && isset($options['n'])) { - $where = true; - // FIXME - $query = 'SELECT * FROM (SELECT @rownum :=0) r, - ( - SELECT @rownum := @rownum +1 AS rownum, `devices`.* - FROM `devices` - WHERE `disabled` = 0 - ORDER BY `device_id` ASC - ) temp - WHERE MOD(temp.rownum, ' . $options['i'] . ') = ' . $options['n'] . ';'; - $doing = $options['n'] . '/' . $options['i']; -} - -if (empty($where)) { +if (empty($options['h'])) { echo "-h | Poll single device\n"; - echo "-h odd Poll odd numbered devices (same as -i 2 -n 0)\n"; - echo "-h even Poll even numbered devices (same as -i 2 -n 1)\n"; + echo "-h odd Poll odd numbered devices\n"; + echo "-h even Poll even numbered devices\n"; echo "-h all Poll all devices\n\n"; - echo "-i -n Poll as instance of \n"; - echo " Instances start at 0. 0-3 for -n 4\n\n"; echo "Debugging and testing options:\n"; echo "-r Do not create or update RRDs\n"; echo "-f Do not insert data into InfluxDB\n"; @@ -93,74 +42,29 @@ if (empty($where)) { 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"; + echo "-q Quiet, minimal output /\n"; echo "\n"; echo "No polling type specified!\n"; exit; } -if (Debug::set(isset($options['d']), false) || isset($options['v'])) { - echo \LibreNMS\Util\Version::get()->header(); +$arguments = [ + 'device spec' => $options['h'], + '--verbose' => isset($options['v']) ? 3 : (isset($options['d']) ? 2 : 1), +]; - echo "DEBUG!\n"; - if (isset($options['v'])) { - Debug::setVerbose(); - } - \LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache +if (isset($options['m'])) { + $arguments['--modules'] = $options['m']; } -// If we've specified modules with -m, use them -$module_override = parse_modules('poller', $options); - -$datastore = Datastore::init($options); - -echo "Starting polling run:\n\n"; -$polled_devices = 0; -$unreachable_devices = 0; -if (! isset($query)) { - $query = "SELECT * FROM `devices` WHERE `disabled` = 0 $where ORDER BY `device_id` ASC"; +if (isset($options['q'])) { + $arguments['--quiet'] = true; } -foreach (dbFetch($query) as $device) { - DeviceCache::setPrimary($device['device_id']); - - if (! poll_device($device, $module_override)) { - $unreachable_devices++; - } - - // Update device_groups - echo "### Start Device Groups ###\n"; - $dg_start = microtime(true); - $group_changes = Action::execute(UpdateDeviceGroupsAction::class); - d_echo('Groups Added: ' . implode(',', $group_changes['attached']) . PHP_EOL); - d_echo('Groups Removed: ' . implode(',', $group_changes['detached']) . PHP_EOL); - echo '### End Device Groups, runtime: ' . round(microtime(true) - $dg_start, 4) . "s ### \n\n"; - - echo "#### Start Alerts ####\n"; - $rules = new AlertRules(); - $rules->runRules($device['device_id']); - echo "#### End Alerts ####\r\n"; - $polled_devices++; +if (isset($options['r']) || isset($options['f']) || isset($options['p'])) { + $arguments['--no-data'] = true; } -$poller_end = microtime(true); -$poller_run = ($poller_end - $poller_start); -$poller_time = substr($poller_run, 0, 5); +$return = Artisan::call('device:poll', $arguments); -$string = $argv[0] . " $doing " . date(Config::get('dateformat.compact')) . " - $polled_devices devices polled in $poller_time secs"; -d_echo("$string\n"); - -if (! isset($options['q'])) { - echo PHP_EOL; - app(\App\Polling\Measure\MeasurementManager::class)->printStats(); -} - -logfile($string); -Datastore::terminate(); -// Remove this for testing -// print_r(get_defined_vars()); - -if ($polled_devices === $unreachable_devices) { - exit(6); -} - -exit(0); +exit($return); diff --git a/routes/console.php b/routes/console.php index eb05849dae..e1cc1c6002 100644 --- a/routes/console.php +++ b/routes/console.php @@ -86,28 +86,6 @@ Artisan::command('poller:discovery (new Process($command))->setTimeout(null)->setIdleTimeout(null)->setTty(true)->run(); })->purpose(__('Discover information about existing devices, defines what will be polled')); -Artisan::command('poller:poll - {device spec : ' . __('Device spec to poll: device_id, hostname, wildcard, odd, even, all') . '} - {--m|modules= : ' . __('Specify single module to be run. Comma separate modules, submodules may be added with /') . '} - {--x|no-data : ' . __('Do not update datastores (RRD, InfluxDB, etc)') . '} -', function () { - $command = [base_path('poller.php'), '-h', $this->argument('device spec')]; - if ($this->option('no-data')) { - array_push($command, '-r', '-f', '-p'); - } - if ($this->option('modules')) { - $command[] = '-m'; - $command[] = $this->option('modules'); - } - if (($verbosity = $this->getOutput()->getVerbosity()) >= 128) { - $command[] = '-d'; - if ($verbosity >= 256) { - $command[] = '-v'; - } - } - (new Process($command))->setTimeout(null)->setIdleTimeout(null)->setTty(true)->run(); -})->purpose(__('Poll data from devices as defined by discovery')); - Artisan::command('poller:alerts', function () { $command = [base_path('alerts.php')]; if (($verbosity = $this->getOutput()->getVerbosity()) >= 128) {