function sig_handler($signo) { switch ($signo) { case SIGTERM: case SIGINT: cacti_log('WARNING: Cacti Poller process terminated by user', true); /* record the process as having completed */ record_cmdphp_done(); exit; break; default: /* ignore all other signals */ } }
} } /* Next Cache Item */ } /* End foreach */ if ($using_proc_function == true && $script_server_calls > 0) { // close php server process fwrite($pipes[0], "quit\r\n"); fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); $return_value = proc_close($cactiphp); } if ($print_data_to_stdout || read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM) { /* take time and log performance data */ list($micro, $seconds) = split(" ", microtime()); $end = $seconds + $micro; cacti_log(sprintf("Time: %01.4f s, " . "Theads: N/A, " . "Hosts: %s", round($end - $start, 4), $host_count), $print_data_to_stdout); } } else { if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) { cacti_log("NOTE: There are no items in your poller for this polling cycle!", TRUE, "POLLER"); } } /* record the process as having completed */ record_cmdphp_done(); function record_cmdphp_done() { /* let the poller server know about cmd.php being finished */ db_execute("insert into poller_time (poller_id, start_time, end_time) values (0, NOW(), NOW())"); }
round($end-$start,4), $device_count),$print_data_to_stdout); }else{ cacti_log(sprintf("Time: %01.4f s, " . "Theads: N/A, " . "Hosts: %s", round($end-$start,4), $device_count),$print_data_to_stdout); } } }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) { cacti_log("NOTE: There are no items in your poller for this polling cycle!", TRUE, "POLLER"); } /* record the process as having completed */ record_cmdphp_done($poller_id); function record_cmdphp_done($poller_id) { global $start; /* let the poller server know about cmd.php being finished */ db_execute("INSERT INTO poller_time (pid, poller_id, start_time, end_time) values (" . getmypid() . ", $poller_id, '$start', NOW())"); } function display_help() { echo "Cacti cmd.php Data Collector, Copyright 2007-2010 - The Cacti Group\n\n"; echo "The slower, yet easier to use Data Collector for Cacti\n\n"; echo "usage: cmd.php [--poller=n] [--first=n] [--last=n]\n\n"; echo "Optional:\n"; echo " --poller=n 0, Defines which Cacti poller will be handles the polling of this device.\n"; echo " --first=n 0, Defines the first device for this Data Collector to be polled.\n";