Can you pls use ini file for username/password in check-postgres-alive.rb[and everywhere else] ?
Salamek opened this issue · 6 comments
As is used in mysql implementation https://github.com/sensu-plugins/sensu-plugins-mysql/blob/master/bin/check-mysql-alive.rb
This password and username is everywhere when used as command parameter, logs, etc (yes i use special user for this, but i dont like it anyway)
postgresql has a pgpass file - I'd take a PR that added support for that. http://www.postgresql.org/docs/9.4/static/libpq-pgpass.html
I've written something similar to what you've requested, however I'm utilising a YAML file for creds as opposed to an ini file. You can find my gist here. I've pretty much copied the check-mysql-alive.rb check.
The YAML file will need to look something like this:
production:
host: db_hostname
port: 1234 (leave this out to default to '5432')
user: db_user
password: db_pass
database: db_name
Is that of any use? Would you like a pull request?
While I would prefer using pgpass as @eheydrick proposed but I would accept any reasonable contribution that removes creds from a cli arg.
Hi,
I added pgpass file and PG* variables support.
You can get it from my repository fork:
https://github.com/ahes/sensu-plugins-postgres/commit/3d7d71d2e5c754b3da54aaca91098faa3cc0c7eb
Pull request created. I didn't run or altered any tests.
Sample usage
Set pgpass path with -f
. By default ~/.pgpass is read if exists.
$ check-postgres-alive.rb -f /var/lib/postgresql/.pgpass -d template1
CheckPostgres OK: Server version: {"version"=>"PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"}
Use env variables to set password and database.
$ export PGPASSWORD=this-is-my-secret-password
$ export PGDATABASE=template1
$ check-postgres-alive.rb -u sensu
CheckPostgres OK: Server version: {"version"=>"PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"}
Enjoy.
Changes have been merged: b52d7ea
@Salamek @majormoses You can close the issue.
closed via #36