linux dot实用程序(使用xhprof)

时间:2010-05-28 15:23:38

标签: php linux profiling graphviz

我为php

安装了xhprof profiling扩展

除了callgraph.php文件外,一切都很好,它返回: failed to shell execute cmd=" dot -Tpng"

所以我检查了dot实用程序没有安装,所以我安装了它。

它似乎从命令行运行正常,所以我再次运行scritp,同样的错误: failed to shell execute cmd=" dot -Tpng"

xhprof文档说明: the callgraph image visualization ([View Callgraph]) feature relies on the presence of Graphviz "dot" utility in your path.

但我不明白我现在需要做什么,特别是“路径中的实用程序”部分

任何帮助表示感谢,谢谢你们

6 个答案:

答案 0 :(得分:15)

如果你想在终端中使用xhprof run next命令的图形函数:

sudo apt-get install graphviz

答案 1 :(得分:2)

当我启用error_reporting时,我发现缺少一些配置变量:

function xhprof_generate_image_by_dot($dot_script, $type) {
  // get config => yep really dirty - but unobstrusive
  global $_xhprof;

  $errorFile    = $_xhprof['dot_errfile'];
  $tmpDirectory = $_xhprof['dot_tempdir'];
  $dotBinary    = $_xhprof['dot_binary'];

将以下行添加到xhprof_lib / config.php之后,它可以正常工作

$_xhprof['dot_errfile'] = '/home/peniel/var/log/xhprof/error.log';
$_xhprof['dot_tempdir'] = '/home/peniel/var/log/xhprof';
$_xhprof['dot_binary'] = '/usr/bin/dot';

答案 2 :(得分:2)

如果您已安装 graphviz ,则由于安全限制,此错误也会发生。某些功能可能被禁用。因此,请参阅日志以获取一些php警告。

例如:

PHP Warning:  proc_open() has been disabled for security reasons in /usr/share/php/xhprof_lib/utils/callgraph_utils.php on line 112

您需要配置 php.ini security.ini 参数" disable_functions "。

答案 3 :(得分:0)

将实用程序“放在路径中”意味着可以通过环境变量PATH找到它。此环境变量包含shell查找在没有显式路径的情况下运行的二进制文件的目录。

我们说dot的完整路径是/opt/foo/bin/dot。然后,您希望以这种方式修改PATH环境变量:

PATH=${PATH}:/opt/foo/bin

答案 4 :(得分:0)

在我的情况下,这只是因为没有安装graphviz造成的。您可以在命令行上查看which dotlocate graphviz

答案 5 :(得分:0)

如果您有Graphviz并仍然收到错误,请快速解决问题的步骤:

  1. 跑“哪个点”
  2.   

    的/ usr / local / bin中/点

    1. 打开xhprof_lib / utils / callgraph_utils.php第110行
    2. 将“dot”替换为“/ usr / local / bin / dot”(或您拥有的路径)