diff options
author | Guillaume Lelarge | 2011-09-25 19:47:30 +0000 |
---|---|---|
committer | Guillaume Lelarge | 2011-10-03 20:44:54 +0000 |
commit | 0e1cb6bea1b011f0a3f779cd5414fc36573ae2d4 (patch) | |
tree | df8fa04168e43397d8a0ff77c672b5ec36971b59 /check_postgres.pl | |
parent | a2e94c9dc73555ebd89b3788ab77d8344850b14e (diff) |
Allow the check of multiple db with connection action
We still stop at the first error.
Per request from Aziz Boultabi.
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-x | check_postgres.pl | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index aed801554..e05e5539c 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -3836,23 +3836,25 @@ sub check_connection { my $info = run_command('SELECT version() AS v'); - $db = $info->{db}[0]; + for $db (@{$info->{db}}) { - if (exists $info->{fatal}) { - $MRTG and do_mrtg({one => 0}); - add_critical $db->{error}; - return; - } + my $err = $db->{error} || ''; + if ($err =~ /FATAL/) { + $MRTG and do_mrtg({one => 0}); + add_critical $db->{error}; + return; + } - my $ver = ($db->{slurp}[0]{v} =~ /(\d+\.\d+\S+)/o) ? $1 : ''; + my $ver = ($db->{slurp}[0]{v} =~ /(\d+\.\d+\S+)/o) ? $1 : ''; - $MRTG and do_mrtg({one => $ver ? 1 : 0}); + $MRTG and do_mrtg({one => $ver ? 1 : 0}); - if ($ver) { - add_ok msg('version', $ver); - } - else { - add_unknown msg('invalid-query', $db->{slurp}[0]{v}); + if ($ver) { + add_ok msg('version', $ver); + } + else { + add_unknown msg('invalid-query', $db->{slurp}[0]{v}); + } } return; |