From e28cb5b3fb52c870b8f5a1cf41cc5afd41e9023a Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Wed, 8 Oct 2008 11:56:58 -0400 Subject: [PATCH] Handle cae where ROUND gives us -0 instead of 0 for three actions. Thanks to Glyn Astill for helping to track this down. Bump version to 2.3.3 and release. --- check_postgres.pl | 27 ++++++++++++++++----------- check_postgres.pl.asc | 6 +++--- check_postgres.pl.html | 9 ++++++++- index.html | 8 ++++---- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index bf5515b99..f0b5e015b 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -28,7 +28,7 @@ $Data::Dumper::Varname = 'POSTGRES'; $Data::Dumper::Indent = 2; $Data::Dumper::Useqq = 1; -our $VERSION = '2.3.2'; +our $VERSION = '2.3.3'; use vars qw/ %opt $PSQL $res $COM $SQL $db /; @@ -2840,7 +2840,7 @@ sub check_query_time { $SQL = q{SELECT datname, max(COALESCE(ROUND(EXTRACT(epoch FROM now()-query_start)),0)) }. qq{FROM pg_stat_activity WHERE current_query <> ''$USERWHERECLAUSE GROUP BY 1}; - $info = run_command($SQL, { regex => qr{\s*.+?\s+\|\s+\d+}, emptyok => 1 } ); + $info = run_command($SQL, { regex => qr{\s*.+?\s+\|\s+\-?\d+}, emptyok => 1 } ); my $found = 0; for $db (@{$info->{db}}) { @@ -2852,8 +2852,8 @@ sub check_query_time { $found = 1; my $max = 0; - SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\d+)\s*/gsm) { - my ($dbname,$current) = ($1,$2); + SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\-?\d+)\s*/gsm) { + my ($dbname,$current) = ($1, int $2); next SLURP if skip_item($dbname); $max = $current if $current > $max; } @@ -2900,7 +2900,7 @@ sub check_txn_time { $SQL = q{SELECT datname, max(COALESCE(ROUND(EXTRACT(epoch FROM now()-xact_start)),0)) }. qq{FROM pg_stat_activity WHERE xact_start IS NOT NULL $USERWHERECLAUSE GROUP BY 1}; - my $info = run_command($SQL, { regex => qr[\s+\|\s+\d+], emptyok => 1 } ); + my $info = run_command($SQL, { regex => qr[\s+\|\s+\-?\d+], emptyok => 1 } ); my $found = 0; for $db (@{$info->{db}}) { @@ -2915,8 +2915,8 @@ sub check_txn_time { } $found = 1; my $max = -1; - SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\d+)\s*/gsm) { - my ($dbname,$current) = ($1,$2); + SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\-?\d+)\s*/gsm) { + my ($dbname,$current) = ($1, int $2); next SLURP if skip_item($dbname); $max = $current if $current > $max; } @@ -2973,7 +2973,7 @@ sub check_txn_idle { $SQL = q{SELECT datname, max(COALESCE(ROUND(EXTRACT(epoch FROM now()-query_start)),0)) }. qq{FROM pg_stat_activity WHERE current_query = ' in transaction'$USERWHERECLAUSE GROUP BY 1}; - my $info = run_command($SQL, { regex => qr[\s*.+?\s+\|\s+\d+], emptyok => 1 } ); + my $info = run_command($SQL, { regex => qr[\s*.+?\s+\|\s+\-?\d+], emptyok => 1 } ); my $found = 0; for $db (@{$info->{db}}) { @@ -2996,8 +2996,8 @@ sub check_txn_idle { } $found = 1; - SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\d+)\s*/gsm) { - my ($dbname,$current) = ($1,$2); + SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\-?\d+)\s*/gsm) { + my ($dbname,$current) = ($1, int $2); next SLURP if skip_item($dbname); $max = $current if $current > $max; } @@ -3549,7 +3549,7 @@ sub check_sequence { =head1 NAME B - a Postgres monitoring script for Nagios, MRTG, and others -This documents describes check_postgres.pl version 2.3.2 +This documents describes check_postgres.pl version 2.3.3 =head1 SYNOPSIS @@ -4690,6 +4690,11 @@ Items not specifically attributed are by Greg Sabino Mullane. =over 4 +=item B + + Account for cases where some rounding queries give -0 instead of 0. + Thanks to Glyn Astill for helping to track this down. + =item B Always quote identifiers in check_replicate_row action. diff --git a/check_postgres.pl.asc b/check_postgres.pl.asc index 39f0eb1e6..f4cd75fae 100644 --- a/check_postgres.pl.asc +++ b/check_postgres.pl.asc @@ -1,6 +1,6 @@ -----BEGIN PGP SIGNATURE----- -iEYEABEDAAYFAkjsw6cACgkQvJuQZxSWSshhtQCfTE8t7CFn2Xfmtt8E/GoTvyOI -kvoAoNYdHSGahtDWRINR8oRqEU+XOaqB -=xyuQ +iEYEABEDAAYFAkjs2EQACgkQvJuQZxSWSsh7YwCg9OZB6Ed76caurDAJo4xuTE6U +xS0AoKRLXITOrMGymNgxa5Ue7GkHpBVb +=8U4w -----END PGP SIGNATURE----- diff --git a/check_postgres.pl.html b/check_postgres.pl.html index 43ea6c31e..868944f94 100644 --- a/check_postgres.pl.html +++ b/check_postgres.pl.html @@ -90,7 +90,7 @@

NAME

check_postgres.pl - a Postgres monitoring script for Nagios, MRTG, and others -This documents describes check_postgres.pl version 2.3.2

+This documents describes check_postgres.pl version 2.3.3


@@ -1121,6 +1121,13 @@ feature requests, and commit notices, send email to Version 2.3.2 +
+
+ Account for cases where some rounding queries give -0 instead of 0.
+  Thanks to Glyn Astill for helping to track this down.
+
+
Version 2.3.2
+
  Always quote identifiers in check_replicate_row action.
diff --git a/index.html b/index.html index 263293034..9423a64e1 100644 --- a/index.html +++ b/index.html @@ -21,14 +21,14 @@ h1 {

check_postgres.pl

-

check_postgres.pl is a script for checking the state of one or more Postgres databases and reporting back in a Nagios-friendly manner. It was developed by Greg Sabino Mullane of End Point Corporation and is BSD-licensed. The latest version is 2.3.2, and was released on October 08, 2008.

+

check_postgres.pl is a script for checking the state of one or more Postgres databases and reporting back in a Nagios-friendly manner. It was developed by Greg Sabino Mullane of End Point Corporation and is BSD-licensed. The latest version is 2.3.3, and was released on October 08, 2008.

The latest development version can be downloaded via git:

-- 2.39.5