bin/metric-postgres-connections.rb in sensu-plugins-postgres-0.1.0 vs bin/metric-postgres-connections.rb in sensu-plugins-postgres-0.1.1

- old
+ new

@@ -75,20 +75,23 @@ "where datname = '#{config[:db]}' group by waiting" ] metrics = { active: 0, - waiting: 0 + waiting: 0, + total: 0 } con.exec(request.join(' ')) do |result| result.each do |row| - if row['waiting'] + if row['waiting'] == 't' metrics[:waiting] = row['count'] - else + elsif row['waiting'] == 'f' metrics[:active] = row['count'] end end end + + metrics[:total] = (metrics[:waiting].to_i + metrics[:active].to_i) metrics.each do |metric, value| output "#{config[:scheme]}.connections.#{config[:db]}.#{metric}", value, timestamp end