[check_postgres] [commit] Add --noidle flag (Selena Deckelmann)
check_postgres at bucardo.org
check_postgres at bucardo.org
Thu Dec 11 23:17:55 UTC 2008
Committed by Greg Sabino Mullane <greg at endpoint.com>
Add --noidle flag (Selena Deckelmann)
Bump version to 2.5.1
---
check_postgres.pl | 25 ++++++++++++++++++-------
check_postgres.pl.asc | 6 +++---
check_postgres.pl.html | 17 +++++++++++++----
index.html | 8 ++++----
4 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index adba695..1a831ba 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.5.0';
+our $VERSION = '2.5.1';
use vars qw/ %opt $PSQL $res $COM $SQL $db /;
@@ -129,6 +129,7 @@ die $USAGE unless
'reverse', ## used by custom_query only
'repinfo=s', ## used by replicate_row only
'schema=s', ## used by fsm_* checks only
+ 'noidle', ## used by backends only
)
and keys %opt
and ! @ARGV;
@@ -925,7 +926,7 @@ sub run_command {
## Don't set any default values if a service is being used
- if (length $opt{dbservice}->[0]) {
+ if (defined $opt{dbservice} and length $opt{dbservice}->[0]) {
$conn->{dbname} = [];
$conn->{port} = [];
$conn->{dbuser} = [];
@@ -1624,6 +1625,7 @@ sub check_backends {
my $warning = $opt{warning} || '90%';
my $critical = $opt{critical} || '95%';
+ my $noidle = $opt{noidle} || 0;
my $validre = qr{^(\-?)(\d+)(\%?)$};
if ($warning !~ $validre) {
@@ -1646,7 +1648,9 @@ sub check_backends {
}
my $MAXSQL = q{SELECT setting FROM pg_settings WHERE name = 'max_connections'};
- $SQL = "SELECT COUNT(*), ($MAXSQL), datname FROM pg_stat_activity GROUP BY 2,3";
+ my $NOIDLE = $noidle ? q{WHERE current_query <> '<IDLE>'} : '';
+ my $GROUPBY = q{GROUP BY 2,3};
+ $SQL = "SELECT COUNT(*), ($MAXSQL), datname FROM pg_stat_activity $NOIDLE $GROUPBY";
my $info = run_command($SQL, {regex => qr[\s*\d+ \| \d+\s+\|] } );
## There may be no entries returned if we catch pg_stat_activity at the right
@@ -3744,7 +3748,7 @@ sub show_dbstats {
=head1 NAME
B<check_postgres.pl> - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.5.0
+This documents describes check_postgres.pl version 2.5.1
=head1 SYNOPSIS
@@ -4057,9 +4061,9 @@ given. This choice does not use the B<max_connections> setting. Second, the
percentage of available connections can be given. Third, a negative number can
be given which represents the number of connections left until B<max_connections>
is reached. The default values for I<--warning> and I<--critical> are '90%' and '95%'.
-You can also filter the databases by use of the
-I<--include> and I<--exclude> options. See the L</"BASIC FILTERING"> section
-for more details.
+You can also specify I<--noidle> to return a count of non-idle processes.
+You can also filter the databases by use of the <--include> and I<--exclude> options.
+See the L</"BASIC FILTERING"> section for more details.
Example 1: Give a warning when the number of connections on host quirm reaches 120, and a critical if it reaches 150.
@@ -4970,6 +4974,13 @@ Items not specifically attributed are by Greg Sabino Mullane.
=over 4
+=item B<Version 2.5.1>
+
+ Add support for --noidle flag to prevent backends action from counting idle processes.
+ Patch by Selena Deckelmann.
+
+ Fix small undefined warning when not using --dbservice.
+
=item B<Version 2.5.0>
Add support for the pg_Service.conf file with the --dbservice option.
diff --git a/check_postgres.pl.asc b/check_postgres.pl.asc
index 2b7865c..82036ad 100644
--- a/check_postgres.pl.asc
+++ b/check_postgres.pl.asc
@@ -1,6 +1,6 @@
-----BEGIN PGP SIGNATURE-----
-iEYEABEDAAYFAkkUSswACgkQvJuQZxSWSsiXmwCg/h+pQ6XtaKgYXUBUQMg1r+1j
-r3EAoNfqJ6npPLwZK167eLldICaVrXqC
-=MB+t
+iEYEABEDAAYFAklBn3MACgkQvJuQZxSWSsh+uQCfYBnecQ2pqKyHckTNEddpAUTE
+q1wAnit4d7RDbxD6OhPGvTNWBIxWVpf7
+=CQ87
-----END PGP SIGNATURE-----
diff --git a/check_postgres.pl.html b/check_postgres.pl.html
index 9fe92ba..1b6c768 100644
--- a/check_postgres.pl.html
+++ b/check_postgres.pl.html
@@ -92,7 +92,7 @@
<hr />
<h1><a name="name">NAME</a></h1>
<p><strong>check_postgres.pl</strong> - a Postgres monitoring script for Nagios, MRTG, Cacti, and others
-This documents describes check_postgres.pl version 2.5.0</p>
+This documents describes check_postgres.pl version 2.5.1</p>
<p>
</p>
<hr />
@@ -417,9 +417,9 @@ given. This choice does not use the <strong>max_connections</strong> setting. Se
percentage of available connections can be given. Third, a negative number can
be given which represents the number of connections left until <strong>max_connections</strong>
is reached. The default values for <em>--warning</em> and <em>--critical</em> are '90%' and '95%'.
-You can also filter the databases by use of the
-<em>--include</em> and <em>--exclude</em> options. See the <a href="#basic_filtering">BASIC FILTERING</a> section
-for more details.</p>
+You can also specify <em>--noidle</em> to return a count of non-idle processes.
+You can also filter the databases by use of the <--include> and <em>--exclude</em> options.
+See the <a href="#basic_filtering">BASIC FILTERING</a> section for more details.</p>
<p>Example 1: Give a warning when the number of connections on host quirm reaches 120, and a critical if it reaches 150.</p>
<pre>
check_postgres_backends --host=quirm --warning=120 --critical=150</pre>
@@ -1213,6 +1213,15 @@ feature requests, and commit notices, send email to <a href="mailto:check_postgr
<h1><a name="history">HISTORY</a></h1>
<p>Items not specifically attributed are by Greg Sabino Mullane.</p>
<dl>
+<dt><strong><a name="item_version_2_2e5_2e1"><strong>Version 2.5.1</strong></a></strong></dt>
+
+<dd>
+<pre>
+ Add support for --noidle flag to prevent backends action from counting idle processes.
+ Patch by Selena Deckelmann.</pre>
+<pre>
+ Fix small undefined warning when not using --dbservice.</pre>
+</dd>
<dt><strong><a name="item_version_2_2e5_2e0"><strong>Version 2.5.0</strong></a></strong></dt>
<dd>
diff --git a/index.html b/index.html
index 6b43869..6fb4df3 100644
--- a/index.html
+++ b/index.html
@@ -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.5.0</b>, and was released on December 04, 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.5.1</b>, and was released on December 11, 2008.</p>
<ul>
- <li><a href="/check_postgres/check_postgres.pl.html">Documentation for check_postgres 2.5.0</a></li>
+ <li><a href="/check_postgres/check_postgres.pl.html">Documentation for check_postgres 2.5.1</a></li>
</ul>
<ul>
- <li><a href="/check_postgres/check_postgres.pl">Download check_postgres.pl 2.5.0</a></li>
- <li><a href="/check_postgres/check_postgres.pl.asc">PGP signature for check_postgres.pl 2.5.0</a></li>
+ <li><a href="/check_postgres/check_postgres.pl">Download check_postgres.pl 2.5.1</a></li>
+ <li><a href="/check_postgres/check_postgres.pl.asc">PGP signature for check_postgres.pl 2.5.1</a></li>
</ul>
<p>The latest development version can be downloaded via git:</p>
--
1.5.5.4
More information about the Check_postgres
mailing list