bin/check-postgres-query.rb in sensu-plugins-postgres-0.1.1 vs bin/check-postgres-query.rb in sensu-plugins-postgres-1.0.0

- old
+ new

@@ -55,11 +55,11 @@ description: 'Database port', short: '-P PORT', long: '--port PORT', default: 5432 - option :db, + option :database, description: 'Database name', short: '-d DB', long: '--db DB', default: 'postgres' @@ -86,12 +86,22 @@ description: 'Critical threshold expression', short: '-c CRITICAL', long: '--critical CRITICAL', default: nil + option :timeout, + description: 'Connection timeout (seconds)', + short: '-T TIMEOUT', + long: '--timeout TIMEOUT', + default: nil + def run begin - con = PG::Connection.new(config[:hostname], config[:port], nil, nil, config[:db], config[:user], config[:password]) + con = PG.connect(host: config[:hostname], + dbname: config[:database], + user: config[:user], + password: config[:password], + connect_timeout: config[:timeout]) res = con.exec(config[:query].to_s) rescue PG::Error => e unknown "Unable to query PostgreSQL: #{e.message}" end