postgres-status-check CLI usage
The tool expects the following input information to function:
- Name of the postgres service
- Name of the namespace of the service
- Name of the database
- Database username
- Database password
These values can be provided in three different ways:
As flags to the command
For eg, the following command can be used to check if a postgres service
by name postgres-db
in dev
namespace with the corresponding
credentials is responding:
$ postgres-status-check --service postgres-db --namespace dev \
--dbname prod_db --username admin --password admin
# output
time="2021-06-29T16:53:05Z" level=info msg="Postgres db postgres\
of Service postgres in namespace default responded OK"
dbname
(database name), username
(database username), password
(database password) and namespace
are and will get default values.
Look at the help of the command for details.
As environment variables
If no flags are provided, the tool looks for environment variables for getting
the information. To avoid possible confusion, the environment variables has the
prefix PSC
. The usage can be as follows:
$ export PSC_DBNAME=postgres
$ export PSC_NAMESPACE=default
$ export PSC_PASSWORD=postgres
$ export PSC_SERVICE=postgres
$ export PSC_USERNAME=postgres
$ postgres-status-check
#output
time="2021-06-29T16:53:05Z" level=info msg="Postgres db postgres of \
Service postgres in namespace default responded OK"
As configuration file
If the tool couldn't find the values in the above two cases, it looks for a
configuration file with the data. By default, it looks for the file
$HOME/.postgres-status-check.yaml
if a flag --config
with the right file
is not provided.
An example usage is:
$ cat /home/username/.config
dbname: postgres-db
namespace: dev
service: postgres-svc
$ postgres-status-check --config /home/username/.config
FATA[0000] services "postgres-svc" not found
exit status 1