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 --httpd ./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 /var/www/html/statsinfo1 localhost 5432 postgres postgres postgres DB002 /var/www/html/statsinfo2 localhost 5433 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, create a pg_reporter report directory in apache directory.
pg_reporter -i /var/www/html
Next, configure database connection file
# vi /var/www/html/pg_reporter.conf DB001 /var/www/html localhost 5432 postgres postgres postgres
Move pg_reporter.conf to cgi-bin directory.
# mv /var/www/html/pg_reporter.conf /var/www/cgi-bin
And create shell script under follows.
# vi /var/www/cgi-bin/pg_reporter #!/bin/sh /usr/bin/pg_reporter -c
Run Apache HTTP Server.
# service httpd start
Input under URL and create your report file!