From d8b571d91c2600c9cec66729fc5a0805ced9d1b5 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Fri, 12 Jun 2009 19:39:38 -0400 Subject: [PATCH] Credit Jeff, make versions consistent. --- META.yml | 4 +- Makefile.PL | 2 +- check_postgres.pl | 7 +- check_postgres.pl.html | 222 ++++++++++++++++++++++++++--------------- 4 files changed, 148 insertions(+), 87 deletions(-) diff --git a/META.yml b/META.yml index 0c57cc69d..184c2d819 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name : check_postgres.pl -version : 2.9.0 +version : 2.9.1 abstract : Postgres monitoring script author: - Greg Sabino Mullane @@ -30,7 +30,7 @@ recommends: provides: check_postgres: file : check_postgres.pl - version : 2.9.0 + version : 2.9.1 keywords: - Postgres diff --git a/Makefile.PL b/Makefile.PL index 7ef5a6f00..1b955825a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,7 +6,7 @@ use strict; use warnings; use 5.006001; -my $VERSION = '2.9.0'; +my $VERSION = '2.9.1'; if ($VERSION =~ /_/) { print "WARNING! This is a test version ($VERSION) and should not be used in production!\n"; diff --git a/check_postgres.pl b/check_postgres.pl index 59fbf8188..cf4af2ce2 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -29,7 +29,7 @@ $Data::Dumper::Varname = 'POSTGRES'; $Data::Dumper::Indent = 2; $Data::Dumper::Useqq = 1; -our $VERSION = '2.9.0'; +our $VERSION = '2.9.1'; use vars qw/ %opt $PSQL $res $COM $SQL $db /; @@ -5949,7 +5949,7 @@ sub show_dbstats { B - a Postgres monitoring script for Nagios, MRTG, Cacti, and others -This documents describes check_postgres.pl version 2.9.0 +This documents describes check_postgres.pl version 2.9.1 =head1 SYNOPSIS @@ -7351,9 +7351,10 @@ Items not specifically attributed are by Greg Sabino Mullane. =over 4 -=item B (May 2009) +=item B (June 2009) Fix for multiple databases with the check_bloat action (Mark Kirkwood) + Tests for same_schema, other minor test fixes (Jeff Boes) =item B (May 28, 2009) diff --git a/check_postgres.pl.html b/check_postgres.pl.html index 901128e46..f39d1dc9e 100644 --- a/check_postgres.pl.html +++ b/check_postgres.pl.html @@ -9,8 +9,10 @@ -

+ + -


NAME

check_postgres.pl - a Postgres monitoring script for Nagios, MRTG, Cacti, and others

-

This documents describes check_postgres.pl version 2.8.1

+

This documents describes check_postgres.pl version 2.9.1


@@ -148,25 +153,25 @@ the directory naming trick.

The default output format is for Nagios, which is a single line of information, along with four specific exit codes:

    -
  1. (OK) +
  2. (OK)
  3. -
  4. (WARNING) +
  5. (WARNING)
  6. -
  7. (CRITICAL) +
  8. (CRITICAL)
  9. -
  10. (UNKNOWN) +
  11. (UNKNOWN)

The output line is one of the words above, a colon, and then a short description of what was measured. Additional statistics information, as well as the total time the command took, can be output as well: see the documentation on the arguments ---showperf, ---perflimit, and ---showtime.

+--showperf, +--perflimit, and +--showtime.

MRTG output

@@ -201,41 +206,41 @@ other actions, using --simple is enough to make Cacti happy.

DATABASE CONNECTION OPTIONS

All actions accept a common set of database options.

-
-H NAME or --host=NAME
+
-H NAME or --host=NAME

Connect to the host indicated by NAME. Can be a comma-separated list of names. Multiple host arguments are allowed. If no host is given, defaults to the PGHOST environment variable or no host at all (which indicates using a local Unix socket). You may also use "--dbhost".

-
-p PORT or --port=PORT
+
-p PORT or --port=PORT

Connects using the specified PORT number. Can be a comma-separated list of port numbers, and multiple port arguments are allowed. If no port number is given, defaults to the PGPORT environment variable. If that is not set, it defaults to 5432. You may also use "--dbport"

-
-db NAME or --dbname=NAME
+
-db NAME or --dbname=NAME

Specifies which database to connect to. Can be a comma-separated list of names, and multiple dbname arguments are allowed. If no dbname option is provided, defaults to the PGDATABASE environment variable. If that is not set, it defaults to 'postgres' if psql is version 8 or greater, and 'template1' otherwise.

-
-u USERNAME or --dbuser=USERNAME
+
-u USERNAME or --dbuser=USERNAME

The name of the database user to connect as. Can be a comma-separated list of usernames, and multiple dbuser arguments are allowed. If this is not provided, it defaults to the PGUSER environment variable, otherwise it defaults to 'postgres'.

-
--dbpass=PASSWORD
+
--dbpass=PASSWORD

Provides the password to connect to the database with. Use of this option is highly discouraged. Instead, one should use a .pgpass or pg_service.conf file.

-
--dbservice=NAME
+
--dbservice=NAME

The name of a service inside of the pg_service.conf file. This file is in your home directory by @@ -268,56 +273,56 @@ carries over until it is changed again.

OTHER OPTIONS

Other options include:

-
--action=NAME
+
--action=NAME

States what action we are running. Required unless using a symlinked file, in which case the name of the file is used to figure out the action.

-
--warning=VAL or -w VAL
+
--warning=VAL or -w VAL

Sets the threshold at which a warning alert is fired. The valid options for this option depends on the action used.

-
--critical=VAL or -c VAL
+
--critical=VAL or -c VAL

Sets the threshold at which a critical alert is fired. The valid options for this option depends on the action used.

-
-t VAL or --timeout=VAL
+
-t VAL or --timeout=VAL

Sets the timeout in seconds after which the script will abort whatever it is doing and return an UNKNOWN status. The timeout is per Postgres cluster, not for the entire script. The default value is 10; the units are always in seconds.

-
-h or --help
+
-h or --help

Displays a help screen with a summary of all actions and options.

-
-V or --version
+
-V or --version

Shows the current version.

-
-v or --verbose
+
-v or --verbose

Set the verbosity level. Can call more than once to boost the level. Setting it to three or higher (in other words, issuing -v -v -v) turns on debugging information for this program which is sent to stderr.

-
--showperf=VAL
+
--showperf=VAL

Determines if we output additional performance data in standard Nagios format (at end of string, after a pipe symbol, using name=value). VAL should be 0 or 1. The default is 1. Only takes effect if using Nagios output mode.

-
--perflimit=i
+
--perflimit=i

Sets a limit as to how many items of interest are reported back when using the @@ -327,19 +332,19 @@ careful when using this with the --include or --exclude option those restrictions are done after the query has been run, and thus your limit may not include the items you want. Only takes effect if using Nagios output mode.

-
--showtime=VAL
+
--showtime=VAL

Determines if the time taken to run each query is shown in the output. VAL should be 0 or 1. The default is 1. No effect unless showperf is on. Only takes effect if using Nagios output mode.

-
--test
+
--test

Enables test mode. See the TEST MODE section below.

-
--PSQL=PATH
+
--PSQL=PATH

Tells the script where to find the psql program. Useful if you have more than @@ -349,23 +354,23 @@ is not allowed. To enable it, you must change the $NO_PSQL_OPTION top of the script to 0. Avoid using this option if you can, and instead hard-code your psql location into the $PSQL variable, also near the top of the script.

-
--symlinks
+
--symlinks

Creates symlinks to the main program for each action.

-
--output=VAL
+
--output=VAL

Determines the format of the output, for use in various programs. The default is 'nagios'. No other systems are supported yet.

-
--mrtg=VAL
+
--mrtg=VAL

Used only for the MRTG or simple output, for a few specific actions.

-
--debugoutput=VAL
+
--debugoutput=VAL

Outputs the exact string returned by psql, for use in debugging. The value is one or more letters, @@ -583,61 +588,61 @@ and the name of the database on the fourth line.

and outputs it in a Cacti-friendly manner. No other output is supported, as the output is informational and does not lend itself to alerts, such as used with Nagios. If no options are given, all databases are returned, one per line. You can include a specific -database by use of the --include option, or you can use the --dbname option.

+database by use of the --include option, or you can use the --dbname option.

Eleven items are returned on each line, in the format name:value, separated by a single space. The items are:

-
backends
+
backends

The number of currently running backends for this database.

-
commits
+
commits

The total number of commits for this database since it was created or reset.

-
rollbacks
+
rollbacks

The total number of rollbacks for this database since it was created or reset.

-
read
+
read

The total number of disk blocks read.

-
hit
+
hit

The total number of buffer hits.

-
ret
+
ret

The total number of rows returned.

-
fetch
+
fetch

The total number of rows fetched.

-
ins
+
ins

The total number of rows inserted.

-
upd
+
upd

The total number of rows updated.

-
del
+
del

The total number of rows deleted.

-
dbname
+
dbname

The name of the database.

@@ -647,37 +652,37 @@ space. The items are:

not available in those versions.

If the dbname argument is given, seven additional items are returned:

-
idx_scan
+
idx_scan

Total number of user index scans.

-
idx_tup_read
+
idx_tup_read

Total number of user index entries returned.

-
idx_tup_fetch
+
idx_tup_fetch

Total number of rows fetched by simple user index scans.

-
idx_blks_read
+
idx_blks_read

Total number of disk blocks read for all user indexes.

-
idx_blks_hit
+
idx_blks_hit

Total number of buffer hits for all user indexes.

-
seq_scan
+
seq_scan

Total number of sequential scans against all user tables.

-
seq_tup_read
+
seq_tup_read

Total number of tuples returned from all user tables.

@@ -884,7 +889,7 @@ This action issues a command that throws an error on each database it is checking, and ensures that the message shows up in the logs. It scans the various log_* settings inside of Postgres to figure out where the logs should be. If you are using syslog, it does a rough (but not foolproof) scan of -/etc/syslog.conf. Alternatively, you can provide the name of the logfile +/etc/syslog.conf. Alternatively, you can provide the name of the logfile with the --logfile option. This is especially useful if the logs have a custom rotation scheme driven be an external program. The --logfile option supports the following escape characters: %Y %m %d %H, which represent @@ -979,6 +984,47 @@ assumed to be seconds.

line gives the name of the database.

+

same_schema

+

(symlink: check_postgres_same_schema) Verifies that two databases are identical as far as their +schema (but not the data within). This is particularly handy for making sure your slaves have not +been modified or corrupted in any way when using master to slave replication. Unlike most other +actions, this has no warning or critical criteria - the databases are either in sync, or are not. +If they are not, a detailed list of the differences is presented. To make the list more readable, +provide a --verbose argument, which will output one item per line.

+

You may want to exclude or filter out certain differences. The way to do this is to add strings +to the --warning option. To exclude a type of object, use "noobjectnames". To exclude +objects of a certain type by a regular expression against their name, use "noobjectname=regex". +See the examples for a better understanding.

+

The types of objects that can be filtered are:

+
+
user +=item schema +=item table +=item view +=item index +=item sequence +=item constraint +=item trigger +=item function
+ +
+

The filter option "noposition" prevents verification of the position of +columns within a table.

+

The filter option "nofuncbody" prevents comparison of the bodies of all +functions.

+

You must provide information on how to reach the second database by a connection +parameter ending in the number 2, such as "--dbport2=5543"

+

Example 1: Verify that two databases on hosts star and line are the same:

+
+  check_postgres_same_schema --dbhost=star --dbhost=line
+

Example 2: Same as before, but exclude any triggers with "slony" in their name

+
+  check_postgres_same_schema --dbhost=star --dbhost=line --warning="notrigger=slony"
+

Example 2: Same as before, but also exclude all indexes

+
+  check_postgres_same_schema --dbhost=star --dbhost=line --warning="notrigger=slony noindexes"
+

+

sequence

(symlink: check_postgres_sequence) Checks how much room is left on all sequences in the database. This is measured as the percent of total possible values that have been used for each sequence. @@ -1070,7 +1116,8 @@ section below for more details.

be provided (there are no defaults). Valid units are 'seconds', 'minutes', 'hours', or 'days'. Each may be written singular or abbreviated to just the first letter. If no units are given, the units are assumed to be seconds.

-

This action requires Postgres 8.3 or better.

+

This action requires Postgres 8.0 or better. Additionally, if the version is less than 8.3, +the 'stats_command_string' parameter must be set to 'on'.

Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:

   check_postgres_txn_idle --port=5432 --warning='15 seconds'
@@ -1144,12 +1191,12 @@ while line 4 indicates which database it is.

wal_files

-

(symlink: check_postgres_wal_files) Checks how many WAL files exist in the pg_xlog directory, which is found +

(symlink: check_postgres_wal_files) Checks how many WAL files exist in the pg_xlog directory, which is found off of your data_directory, sometimes as a symlink to another physical disk for performance reasons. This action must be run as a superuser, in order to access the -contents of the pg_xlog directory. The minimum version to use this action is +contents of the pg_xlog directory. The minimum version to use this action is Postgres 8.1. The --warning and --critical options are simply the number of -files in the pg_xlog directory. What number to set this to will vary, but a general +files in the pg_xlog directory. What number to set this to will vary, but a general guideline is to put a number slightly higher than what is normally there, to catch problems early.

Normally, WAL files are closed and then re-used, but a long-running open @@ -1235,21 +1282,21 @@ An --includeuser option always trumps an --excludeuser option. give each option more than once for multiple users, or you can give a comma-separated list. The actions that currently use these options are:

-
database_size
+
database_size
-
last_analyze
+
last_analyze
-
last_autoanalyze
+
last_autoanalyze
-
last_vacuum
+
last_vacuum
-
last_autovacuum
+
last_autovacuum
-
query_time
+
query_time
-
relation_size
+
relation_size
-
txn_time
+
txn_time

Examples:

@@ -1289,15 +1336,15 @@ instead of symlinks, so that the plugin only gets compiled one time.

DEPENDENCIES

Access to a working version of psql, and the following very standard Perl modules:

-
Cwd
+
Cwd
-
Getopt::Long
+
Getopt::Long
-
File::Basename
+
File::Basename
-
File::Temp
+
File::Temp
-
Time::HiRes (if $opt{showtime} is set to true, which is the default)
+
Time::HiRes (if $opt{showtime} is set to true, which is the default)

The settings_checksum action requires the Digest::MD5 module.

@@ -1331,13 +1378,26 @@ feature requests, and commit notices, send email to HISTORY

Items not specifically attributed are by Greg Sabino Mullane.

-
Version 2.8.1 (May, 15 2009)
+
Version 2.9.1 (June 2009)
+ +
+
+  Fix for multiple databases with the check_bloat action (Mark Kirkwood)
+  Tests for same_schema, other minor test fixes (Jeff Boes)
+
+
Version 2.9.0 (May 28, 2009)
+ +
+
+  Added the same_schema action (Greg)
+
+
Version 2.8.1 (May 15, 2009)
   Added timeout via statement_timeout in addition to perl alarm (Greg)
-
Version 2.8.0 (May 4, 2009)
+
Version 2.8.0 (May 4, 2009)
@@ -1363,14 +1423,14 @@ feature requests, and commit notices, send email to Version 2.7.3 (February 10, 2009)
+
Version 2.7.3 (February 10, 2009)
   Make the sequence action check if sequence being used for a int4 column and
   react appropriately. (Michael Glaesemann)
-
Version 2.7.2 (February 9, 2009)
+
Version 2.7.2 (February 9, 2009)
@@ -1401,7 +1461,7 @@ feature requests, and commit notices, send email to Version 2.5.4 (January 7, 2009)
+
Version 2.5.4 (January 7, 2009)
@@ -1464,7 +1524,7 @@ feature requests, and commit notices, send email to Version 2.3.10 (October 23, 2008)
+
Version 2.3.10 (October 23, 2008)
@@ -1472,32 +1532,32 @@ feature requests, and commit notices, send email to Version 2.3.9 (October 23, 2008)
+
Version 2.3.9 (October 23, 2008)
  Minor tweak to way we store the default port.
-
Version 2.3.8 (October 21, 2008)
+
Version 2.3.8 (October 21, 2008)
  Allow the default port to be changed easily.
  Allow transform of simple output by MB, GB, etc.
-
Version 2.3.7 (October 14, 2008)
+
Version 2.3.7 (October 14, 2008)
  Allow multiple databases in 'sequence' action. Reported by Christoph Zwerschke.
-
Version 2.3.6 (October 13, 2008)
+
Version 2.3.6 (October 13, 2008)
  Add missing $schema to check_fsm_pages. (Robert Treat)
-
Version 2.3.5 (October 9, 2008)
+
Version 2.3.5 (October 9, 2008)
@@ -1793,7 +1853,7 @@ feature requests, and commit notices, send email to Version 1.0.16 (December 7, 2007)
+
Version 1.0.16 (December 7, 2007)
-- 
2.30.2