summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Berg2016-06-08 20:14:59 +0000
committerChristoph Berg2016-06-08 20:14:59 +0000
commit3d6f175a9303753b7a36a59d4179d21b5e5d9a02 (patch)
tree23067fa239015ad647f20d8114255d803f8da03f
parent0984bbc4effc2bcc64ac53c5957ce23e1def832a (diff)
txn_idle: Document that --includeuser can be used to work around superuser checks
Close #81.
-rwxr-xr-xcheck_postgres.pl4
-rw-r--r--t/02_txn_idle.t10
2 files changed, 12 insertions, 2 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index 84065bad6..76514448f 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -9995,6 +9995,10 @@ are given and the numbers are unsigned, the units are assumed to be seconds.
This action requires Postgres 8.3 or better.
+Superuser privileges are required to see the queries of all users in the system;
+UNKNOWN is returned if queries cannot be checked. To only include queries by
+the connecting user, use I<--includeuser>.
+
Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:
check_postgres_txn_idle --port=5432 --warning='15 seconds'
diff --git a/t/02_txn_idle.t b/t/02_txn_idle.t
index 0f841a3b7..87efe4ce7 100644
--- a/t/02_txn_idle.t
+++ b/t/02_txn_idle.t
@@ -6,7 +6,7 @@ use 5.006;
use strict;
use warnings;
use Data::Dumper;
-use Test::More tests => 15;
+use Test::More tests => 16;
use lib 't','.';
use CP_Testing;
@@ -84,9 +84,15 @@ like ($cp->run(q{-w '1 for 2s'}), qr{1 idle transactions longer than 2s, longest
$t = qq{$S returns an unknown if running as a non-superuser};
my $olduser = $cp->{testuser};
$cp->{testuser} = 'powerless_pete';
-like ($cp->run('-w 0'), qr{^$label UNKNOWN: .+superuser}, $t);
+like ($cp->run('-w 1'), qr{^$label UNKNOWN: .+superuser}, $t);
$idle_dbh->commit;
+my $idle_dbh2 = $cp->test_database_handle({ testuser => 'powerless_pete' });
+$idle_dbh2->do('SELECT 1');
+sleep(1);
+$t = qq{$S identifies own queries even when running as a non-superuser};
+like ($cp->run('-w 1 --includeuser powerless_pete'), qr{longest idle in txn: \d+s}, $t);
+
exit;