apache.html
来自「perl教程」· HTML 代码 · 共 160 行
HTML
160 行
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../../displayToc.js"></script>
<script language="JavaScript" src="../../../tocParas.js"></script>
<script language="JavaScript" src="../../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../../scineplex.css">
<title>DBI::ProfileDumper::Apache - capture DBI profiling data from Apache/mod_perl</title>
<link rel="stylesheet" href="../../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',3);</script>
<h1><a>DBI::ProfileDumper::Apache - capture DBI profiling data from Apache/mod_perl</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#usage">USAGE</a></li>
<ul>
<li><a href="#loading_the_module">LOADING THE MODULE</a></li>
<li><a href="#gathering_profile_data">GATHERING PROFILE DATA</a></li>
<li><a href="#cleaning_up">CLEANING UP</a></li>
</ul>
<li><a href="#memory_usage">MEMORY USAGE</a></li>
<li><a href="#author">AUTHOR</a></li>
<li><a href="#copyright_and_license">COPYRIGHT AND LICENSE</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>DBI::ProfileDumper::Apache - capture DBI profiling data from Apache/mod_perl</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<p>Add this line to your <em>httpd.conf</em>:</p>
<pre>
PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache</pre>
<p>Under mod_perl2 RC5+ you'll need to also add:</p>
<pre>
PerlSetEnv DBI_PROFILE_APACHE_LOG_DIR /server_root/logs</pre>
<p>OR add</p>
<pre>
PerlOptions +GlobalRequest</pre>
<p>to the gobal config section you're about test with DBI::ProfileDumper::Apache.
If you don't do this, you'll see messages in your error_log similar to:</p>
<pre>
DBI::ProfileDumper::Apache on_destroy failed: Global $r object is not available. Set:
PerlOptions +GlobalRequest in httpd.conf at ..../DBI/ProfileDumper/Apache.pm line 144</pre>
<p>Then restart your server. Access the code you wish to test using a
web browser, then shutdown your server. This will create a set of
<em>dbi.prof.*</em> files in your Apache log directory. Get a profiling
report with <a href="../../../bin/dbiprof.html">dbiprof</a>:</p>
<pre>
dbiprof /usr/local/apache/logs/dbi.prof.*</pre>
<p>When you're ready to perform another profiling run, delete the old
files</p>
<pre>
rm /usr/local/apache/logs/dbi.prof.*</pre>
<p>and start again.</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module interfaces DBI::ProfileDumper to Apache/mod_perl. Using
this module you can collect profiling data from mod_perl applications.
It works by creating a DBI::ProfileDumper data file for each Apache
process. These files are created in your Apache log directory. You
can then use dbiprof to analyze the profile files.</p>
<p>
</p>
<hr />
<h1><a name="usage">USAGE</a></h1>
<p>
</p>
<h2><a name="loading_the_module">LOADING THE MODULE</a></h2>
<p>The easiest way to use this module is just to set the DBI_PROFILE
environment variable in your <em>httpd.conf</em>:</p>
<pre>
PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache</pre>
<p>If you want to use one of DBI::Profile's other Path settings, you can
use a string like:</p>
<pre>
PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache</pre>
<p>It's also possible to use this module by setting the Profile attribute
of any DBI handle:</p>
<pre>
<span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">Profile</span><span class="operator">}</span> <span class="operator">=</span> <span class="string">"2/DBI::ProfileDumper::Apache"</span><span class="operator">;</span>
</pre>
<p>See <a href="../../../lib/DBI/ProfileDumper.html">the DBI::ProfileDumper manpage</a> for more possibilities.</p>
<p>
</p>
<h2><a name="gathering_profile_data">GATHERING PROFILE DATA</a></h2>
<p>Once you have the module loaded, use your application as you normally
would. Stop the webserver when your tests are complete. Profile data
files will be produced when Apache exits and you'll see something like
this in your error_log:</p>
<pre>
DBI::ProfileDumper::Apache writing to /usr/local/apache/logs/dbi.prof.2619</pre>
<p>Now you can use dbiprof to examine the data:</p>
<pre>
dbiprof /usr/local/apache/logs/dbi.prof.*</pre>
<p>By passing dbiprof a list of all generated files, dbiprof will
automatically merge them into one result set. You can also pass
dbiprof sorting and querying options, see <a href="../../../bin/dbiprof.html">the dbiprof manpage</a> for details.</p>
<p>
</p>
<h2><a name="cleaning_up">CLEANING UP</a></h2>
<p>Once you've made some code changes, you're ready to start again.
First, delete the old profile data files:</p>
<pre>
rm /usr/local/apache/logs/dbi.prof.*</pre>
<p>Then restart your server and get back to work.</p>
<p>
</p>
<hr />
<h1><a name="memory_usage">MEMORY USAGE</a></h1>
<p>DBI::Profile can use a lot of memory for very active applications. It
collects profiling data in memory for each distinct query your
application runs. You can avoid this problem with a call like this:</p>
<pre>
<span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">Profile</span><span class="operator">}</span><span class="operator">-></span><span class="variable">flush_to_disk</span><span class="operator">()</span> <span class="keyword">if</span> <span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">Profile</span><span class="operator">}</span><span class="operator">;</span>
</pre>
<p>Calling <code>flush_to_disk()</code> will clear out the profile data and write
it to disk. Put this someplace where it will run on every request,
like a CleanupHandler, and your memory troubles should go away. Well,
at least the ones caused by DBI::Profile anyway.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Sam Tregar <<a href="mailto:sam@tregar.com">sam@tregar.com</a>></p>
<p>
</p>
<hr />
<h1><a name="copyright_and_license">COPYRIGHT AND LICENSE</a></h1>
<p>Copyright (C) 2002 Sam Tregar</p>
<p>This program is free software; you can redistribute it and/or modify
it under the same terms as Perl 5 itself.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?