diff options
| author | Christoph Berg | 2016-06-08 11:42:44 +0000 |
|---|---|---|
| committer | Christoph Berg | 2016-06-08 11:42:44 +0000 |
| commit | 0984bbc4effc2bcc64ac53c5957ce23e1def832a (patch) | |
| tree | ab43838e3c428f3d546c0e65c9c168663a73ac8f /check_postgres.pl | |
| parent | c2e378122b5b20abf7ab69476296a5307733def0 (diff) | |
connection: Make all errors including timeout from psql CRITICAL
UNKNOWN is not so much useful in the context of basic connection checks.
(The result remains UNKNOWN in case version() returns something fishy.)
Close #100.
Diffstat (limited to 'check_postgres.pl')
| -rwxr-xr-x | check_postgres.pl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index afb3b27a0..84065bad6 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -2624,7 +2624,7 @@ sub run_command { } } - local $SIG{ALRM} = sub { die 'Timed out' }; + local $SIG{ALRM} = sub { die "Timed out\n" }; alarm 0; push @args, '-c', $string; @@ -2642,6 +2642,10 @@ sub run_command { alarm 0; open STDERR, '>&', $oldstderr or ndie msg('runcommand-noerr'); close $oldstderr or ndie msg('file-noclose', 'STDERR copy', $!); + if ($err and $action eq 'connection') { + $info->{fatal} = $err; + return $info; + } if ($err) { if ($err =~ /Timed out/) { ndie msg('runcommand-timeout', $timeout); @@ -2666,8 +2670,8 @@ sub run_command { } ## If we are just trying to connect, failed attempts are critical - if ($action eq 'connection' and $db->{error} =~ /FATAL|could not connect/) { - $info->{fatal} = 1; + if ($action eq 'connection' and $db->{error}) { + $info->{fatal} = $db->{error}; return $info; } @@ -4325,11 +4329,15 @@ sub check_connection { } my $info = run_command('SELECT version() AS v'); + if ($info->{fatal}) { + add_critical $info->{fatal}; + return; + } for $db (@{$info->{db}}) { my $err = $db->{error} || ''; - if ($err =~ /FATAL|could not connect/) { + if ($err) { $MRTG and do_mrtg({one => 0}); add_critical $db->{error}; return; @@ -10321,6 +10329,8 @@ Items not specifically attributed are by GSM (Greg Sabino Mullane). total_relation_size, using the respective pg_indexes_size() and pg_total_relation_size() functions. All size checks will now also check materialized views where applicable. + + Connection errors are now always critical, not unknown. (Christoph Berg) New action replication_slots checking if logical or physical replication |
