summaryrefslogtreecommitdiff
path: root/check_postgres.pl
diff options
context:
space:
mode:
authorGreg Sabino Mullane2011-07-04 18:37:04 +0000
committerGreg Sabino Mullane2011-07-04 18:37:04 +0000
commitc5c4f994ab214513f1d0ae86d5b88cc38ddae30d (patch)
tree62fc3179292daafb0c405dce4a580dc5fcb3a016 /check_postgres.pl
parent5f9eac01e750764f072f33ee9f0efb6cc584b5ba (diff)
Better tests for non-superuser in txn_idle and friends.
Attempts to fix bug 59.
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-xcheck_postgres.pl33
1 files changed, 19 insertions, 14 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index 6a8863e7b..3be87c1ae 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7162,7 +7162,7 @@ sub check_txn_idle {
my $thing = shift || msg('transactions');
my $perf = shift || msg('txn-time');
my $start = shift || 'query_start';
- my $clause = shift || q{current_query = '<IDLE> in transaction'};
+ my $clause = shift || q{current_query ~ '^<'};
## Extract the warning and critical seconds and counts.
## If not given, items will be an empty string
@@ -7196,25 +7196,30 @@ sub check_txn_idle {
## Skip if we don't care about this database
next if skip_item($r->{datname});
- ## Detect cases where pg_stat_activity is not fully populated
- if (length $r->{xact_start} and $r->{xact_start} !~ /\d/o) {
- ## Perhaps this is a non-superuser?
- if ($r->{current_query} =~ /insufficient/) {
- add_unknown msg('psa-nosuper');
- return;
- }
+ ## We do a lot of filtering based on the current_query
+ my $cq = $r->{current_query};
- ## Perhaps stats_command_string / track_activities is off?
- if ($r->{current_query} =~ /disabled/) {
- add_unknown msg('psa-disabled');
- return;
- }
+ ## Return unknown if we cannot see because we are a non-superuser?
+ if ($cq =~ /insufficient/o) {
+ add_unknown msg('psa-nosuper');
+ return;
+ }
+
+ ## Return unknown if stats_command_string / track_activities is off?
+ if ($cq =~ /disabled/o) {
+ add_unknown msg('psa-disabled');
+ return;
+ }
- ## Something else is going on
+ ## Detect other cases where pg_stat_activity is not fully populated
+ if (length $r->{xact_start} and $r->{xact_start} !~ /\d/o) {
add_unknown msg('psa-noexact');
return;
}
+ ## Filter out based on the action
+ next if $action eq 'txn_idle' and $cq ne '<IDLE> in transaction';
+
## Keep track of the longest overall time
$maxr = $r if $r->{seconds} >= $maxr->{seconds};