#!/usr/bin/env php 0) { $notification['notification_list']['id'] = $notify; $notification['notification_list']['reply_to'] = $reply_to; $notification['notification_list']['from'] = $from; } $queued[] = reports_queue($name, 1, 'reports', $id, $command, $notification); } } $number_sent = cacti_sizeof($queued); if (cacti_sizeof($queued)) { foreach ($queued as $qid) { reports_run($qid); } } // record the end time $end = microtime(true); // log statistics $reports_stats = sprintf('Time:%01.4f Reports:%s', $end - $start, $number_sent); reports_log('REPORTS STATS: ' . $reports_stats, true, 'REPORTS', POLLER_VERBOSITY_LOW); db_execute_prepared('REPLACE INTO settings (name, value) VALUES ("stats_reports", ?)', [$reports_stats]); } if (!$force) { unregister_process('reports', 'master', 0); } } else { $timeout = intval(read_config_option('scheduler_timeout')); if (empty($timeout)) { $timeout = 300; } if (!register_process_start('reports', 'child', $report_id, $timeout)) { exit(0); } $report = db_fetch_row_prepared('SELECT * FROM reports WHERE id = ?', [$report_id]); if (cacti_sizeof($report)) { reports_log('Reports processing report: ' . $report['name'], true, 'REPORTS'); $current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', [$report['user_id']]); if (isset($report['email'])) { db_execute_prepared('UPDATE reports SET last_started = ? WHERE id = ?', [date('Y-m-d H:i:s'), $report['id']]); generate_report($queue_id, $report, false); } } unregister_process('reports', 'child', $report_id); } exit(0); /** * sig_handler - provides a generic means to catch exceptions to the Cacti log. * * @param int $signo the signal that was thrown by the interface. * * @return void */ function sig_handler(int $signo) : void { switch ($signo) { case SIGTERM: case SIGINT: reports_log('WARNING: Reports Poller terminated by user', false, 'REPORTS TRACE', POLLER_VERBOSITY_LOW); exit(1); default: // ignore all other signals } } /** * display_version - displays version information */ function display_version() : void { $version = get_cacti_cli_version(); print "Cacti Reporting Poller, Version $version, " . COPYRIGHT_YEARS . "\n"; } /** * display_help - generic help screen for utilities */ function display_help() : void { display_version(); print "\nusage: poller_reports.php [--force] [--debug]\n\n"; print "Cacti's graphical reporting poller. This poller will create and distribute\n"; print "email reports to recipients based upon the schedules for those reports.\n\n"; print "Optional:\n"; print " --force - Force all Reports to be sent\n"; print " --debug - Display verbose output during execution\n\n"; }