From ba280727c38be0ac815ea9e4d6dd94f85842844f Mon Sep 17 00:00:00 2001 From: Dominic Hargreaves Date: Sat, 23 Mar 2013 12:09:34 -0400 Subject: 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) --- check_postgres.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'check_postgres.pl') 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; -- cgit v1.2.3