For connection test, return critical, not unknown, on FATAL errors
authorGreg Sabino Mullane <greg@endpoint.com>
Mon, 27 Dec 2010 17:04:47 +0000 (12:04 -0500)
committerGreg Sabino Mullane <greg@endpoint.com>
Mon, 27 Dec 2010 17:04:47 +0000 (12:04 -0500)
check_postgres.pl

index b5ff62de45b257b2e7778fd78a1a9259da14da5a..085d079bbeec2b0ba2c04d128e1005da5e3c2f1a 100755 (executable)
@@ -1932,6 +1932,12 @@ sub run_command {
             }
 
             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 (exists $arg->{fatalregex} and $db->{error} =~ /$arg->{fatalregex}/) {
                     $info->{fatalregex} = $db->{error};
                     next;
@@ -3079,6 +3085,12 @@ sub check_connection {
 
     $db = $info->{db}[0];
 
+    if (exists $info->{fatal}) {
+        $MRTG and do_mrtg({one => 0});
+        add_critical $db->{error};
+        return;
+    }
+
     my $ver = ($db->{slurp}[0]{v} =~ /(\d+\.\d+\S+)/o) ? $1 : '';
 
     $MRTG and do_mrtg({one => $ver ? 1 : 0});
@@ -8751,6 +8763,9 @@ Items not specifically attributed are by Greg Sabino Mullane.
 
   Fix problem when examining items in pg_settings (Greg Sabino Mullane)
 
+  For connection test, return critical, not unknown, on FATAL errors
+    (Greg Sabino Mullane, reported by Peter Eisentraut in bug #62)
+
 =item B<Version 2.15.0>
 
   Add --quiet argument to surpress output on OK Nagios results