2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/sensu-plugins-postgres/pgpass.rb', line 2
def pgpass
if File.file?(config[:pgpass])
pgpass = Hash[i[hostname port database user password].zip(File.readlines(config[:pgpass])[0].strip.split(':'))]
pgpass[:database] = nil if pgpass[:database] == '*'
pgpass.each do |k, v|
config[k] ||= v
end
else
config[:hostname] ||= ENV['PGHOST'] || 'localhost'
config[:port] ||= ENV['PGPORT'] || 5432
config[:database] ||= ENV['PGDATABASE'] || 'postgres'
config[:user] ||= ENV['PGUSER'] || 'postgres'
config[:password] ||= ENV['PGPASSWORD']
end
end
|