mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Sometimes the output streams already contain output, so we don't get the output we expect.
Clear those output buffers, but only when we care about it.
This commit is contained in:
@@ -182,12 +182,20 @@ function rrdtool($command, $filename, $options, $timeout=0)
|
||||
print $console_color->convert('[%rRRD Disabled%n]');
|
||||
$output = array(null, null);
|
||||
} else {
|
||||
fwrite($rrd_pipes[0], $cmd."\n");
|
||||
|
||||
if($timeout > 0) {
|
||||
stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout);
|
||||
if ($timeout > 0) {
|
||||
// if we care about the output, indicated by the fact that we are waiting for it
|
||||
// remove any previous output before sending the command
|
||||
stream_get_contents($rrd_pipes[1]);
|
||||
stream_get_contents($rrd_pipes[2]);
|
||||
}
|
||||
$output = array(stream_get_contents($rrd_pipes[1]),stream_get_contents($rrd_pipes[2]));
|
||||
|
||||
fwrite($rrd_pipes[0], $cmd . "\n");
|
||||
|
||||
if ($timeout > 0) {
|
||||
// this causes us to block until we receive output for up to $timeout seconds
|
||||
stream_select($r = $rrd_pipes, $w = null, $x = null, $timeout);
|
||||
}
|
||||
$output = array(stream_get_contents($rrd_pipes[1]), stream_get_contents($rrd_pipes[2]));
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
|
Reference in New Issue
Block a user