【问题标题】:linux dot utility (with xhprof)linux dot 实用程序(带有 xhprof)
【发布时间】:2011-02-25 04:38:23
【问题描述】:

我为 php 安装了 xhprof 分析扩展

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

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

它似乎从命令行运行良好,所以我再次运行脚本,同样的错误: 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.

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

感谢大家的帮助,谢谢

【问题讨论】:

    标签: php linux profiling graphviz


    【解决方案1】:

    如果您想要 xhprof 的图形功能,请在终端中运行下一个命令:

    sudo apt-get install graphviz
    

    【讨论】:

    • 也可用于使用自制软件的 Mac:brew install graphviz。像魅力一样工作!
    【解决方案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';
    

    【讨论】:

      【解决方案3】:

      如果你安装了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.inisecurity.ini参数“disable_functions”。

      【讨论】:

        【解决方案4】:

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

        假设dot 的完整路径是/opt/foo/bin/dot。然后你想用这种方式修改你的PATH 环境变量:

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

        【讨论】:

        • 我按照你说的添加了 PATH=${PATH}:/usr/bin/dot 相同的错误(我也应该说它来自网络浏览器)
        • @mononym - 您需要为您的 Web 服务器设置 PATH。
        【解决方案5】:

        在我的情况下,这仅仅是因为未安装 graphviz。您可以在命令行中使用which dotlocate graphviz 进行检查。

        【讨论】:

          【解决方案6】:

          如果您有 Graphviz 并且仍然出现错误,快速解决问题的步骤:

          1. 运行“哪个点”

          /usr/local/bin/点

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

          【讨论】:

            猜你喜欢
            • 2015-07-31
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-09-08
            相关资源
            最近更新 更多