pg_reporter -- make HTML reports from PostgreSQL.
pg_reporter [OPTIONS] [TEMPLATE]
It make a HTML report with TEMPLATE from data in PostgreSQL database. pg_repoter supports the following modes. See also Description for details.
|Initialization mode||Initialize a directory used by CGI mode and HTTPD mode.|
|Command line mode||Make a report with specified parameters.|
|CGI mode||Work as a CGI module to make reports.|
|HTTPD mode||Work as a HTTPD server to make reports.|
Here are sample reports:
pg_reporter is a general purpose reporting tool for PostgreSQL. You can write your own template, and reports will be generated with the template. You only have to know SQL and HTML to write templates.
Attached templates make HTML reports for pg_statsinfo. They support navigation for the snapshot list in CGI or HTTPD modes, so you can get graphical reports only with a couple of mouse clicks.
Make a directory in the current working directory for reports.
$ pg_reporter --init=./htdocs
Run as a HTTPD mode.
$ pg_reporter -D ./htdocs
Access with a web browser to port 8080 on the localhost.
The HTTPD mode accepts URLs in the following forms:
On the other hand, you can also make a report directly from command line with options. In the following example, connecting to stats database, using a template details.xml, and writing a report into details.html.
$ pg_reporter -d stats -t details.xml -o details.html -a "begin=1&end=10"
pg_reporter accepts the following command line options.
Options to connect to servers.
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Environment Variables).
Connection information is described in .dbnames file.
DB001 db1.example.com 5432 postgres postgres postgres DB002 db2.example.com 5432 stats postgres postgres
pg_reporter has the following restrictions and limitations.
Here is a flow of pg_reporter. It is a single-threaded application.
Here is a contents of the directory made by initialization mode.
The running mode is selected with the following rule:
|Command line mode||template file|
|CGI mode||no options|
pg_reporter can be build with PGXS as same as standard contrib modules. NOTE: If you want build the pg_reporter with PostgreSQL souce-code, PostgreSQL have to be built with "--with-libxml".
$ cd pg_reporter $ make USE_PGXS=1 $ make USE_PGXS=1 install
You don't have to run registoration script for pg_reporter. But if you will make a report for pg_statsinfo, you need to install pg_statsinfo.
Those operations are required only if you will run in CGI mode. First, install Apache HTTP Server.
# rpm -ivh httpd-2.2.11-1.x86_64.rpm
Next, add the following lines in the configuration file for Apache HTTP Server.
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^/files$ /report [R,L,QSA] RewriteRule ^/([0-9A-Za-z]+)/([^\./]+)$ \ /cgi-bin/pg_reporter?id=$1&template=$2 [R,L,QSA] </IfModule> <Directory "/var/www/html/report"> Options Indexes </Directory>
Copy pg_reporter executable file to CGI directory for Apache HTTP Server. And initialize a directory for reporting.
$ cp $PGHOME/bin/pg_reporter /var/www/cgi-bin/ $ pg_reporter -i /var/www/html
$ vi /var/www/html/.dbnames
Run Apache HTTP Server.
# service httpd start