[check_postgres] [commit] Always show all databases in the perf output, and order them, per suggestion by Cédric Villemain

check_postgres at bucardo.org check_postgres at bucardo.org
Sat Feb 21 15:04:06 UTC 2009


Committed by Greg Sabino Mullane <greg at endpoint.com>

=?utf-8?q?Always=20show=20all=20databases=20in=20the=20perf=20output,=20and=20order=20them,=20per=20suggestion=20by=20C=C3=A9dric=20Villemain?=

Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

---
 check_postgres.pl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/check_postgres.pl b/check_postgres.pl
index 8e8b7f3..1d114a1 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2092,7 +2092,8 @@ sub check_backends {
 	my $MAXSQL = q{SELECT setting FROM pg_settings WHERE name = 'max_connections'};
 	my $NOIDLE = $noidle ? q{WHERE current_query <> '<IDLE>'} : '';
 	my $GROUPBY = q{GROUP BY 2,3};
-	$SQL = "SELECT COUNT(*), ($MAXSQL), datname FROM pg_stat_activity $NOIDLE $GROUPBY";
+	$SQL = "SELECT COUNT(datid), ($MAXSQL), d.datname FROM pg_database d ".
+		"LEFT JOIN pg_stat_activity s ON (s.datid = d.oid) $NOIDLE $GROUPBY ORDER BY datname";
 	my $info = run_command($SQL, {regex => qr[\s*\d+ \| \d+\s+\|] } );
 
 	## There may be no entries returned if we catch pg_stat_activity at the right
-- 
1.6.0.5



More information about the Check_postgres mailing list