ORDER BY `device_id` ASC ) temp WHERE MOD(temp.rownum, ' . $options['i'] . ') = ?;'; $doing = $options['n'] . "/" . $options['i']; $params[] = $options['n']; //print_vars($query); //print_vars($params); } if (!$where) { print_message("%n\nUSAGE:\n{$scriptname} [-drqV] [-i instances] [-n number] [-m module] [-h device]\n\nEXAMPLE:\n-h <device id> | <device hostname wildcard> Poll single device\n-h odd Poll odd numbered devices (same as -i 2 -n 0)\n-h even Poll even numbered devices (same as -i 2 -n 1)\n-h all Poll all devices\n-h new Poll all devices that have not had a discovery run before\n\n-i <instances> -n <id/number> Poll as instance <id/number> of <instances>\n Instance numbers start at 0. 0-3 for -i 4\n Example:\n -i 4 -n 0\n -i 4 -n 1\n -i 4 -n 2\n -i 4 -n 3\n\nOPTIONS:\n -h Device hostname, id or key odd/even/all/new.\n -i Poll instances count.\n -n Instance id (number), must start from 0 and to be less than instances count.\n -q Quiet output.\n -M Show globally enabled/disabled modules and exit.\n -V Show version and exit.\n\nDEBUGGING OPTIONS:\n -r Do not create or update RRDs\n -d Enable debugging output.\n -dd More verbose debugging output.\n -m Specify module(s) (separated by commas) to be run.\n\n%rInvalid arguments!%n", 'color', FALSE); exit; } if (isset($options['r'])) { $config['norrd'] = TRUE; } $cache['maint'] = cache_alert_maintenance(); rrdtool_pipe_open($rrd_process, $rrd_pipes); print_cli_heading("%WStarting polling run at " . date("Y-m-d H:i:s"), 0); $polled_devices = 0; if (!isset($query)) { $query = "SELECT `device_id` FROM `devices` WHERE `disabled` = 0 {$where} ORDER BY `device_id` ASC"; } foreach (dbFetch($query, $params) as $device) { $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); poll_device($device, $options); $polled_devices++; } $poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5); if ($polled_devices) {
} else { // No FIFO configured, take logs from stdin #echo 'Opening STDIN'.PHP_EOL; //No any echo to STDOUT/STDERR! $s = fopen('php://stdin', 'r'); } while ($line = fgets($s)) { if (isset($config['syslog']['debug']) && $config['syslog']['debug']) { // Store RAW syslog line into debug.log logfile('debug.log', $line); } // Update syslog ruleset if they've changed. (this query should be cheap). $new_rules = get_obs_attrib('syslog_rules_changed'); if ($new_rules > $cur_rules) { $cur_rules = $new_rules; $rules = cache_syslog_rules(); $device_rules = cache_syslog_rules_assoc(); $maint = cache_alert_maintenance(); // logfile('debug.log', "Rules updated: ".$new_rules); } // host || facility || priority || level || tag || timestamp || msg || program $entry = array(); // Init!!! list($entry['host'], $entry['facility'], $entry['priority'], $entry['level'], $entry['tag'], $entry['timestamp'], $entry['msg'], $entry['program']) = explode("||", trim($line)); process_syslog($entry, 1); unset($entry, $line); $i++; if ($i > 10) { $i = 1; } } // EOF