fix for early reads from RRDTool pipe

git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@2086 860744bd-22fc-0310-8c96-e9fe5004b5ca
This commit is contained in:
Larry Adams committed 2004-09-20 23:00:35 +00:00
1 parent 5118ced519
commit 4ba70d2708
1 file changed
+19 -7
+19 -7
View File
@@ -42,8 +42,8 @@ function rrd_init() {
$rrd_struc["fd"] = proc_open(read_config_option("path_rrdtool") . " -", $rrd_des, $rrd_pipes);
$rrd_struc["pipes"] = $rrd_pipes;
stream_set_blocking($rrd_struc["pipes"][RRDTOOL_PIPE_CHILD_READ], false);
stream_set_blocking($rrd_struc["pipes"][RRDTOOL_PIPE_CHILD_WRITE], false);
stream_set_blocking($rrd_struc["pipes"][RRDTOOL_PIPE_CHILD_READ], true);
stream_set_blocking($rrd_struc["pipes"][RRDTOOL_PIPE_CHILD_WRITE], true);
}else {
$rrd_struc["fd"] = popen(read_config_option("path_rrdtool") . " -", "w");
}
@@ -133,7 +133,7 @@ function rrdtool_execute($command_line, $log_to_stdout, $output_flag, $rrd_struc
}
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
cacti_log("RRD2CACTI: " . strip_newlines($line), false);
cacti_log("RRD2CACTI: " . strip_newlines($line), false, "POLLER");
}
return $line;
@@ -143,13 +143,25 @@ function rrdtool_execute($command_line, $log_to_stdout, $output_flag, $rrd_struc
$fp = rrd_get_fd($rrd_struc, RRDTOOL_PIPE_CHILD_WRITE);
}
$line = fgets($fp, 4096);
/* Prepare the read array */
$read_fd = array($fp);
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
cacti_log("RRD2CACTI: " . strip_newlines($line), $log_to_stdout);
if (false === ($num_changed_streams = stream_select($read_fd, $write_fd = NULL, $except_fd = NULL, 2, 0))) {
/* Error handling */
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
cacti_log("RRD2CACTI: ERROR: RRD Did not Respond to RRDTool Command", $log_to_stdout, "POLLER");
}
} elseif ($num_changed_streams > 0) {
/* At least on one of the streams something interesting happened */
$line = fgets($fp, 4096);
if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
cacti_log("RRD2CACTI: " . strip_newlines($line), $log_to_stdout, "POLLER");
}
return $line;
}
return $line;
}
break;