Handle cae where ROUND gives us -0 instead of 0 for three actions.
authorGreg Sabino Mullane <greg@endpoint.com>
Wed, 8 Oct 2008 15:56:58 +0000 (11:56 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Wed, 8 Oct 2008 15:56:58 +0000 (11:56 -0400)
Thanks to Glyn Astill for helping to track this down.
Bump version to 2.3.3 and release.

check_postgres.pl
check_postgres.pl.asc
check_postgres.pl.html
index.html

index bf5515b99577f68e997714d955156a5a6e73ea91..f0b5e015b50f51eee416d56eab8d1a3ae437b0fa 100755 (executable)
@@ -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 <> '<IDLE>'$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 = '<IDLE> 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<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
 
 =head1 SYNOPSIS
 
@@ -4690,6 +4690,11 @@ Items not specifically attributed are by Greg Sabino Mullane.
 
 =over 4
 
+=item B<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.
+
 =item B<Version 2.3.2>
 
  Always quote identifiers in check_replicate_row action.
index 39f0eb1e6ae56ce243084675e99c34fb750a332a..f4cd75faeb363505605d311a75e1becc52b45c76 100644 (file)
@@ -1,6 +1,6 @@
 -----BEGIN PGP SIGNATURE-----
 
-iEYEABEDAAYFAkjsw6cACgkQvJuQZxSWSshhtQCfTE8t7CFn2Xfmtt8E/GoTvyOI
-kvoAoNYdHSGahtDWRINR8oRqEU+XOaqB
-=xyuQ
+iEYEABEDAAYFAkjs2EQACgkQvJuQZxSWSsh7YwCg9OZB6Ed76caurDAJo4xuTE6U
+xS0AoKRLXITOrMGymNgxa5Ue7GkHpBVb
+=8U4w
 -----END PGP SIGNATURE-----
index 43ea6c31e0b0b6ea1e21b86684032c8003b98277..868944f948908148c923b40b0d07868b68eb388b 100644 (file)
@@ -90,7 +90,7 @@
 <hr />
 <h1><a name="name">NAME</a></h1>
 <p><strong>check_postgres.pl</strong> - a Postgres monitoring script for Nagios, MRTG, and others
-This documents describes check_postgres.pl version 2.3.2</p>
+This documents describes check_postgres.pl version 2.3.3</p>
 <p>
 </p>
 <hr />
@@ -1121,6 +1121,13 @@ feature requests, and commit notices, send email to <a href="mailto:check_postgr
 <dl>
 <dt><strong><a name="item_version_2_2e3_2e2"><strong>Version 2.3.2</strong></a></strong></dt>
 
+<dd>
+<pre>
+ Account for cases where some rounding queries give -0 instead of 0.
+  Thanks to Glyn Astill for helping to track this down.</pre>
+</dd>
+<dt><strong><strong>Version 2.3.2</strong></strong></dt>
+
 <dd>
 <pre>
  Always quote identifiers in check_replicate_row action.</pre>
index 263293034aaf3e3da9737ab8364eda3914e4f499..9423a64e18b735eff2f69ce17e793f3a508d68a0 100644 (file)
@@ -21,14 +21,14 @@ h1 {
 
 <h1>check_postgres.pl</h1>
 
-<p><b>check_postgres.pl</b> 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 <a href="http://www.endpoint.com/">End Point Corporation</a> and is BSD-licensed. The latest version is <b>2.3.2</b>, and was released on October 08, 2008.</p>
+<p><b>check_postgres.pl</b> 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 <a href="http://www.endpoint.com/">End Point Corporation</a> and is BSD-licensed. The latest version is <b>2.3.3</b>, and was released on October 08, 2008.</p>
 
 <ul>
- <li><a href="/check_postgres/check_postgres.pl.html">Documentation for check_postgres 2.3.2</a></li>
+ <li><a href="/check_postgres/check_postgres.pl.html">Documentation for check_postgres 2.3.3</a></li>
 </ul>
 <ul>
- <li><a href="/check_postgres/check_postgres.pl">Download check_postgres.pl 2.3.2</a></li>
- <li><a href="/check_postgres/check_postgres.pl.asc">PGP signature for check_postgres.pl 2.3.2</a></li>
+ <li><a href="/check_postgres/check_postgres.pl">Download check_postgres.pl 2.3.3</a></li>
+ <li><a href="/check_postgres/check_postgres.pl.asc">PGP signature for check_postgres.pl 2.3.3</a></li>
 </ul>
 
 <p>The latest development version can be downloaded via git:</p>