| 1 |
------------------------------------------------------------------------------ |
| 2 |
pgbadger_tools - Tools based on pgBadger binary files |
| 3 |
|
| 4 |
This program is open source, licensed under the PostgreSQL Licence. |
| 5 |
For license terms, see the LICENSE file. |
| 6 |
------------------------------------------------------------------------------ |
| 7 |
|
| 8 |
This program is first used to demonstrate how to deal with pgBadger binary |
| 9 |
files to build your own tool. If you don't want to rewrite all, you can |
| 10 |
post pull request of this tool with your own option so that pgbadger_tools |
| 11 |
will do what your need. |
| 12 |
|
| 13 |
All statistics and data gathered by pgBadger binary file is load into memory |
| 14 |
using method load_stat(). To generate a binary file you simply have to set |
| 15 |
the output file extension to .bin. Note that if you use incremental mode with |
| 16 |
pgbadger it already generate binary file in daily directories. |
| 17 |
|
| 18 |
example: pgbadger -o out.bin /var/log/postgresql/postgresql.log |
| 19 |
|
| 20 |
PGBADGER_TOOLS OPTIONS AND TOOLS |
| 21 |
-------------------------------- |
| 22 |
|
| 23 |
**Auto explain** |
| 24 |
|
| 25 |
The first option added is --explain-slowest that dump top slowest queries in |
| 26 |
an explain analyze statement, ready to be executed. An extended version could |
| 27 |
be created to automatically execute those explain statement on the database. |
| 28 |
|
| 29 |
./pgbadger_tools --explain-slowest out.bin |
| 30 |
|
| 31 |
You can use several binary file as input, for example from an incremental |
| 32 |
output directory: |
| 33 |
|
| 34 |
./pgbadger_tools --explain-slowest /var/www/pgbadger/2014/09/03/*.bin |
| 35 |
|
| 36 |
The explain tool is base on an original work of Rodolphe Quiedeville, that was |
| 37 |
first sent as a pull request on pgbadger. But we need to keep pgBadger simple |
| 38 |
so the place of this kind of addons are more in peripheral tools. It is possible |
| 39 |
that in future, the tsung and json output will be removed from pgbadger and put |
| 40 |
in pgbadger_tools |
| 41 |
|
| 42 |
If you want to chain tools and HTML report, you can proceed as follow: |
| 43 |
|
| 44 |
pgbadger -o out.bin /var/log/postgresql/postgresql.log |
| 45 |
./pgbadger_tools --explain-slowest out.bin > explain_top_slowest.sql |
| 46 |
pgbadger -o report.html out.bin |
| 47 |
|
| 48 |
**CSV output** |
| 49 |
_ |
| 50 |
When using the following option, pgbadger_tools will export top queries section |
| 51 |
results in csv format, for example for later analysis. This is an original work |
| 52 |
of bricklen. |
| 53 |
|
| 54 |
Here are the supported options, only one of the following is mandatory: |
| 55 |
|
| 56 |
--csv-time-consuming : generate a CSV file with top time consuming queries |
| 57 |
--csv-slowest : generate a CSV file with top slowest queries |
| 58 |
--csv-normalized : generate a CSV file with top normalized queries |
| 59 |
|
| 60 |
./pgbadger_tools --csv-time-consuming out.bin |
| 61 |
|
| 62 |
Those options can not be used together. By default the output file is named |
| 63 |
out.csv, you can use the --csv-filename option to renamed this file. Ex: |
| 64 |
|
| 65 |
./pgbadger_tools --csv-slowest --csv-filename slowest.csv out.bin |
| 66 |
|
| 67 |
Option to limit top queries to minimum duration: |
| 68 |
|
| 69 |
--max-duration MS : set the number of milliseconds above which queries |
| 70 |
will not be reported. Use it if you want to auto |
| 71 |
execute explain statements. |
| 72 |
|
| 73 |
If you want to chain tools and HTML report, you can proceed as follow: |
| 74 |
|
| 75 |
pgbadger -o out.bin /var/log/postgresql/postgresql.log |
| 76 |
./pgbadger_tools --csv-slowest out.bin --csv-filename top_slowest.csv |
| 77 |
pgbadger -o report.html out.bin |
| 78 |
|
| 79 |
|
| 80 |
CONTRIBUTION: |
| 81 |
------------- |
| 82 |
|
| 83 |
Feel free to extend pgbadger_tools of new features. To see how to integrate |
| 84 |
you Perl code in this program, search for "Add your own" string in the code |
| 85 |
and look at the example searching on explain_slowest. |
| 86 |
|
| 87 |
Regards, |
| 88 |
|
| 89 |
-- |
| 90 |
Gilles Darold |
| 91 |
|