1DBI::ProfileDumper::ApaUcsheer(3C)ontributed Perl DocumeDnBtIa:t:iPornofileDumper::Apache(3)
2
3
4

NAME

6       DBI::ProfileDumper::Apache - capture DBI profiling data from
7       Apache/mod_perl
8

SYNOPSIS

10       Add this line to your httpd.conf:
11
12         PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache
13
14       (If you're using mod_perl2, see "When using mod_perl2" for some
15       additional notes.)
16
17       Then restart your server.  Access the code you wish to test using a web
18       browser, then shutdown your server.  This will create a set of
19       dbi.prof.* files in your Apache log directory.
20
21       Get a profiling report with dbiprof:
22
23         dbiprof /path/to/your/apache/logs/dbi.prof.*
24
25       When you're ready to perform another profiling run, delete the old
26       files and start again.
27

DESCRIPTION

29       This module interfaces DBI::ProfileDumper to Apache/mod_perl.  Using
30       this module you can collect profiling data from mod_perl applications.
31       It works by creating a DBI::ProfileDumper data file for each Apache
32       process.  These files are created in your Apache log directory.  You
33       can then use the dbiprof utility to analyze the profile files.
34

USAGE

36   LOADING THE MODULE
37       The easiest way to use this module is just to set the DBI_PROFILE
38       environment variable in your httpd.conf:
39
40         PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache
41
42       The DBI will look after loading and using the module when the first DBI
43       handle is created.
44
45       It's also possible to use this module by setting the Profile attribute
46       of any DBI handle:
47
48         $dbh->{Profile} = "2/DBI::ProfileDumper::Apache";
49
50       See DBI::ProfileDumper for more possibilities, and DBI::Profile for
51       full details of the DBI's profiling mechanism.
52
53   WRITING PROFILE DATA
54       The profile data files will be written to your Apache log directory by
55       default.
56
57       The user that the httpd processes run as will need write access to the
58       directory.  So, for example, if you're running the child httpds as user
59       'nobody' and using chronolog to write to the logs directory, then
60       you'll need to change the default.
61
62       You can change the destination directory either by specifying a "Dir"
63       value when creating the profile (like "File" in the DBI::ProfileDumper
64       docs), or you can use the "DBI_PROFILE_APACHE_LOG_DIR" env var to
65       change that. For example:
66
67         PerlSetEnv DBI_PROFILE_APACHE_LOG_DIR /server_root/logs
68
69       When using mod_perl2
70
71       Under mod_perl2 you'll need to either set the
72       "DBI_PROFILE_APACHE_LOG_DIR" env var, or enable the mod_perl2
73       "GlobalRequest" option, like this:
74
75         PerlOptions +GlobalRequest
76
77       to the global config section you're about test with
78       DBI::ProfileDumper::Apache.  If you don't do one of those then you'll
79       see messages in your error_log similar to:
80
81         DBI::ProfileDumper::Apache on_destroy failed: Global $r object is not available. Set:
82           PerlOptions +GlobalRequest in httpd.conf at ..../DBI/ProfileDumper/Apache.pm line 144
83
84       Naming the files
85
86       The default file name is inherited from DBI::ProfileDumper via the
87       filename() method, but DBI::ProfileDumper::Apache appends the parent
88       pid and the current pid, separated by dots, to that name.
89
90       Silencing the log
91
92       By default a message is written to STDERR (i.e., the apache error_log
93       file) when flush_to_disk() is called (either explicitly, or implicitly
94       via DESTROY).
95
96       That's usually very useful. If you don't want the log message you can
97       silence it by setting the "Quiet" attribute true.
98
99         PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache/Quiet:1
100
101         $dbh->{Profile} = "!Statement/DBI::ProfileDumper/Quiet:1";
102
103         $dbh->{Profile} = DBI::ProfileDumper->new(
104             Path => [ '!Statement' ]
105             Quiet => 1
106         );
107
108   GATHERING PROFILE DATA
109       Once you have the module loaded, use your application as you normally
110       would.  Stop the webserver when your tests are complete.  Profile data
111       files will be produced when Apache exits and you'll see something like
112       this in your error_log:
113
114         DBI::ProfileDumper::Apache writing to /usr/local/apache/logs/dbi.prof.2604.2619
115
116       Now you can use dbiprof to examine the data:
117
118         dbiprof /usr/local/apache/logs/dbi.prof.2604.*
119
120       By passing dbiprof a list of all generated files, dbiprof will
121       automatically merge them into one result set.  You can also pass
122       dbiprof sorting and querying options, see dbiprof for details.
123
124   CLEANING UP
125       Once you've made some code changes, you're ready to start again.
126       First, delete the old profile data files:
127
128         rm /usr/local/apache/logs/dbi.prof.*
129
130       Then restart your server and get back to work.
131

OTHER ISSUES

133   Memory usage
134       DBI::Profile can use a lot of memory for very active applications
135       because it collects profiling data in memory for each distinct query
136       run.  Calling "flush_to_disk()" will write the current data to disk and
137       free the memory it's using. For example:
138
139         $dbh->{Profile}->flush_to_disk() if $dbh->{Profile};
140
141       or, rather than flush every time, you could flush less often:
142
143         $dbh->{Profile}->flush_to_disk()
144           if $dbh->{Profile} and ++$i % 100;
145

AUTHOR

147       Sam Tregar <sam@tregar.com>
148
150       Copyright (C) 2002 Sam Tregar
151
152       This program is free software; you can redistribute it and/or modify it
153       under the same terms as Perl 5 itself.
154
155
156
157perl v5.26.3                      2013-06-24     DBI::ProfileDumper::Apache(3)
Impressum