I am setting up monitoring for my PostgreSQL database server, and ran across a cool way to get around specifying the username/password via the command-line every time the checks are run: pg_service.conf. Unfortunately, there is very little documentation on the config file. As best as I can figure out, if you are connecting to a remote host, your definitions should look as follows:
On a Gentoo Linux server with PostgreSQL 8.4 installed, this file will need to be placed at
/etc/postgresql-8.4/pg_service.conf. Then, to reference it, simply export the
PGSERVICE environment variable with the value of the name of the service in brackets.