Allow to specify database password

This commit is contained in:
André de Kock 2017-07-20 18:13:11 +02:00 committed by GitHub
parent 955e8cec90
commit 48b1e5aa6f
1 changed files with 3 additions and 2 deletions

View File

@ -23,6 +23,7 @@
dbserver='localhost'
dbuser='postgres'
dbpass=''
if [ "$1" = "config" ]; then
echo 'graph_args --base 1024 --lower-limit 0'
@ -31,7 +32,7 @@ if [ "$1" = "config" ]; then
echo 'graph_title PostgreSQL Tablespace Sizes'
echo 'graph_vlabel Size (bytes)'
psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname FROM pg_tablespace ORDER BY 1;" | while read name
PGPASSWORD="${dbpass}" psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname FROM pg_tablespace ORDER BY 1;" | while read name
do
test -z "${name}" && continue
echo ${name}'.label '${name}
@ -47,7 +48,7 @@ if [ "$1" = "config" ]; then
exit 0
fi
psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname, PG_TABLESPACE_SIZE(oid) FROM pg_tablespace ORDER BY 1;" | while read name sep num
PGPASSWORD="${dbpass}" psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname, PG_TABLESPACE_SIZE(oid) FROM pg_tablespace ORDER BY 1;" | while read name sep num
do
test -z "${name}" && continue
echo ${name}'.value '${num}