Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make command string shorter for exec #217

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make command string shorter for exec
When we have too many hosts, given command string becomes so long that
'exec' function cannot handle it properly. It's a little bit inefficient
but works correctly even if you have many(>1000) hosts, especially for
stacked grapher.
dgoon committed Nov 19, 2013
commit 19db9360fba74edb2e26845daac18bcc5f3179b5
9 changes: 8 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
@@ -1383,8 +1383,15 @@ function heuristic_urldecode($blob) {
// alternative passthru() implementation to avoid incomplete images shown in
// browsers.
function my_passthru($command) {
// "exec" cannot handle very long command strings
$cmdf = tempnam('/tmp', 'ganglia-graph-cmd.');
$cmdfp = fopen($cmdf, 'wb');
fwrite($cmdfp, $command);
fclose($cmdfp);
$cmd = "/bin/bash $cmdf";
$tf = tempnam('/tmp', 'ganglia-graph.');
$ret = exec("$command > $tf");
$ret = exec("$cmd > $tf");
unlink($cmdf);
$size = filesize($tf);
header("Content-Length: $size");
$fp = fopen($tf, 'rb');