From 4c3a7e9d4b20412ac2c7ee7474eaa3051a5baecf Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Sat, 21 Feb 2009 10:02:25 -0500 Subject: [PATCH] =?utf8?q?Always=20show=20all=20databases=20in=20the=20per?= =?utf8?q?f=20output,=20and=20order=20them,=20per=20suggestion=20by=20C?= =?utf8?q?=C3=A9dric=20Villemain?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- check_postgres.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_postgres.pl b/check_postgres.pl index 8e8b7f3d6..1d114a1f2 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 <> ''} : ''; 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 -- 2.39.5