Esempio n. 1
0
							$output = exec_poll($index_item["arg1"]);
							break;
						}

						/* assert the result with the expected value in the db; recache if the assert fails */
						if (($index_item["op"] == "=") && ($index_item["assert_value"] != trim($output))) {
							cacti_log("ASSERT: '" . $index_item["assert_value"] . "=" . trim($output) . "' failed. Recaching host '" . $item["hostname"] . "', data query #" . $index_item["data_query_id"], $print_data_to_stdout);
							db_replace("poller_command", array("poller_id"=>0, "time"=>sql_function_timestamp(), "action"=>POLLER_COMMAND_REINDEX, "command"=>$item["host_id"] . ":" . $index_item["data_query_id"]), array("poller_id", "action", "command"), true);
							$assert_fail = true;
						}else if (($index_item["op"] == ">") && ($index_item["assert_value"] < trim($output))) {
							cacti_log("ASSERT: '" . $index_item["assert_value"] . ">" . trim($output) . "' failed. Recaching host '" . $item["hostname"] . "', data query #" . $index_item["data_query_id"], $print_data_to_stdout);
							db_replace("poller_command", array("poller_id"=>0, "time"=>sql_function_timestamp(), "action"=>POLLER_COMMAND_REINDEX, "command"=>$item["host_id"] . ":" . $index_item["data_query_id"]), array("poller_id", "action", "command"), true);
							$assert_fail = true;
						}else if (($index_item["op"] == "<") && ($index_item["assert_value"] > trim($output))) {
							cacti_log("ASSERT: '" . $index_item["assert_value"] . "<" . trim($output) . "' failed. Recaching host '" . $item["hostname"] . "', data query #" . $index_item["data_query_id"], $print_data_to_stdout);
							db_replace("poller_command", array("poller_id"=>0, "time"=>sql_function_timestamp(), "action"=>POLLER_COMMAND_REINDEX, "command"=>$item["host_id"] . ":" . $index_item["data_query_id"]), array("poller_id", "action", "command"), true);
							$assert_fail = true;
						}

						/* update 'poller_reindex' with the correct information if:
						 * 1) the assert fails
						 * 2) the OP code is > or < meaning the current value could have changed without causing
						 *     the assert to fail */
						if (($assert_fail == true) || ($index_item["op"] == ">") || ($index_item["op"] == "<")) {
							db_execute("update poller_reindex set assert_value='$output' where host_id='$host_id' and data_query_id='" . $index_item["data_query_id"] . "' and arg1='" . $index_item["arg1"] . "'");

							/* spike kill logic */
							if (($assert_fail) &&
								(($index_item["op"] == "<") || ($index_item["arg1"] == ".1.3.6.1.2.1.1.3.0"))) {
								/* don't spike kill unless we are certain */
								if (!empty($output)) {
Esempio n. 2
0
				$process_file_number++;
			} /* end change_files */
		} /* end for each */

		if ($host_count > 1) {
			$last_host = $item["id"];

			exec_background($command_string, "$extra_args $first_host $last_host");
			usleep(100000);

			$process_file_number++;
		}

		/* insert the current date/time for graphs */
		db_replace("settings",array("name"=>"date","value"=>sql_function_timestamp()),"name", true);

		if ($poller == "1") {
			$max_threads = "N/A";
		}

		/* open a pipe to rrdtool for writing */
		$rrdtool_pipe = rrd_init();

		$rrds_processed = 0;
		while (1) {
			$polling_items = db_fetch_assoc("select poller_id,end_time from poller_time where poller_id=0");

			if (sizeof($polling_items) >= $process_file_number) {
				$rrds_processed = $rrds_processed + process_poller_output($rrdtool_pipe, TRUE);