summaryrefslogtreecommitdiff
path: root/check_postgres.pl
diff options
context:
space:
mode:
authorDominic Hargreaves2013-03-23 16:09:34 +0000
committerGreg Sabino Mullane2013-03-23 16:09:34 +0000
commitba280727c38be0ac815ea9e4d6dd94f85842844f (patch)
treee617e7b4501d096d7e9ebd3322e2f4ece500eb43 /check_postgres.pl
parent8faf756adbfcae79648cebee96dc4510e9e62f96 (diff)
Make sure connection checks return CRITICAL rather than UNKNOWN.
Patch by Dominic Hargreaves with minor tweaks by Greg Sabino Mullane. Thanks to Christoph Berg for the forward (this came in via the Debian bugs system)
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-xcheck_postgres.pl16
1 files changed, 8 insertions, 8 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index a3078f40d..152b7e831 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2353,13 +2353,13 @@ sub run_command {
$ERROR = $db->{error};
}
- if ($db->{error} =~ /FATAL/) {
- ## If we are just trying to connect, this should be a normal error
- if ($action eq 'connection') {
- $info->{fatal} = 1;
- return $info;
- }
+ ## 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;
+ return $info;
+ }
+ if ($db->{error} =~ /FATAL/) {
if (exists $arg->{fatalregex} and $db->{error} =~ /$arg->{fatalregex}/) {
$info->{fatalregex} = $db->{error};
next;
@@ -2369,7 +2369,7 @@ sub run_command {
}
}
- elsif ($db->{error} =~ /statement timeout/) {
+ if ($db->{error} =~ /statement timeout/) {
ndie msg('runcommand-timeout', $timeout);
}
@@ -4011,7 +4011,7 @@ sub check_connection {
for $db (@{$info->{db}}) {
my $err = $db->{error} || '';
- if ($err =~ /FATAL/) {
+ if ($err =~ /FATAL|could not connect/) {
$MRTG and do_mrtg({one => 0});
add_critical $db->{error};
return;