@@ -1478,7 +1478,7 @@ sub finishup {
1478
1478
check_fsm_relations() if $action eq ' fsm_relations' ;
1479
1479
1480
1480
# # Spit back info from the pg_stat_database table. Cacti only
1481
- show_dbstats () if $action eq ' dbstats' ;
1481
+ check_dbstats () if $action eq ' dbstats' ;
1482
1482
1483
1483
# # Check how long since the last checkpoint
1484
1484
check_checkpoint() if $action eq ' checkpoint' ;
@@ -3263,7 +3263,7 @@ sub check_database_size {
3263
3263
} # # end of check_database_size
3264
3264
3265
3265
3266
- sub show_dbstats {
3266
+ sub check_dbstats {
3267
3267
3268
3268
# # Returns values from the pg_stat_database view
3269
3269
# # Supports: Cacti
@@ -3328,7 +3328,7 @@ sub show_dbstats {
3328
3328
3329
3329
exit 0;
3330
3330
3331
- } # # end of show_dbstats
3331
+ } # # end of check_dbstats
3332
3332
3333
3333
3334
3334
sub check_disabled_triggers {
@@ -4143,7 +4143,7 @@ sub check_logfile {
4143
4143
} # # end of check_logfile
4144
4144
4145
4145
4146
- sub check_new_version {
4146
+ sub find_new_version {
4147
4147
4148
4148
# # Check for newer versions of some program
4149
4149
@@ -4250,15 +4250,15 @@ sub check_new_version {
4250
4250
add_unknown msg(' new-ver-tt' , $program , $lversion , $cversion );
4251
4251
return ;
4252
4252
4253
- } # # end of check_new_version
4253
+ } # # end of find_new_version
4254
4254
4255
4255
4256
4256
sub check_new_version_bc {
4257
4257
4258
4258
# # Check if a newer version of Bucardo is available
4259
4259
4260
4260
my $url = ' http://bucardo.org/bucardo/latest_version.txt' ;
4261
- check_new_version (' Bucardo' , ' bucardo_ctl' , $url );
4261
+ find_new_version (' Bucardo' , ' bucardo_ctl' , $url );
4262
4262
4263
4263
return ;
4264
4264
@@ -4270,7 +4270,7 @@ sub check_new_version_cp {
4270
4270
# # Check if a new version of check_postgres.pl is available
4271
4271
4272
4272
my $url = ' http://bucardo.org/check_postgres/latest_version.txt' ;
4273
- check_new_version (' check_postgres' , $VERSION , $url );
4273
+ find_new_version (' check_postgres' , $VERSION , $url );
4274
4274
4275
4275
return ;
4276
4276
@@ -4296,7 +4296,7 @@ sub check_new_version_pg {
4296
4296
return ;
4297
4297
}
4298
4298
4299
- check_new_version (' Postgres' , $lversion , $url );
4299
+ find_new_version (' Postgres' , $lversion , $url );
4300
4300
4301
4301
return ;
4302
4302
@@ -4308,14 +4308,14 @@ sub check_new_version_tnm {
4308
4308
# # Check if a new version of tail_n_mail is available
4309
4309
4310
4310
my $url = ' http://bucardo.org/tail_n_mail/latest_version.txt' ;
4311
- check_new_version (' tail_n_mail' , ' tail_n_mail' , $url );
4311
+ find_new_version (' tail_n_mail' , ' tail_n_mail' , $url );
4312
4312
4313
4313
return ;
4314
4314
4315
4315
} # # end of check_new_version_tnm
4316
4316
4317
4317
4318
- sub check_pg_stat_activity {
4318
+ sub find_pg_stat_activity {
4319
4319
4320
4320
# # Common function to run various actions against the pg_stat_activity view
4321
4321
# # Actions: txn_idle, txn_time, query_time
@@ -4462,7 +4462,7 @@ sub check_pg_stat_activity {
4462
4462
4463
4463
return ;
4464
4464
4465
- } # # end of check_pg_stat_activity
4465
+ } # # end of find_pg_stat_activity
4466
4466
4467
4467
4468
4468
sub check_pgbouncer_checksum {
@@ -4526,7 +4526,9 @@ sub check_pgbouncer_checksum {
4526
4526
4527
4527
} # # end of check_pgbouncer_checksum
4528
4528
4529
+
4529
4530
sub check_pgb_pool {
4531
+
4530
4532
# Check various bits of the pgbouncer SHOW POOLS ouptut
4531
4533
my $stat = shift ;
4532
4534
my ($warning , $critical ) = validate_range({type => ' positive integer' });
@@ -4560,6 +4562,7 @@ sub check_pgb_pool {
4560
4562
4561
4563
} # # end of check_pgb_pool
4562
4564
4565
+
4563
4566
sub check_prepared_txns {
4564
4567
4565
4568
# # Checks age of prepared transactions
@@ -4704,7 +4707,7 @@ sub check_query_time {
4704
4707
4705
4708
# # Check the length of running queries
4706
4709
4707
- return check_pg_stat_activity (
4710
+ return find_pg_stat_activity (
4708
4711
{
4709
4712
default_warning => ' 2 minutes' ,
4710
4713
default_critical => ' 5 minutes' ,
@@ -7936,16 +7939,16 @@ =head2 B<relation_size>
7936
7939
For MRTG output, returns the size in bytes of the largest relation, and the name of the database
7937
7940
and relation as the fourth line.
7938
7941
7939
- =head2 B<last_vacuum >
7940
-
7941
- =head2 B<last_autovacuum >
7942
-
7943
7942
=head2 B<last_analyze >
7944
7943
7944
+ =head2 B<last_vacuum >
7945
+
7945
7946
=head2 B<last_autoanalyze >
7946
7947
7947
- (symlinks: C<check_postgres_last_vacuum > , C<check_postgres_last_autovacuum > , C<check_postgres_last_analyze > , and
7948
- C<check_postgres_last_autoanalyze > )
7948
+ =head2 B<last_autovacuum >
7949
+
7950
+ (symlinks: C<check_postgres_last_analyze > , C<check_postgres_last_vacuum > ,
7951
+ C<check_postgres_last_autoanalyze > , and C<check_postgres_last_autovacuum > )
7949
7952
Checks how long it has been since vacuum (or analyze) was last run on each
7950
7953
table in one or more databases. Use of these actions requires that the target
7951
7954
database is version 8.3 or greater, or that the version is 8.2 and the
@@ -8361,6 +8364,30 @@ =head2 B<sequence>
8361
8364
8362
8365
check_postgres_sequence --dbport=5432 --critical=50% --include=orders_id_seq
8363
8366
8367
+ =head2 B<settings_checksum >
8368
+
8369
+ (C<symlink: check_postgres_settings_checksum > ) Checks that all the Postgres settings are the same as last time you checked.
8370
+ This is done by generating a checksum of a sorted list of setting names and
8371
+ their values. Note that different users in the same database may have different
8372
+ checksums, due to ALTER USER usage, and due to the fact that superusers see more
8373
+ settings than ordinary users. Either the I<--warning > or the I<--critical > option
8374
+ should be given, but not both. The value of each one is the checksum, a
8375
+ 32-character hexadecimal value. You can run with the special C<--critical=0 > option
8376
+ to find out an existing checksum.
8377
+
8378
+ This action requires the Digest::MD5 module.
8379
+
8380
+ Example 1: Find the initial checksum for the database on port 5555 using the default user (usually postgres)
8381
+
8382
+ check_postgres_settings_checksum --port=5555 --critical=0
8383
+
8384
+ Example 2: Make sure no settings have changed and warn if so, using the checksum from above.
8385
+
8386
+ check_postgres_settings_checksum --port=5555 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
8387
+
8388
+ For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A
8389
+ checksum must be provided as the C<--mrtg > argument. The fourth line always gives the
8390
+ current checksum.
8364
8391
8365
8392
=head2 B<slony_status >
8366
8393
@@ -8380,35 +8407,22 @@ =head2 B<slony_status>
8380
8407
8381
8408
check_postgres_slony_status --schema=_slony --critical=600
8382
8409
8410
+ =head2 B<timesync >
8383
8411
8384
- =head2 B<txn_time >
8385
-
8386
-
8387
- (C<symlink: check_postgres_txn_time > ) Checks the length of open transactions on one or more databases.
8388
- There is no need to run this command more than once per database cluster.
8389
- Databases can be filtered by use of the
8390
- I<--include > and I<--exclude > options. See the L</"BASIC FILTERING"> section
8391
- for more details. The owner of the transaction can also be filtered, by use of
8392
- the I<--includeuser > and I<--excludeuser > options.
8393
- See the L</"USER NAME FILTERING"> section for more details.
8394
-
8395
- The values or the I<--warning > and I<--critical > options are units of time, and
8396
- must be provided (no default). Valid units are 'seconds', 'minutes', 'hours',
8397
- or 'days'. Each may be written singular or abbreviated to just the first letter.
8398
- If no units are given, the units are assumed to be seconds.
8399
-
8400
- This action requires Postgres 8.3 or better.
8401
-
8402
- Example 1: Give a critical if any transaction has been open for more than 10 minutes:
8412
+ (C<symlink: check_postgres_timesync > ) Compares the local system time with the time reported by one or more databases.
8413
+ The I<--warning > and I<--critical > options represent the number of seconds between
8414
+ the two systems before an alert is given. If neither is specified, the default values
8415
+ are used, which are '2' and '5'. The warning value cannot be greater than the critical
8416
+ value. Due to the non-exact nature of this test, values of '0' or '1' are not recommended.
8403
8417
8404
- check_postgres_txn_time --port=5432 --critical='10 minutes'
8418
+ The string returned shows the time difference as well as the time on each side written out.
8405
8419
8406
- Example 1: Warn if user 'warehouse' has a transaction open over 30 seconds
8420
+ Example 1: Check that databases on hosts ankh, morpork, and klatch are no more than 3 seconds off from the local time:
8407
8421
8408
- check_postgres_txn_time --port-5432 --warning=30s --includeuser=warehouse
8422
+ check_postgres_timesync --host=ankh,morpork,klatch --critical=3
8409
8423
8410
- For MRTG output, returns the maximum time in seconds a transaction has been open on the
8411
- first line . The fourth line gives the name of the database.
8424
+ For MRTG output, returns one the first line the number of seconds difference between the local
8425
+ time and the database time . The fourth line returns the name of the database.
8412
8426
8413
8427
=head2 B<txn_idle >
8414
8428
@@ -8432,58 +8446,33 @@ =head2 B<txn_idle>
8432
8446
For MRTG output, returns the time in seconds the longest idle transaction has been running. The fourth
8433
8447
line returns the name of the database.
8434
8448
8435
- =head2 B<rebuild_symlinks >
8436
-
8437
- =head2 B<rebuild_symlinks_force >
8438
-
8439
- This action requires no other arguments, and does not connect to any databases,
8440
- but simply creates symlinks in the current directory for each action, in the form
8441
- B<check_postgres_E<lt> action_nameE<gt> >.
8442
- If the file already exists, it will not be overwritten. If the action is rebuild_symlinks_force,
8443
- then symlinks will be overwritten. The option --symlinks is a shorter way of saying
8444
- --action=rebuild_symlinks
8445
-
8446
- =head2 B<settings_checksum >
8447
-
8448
- (C<symlink: check_postgres_settings_checksum > ) Checks that all the Postgres settings are the same as last time you checked.
8449
- This is done by generating a checksum of a sorted list of setting names and
8450
- their values. Note that different users in the same database may have different
8451
- checksums, due to ALTER USER usage, and due to the fact that superusers see more
8452
- settings than ordinary users. Either the I<--warning > or the I<--critical > option
8453
- should be given, but not both. The value of each one is the checksum, a
8454
- 32-character hexadecimal value. You can run with the special C<--critical=0 > option
8455
- to find out an existing checksum.
8456
-
8457
- This action requires the Digest::MD5 module.
8458
-
8459
- Example 1: Find the initial checksum for the database on port 5555 using the default user (usually postgres)
8460
-
8461
- check_postgres_settings_checksum --port=5555 --critical=0
8462
-
8463
- Example 2: Make sure no settings have changed and warn if so, using the checksum from above.
8449
+ =head2 B<txn_time >
8464
8450
8465
- check_postgres_settings_checksum --port=5555 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
8451
+ (C<symlink: check_postgres_txn_time > ) Checks the length of open transactions on one or more databases.
8452
+ There is no need to run this command more than once per database cluster.
8453
+ Databases can be filtered by use of the
8454
+ I<--include > and I<--exclude > options. See the L</"BASIC FILTERING"> section
8455
+ for more details. The owner of the transaction can also be filtered, by use of
8456
+ the I<--includeuser > and I<--excludeuser > options.
8457
+ See the L</"USER NAME FILTERING"> section for more details.
8466
8458
8467
- For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A
8468
- checksum must be provided as the C<--mrtg > argument. The fourth line always gives the
8469
- current checksum.
8459
+ The values or the I<--warning > and I<--critical > options are units of time, and
8460
+ must be provided (no default). Valid units are 'seconds', 'minutes', 'hours',
8461
+ or 'days'. Each may be written singular or abbreviated to just the first letter.
8462
+ If no units are given, the units are assumed to be seconds.
8470
8463
8471
- =head2 B< timesync >
8464
+ This action requires Postgres 8.3 or better.
8472
8465
8473
- (C<symlink: check_postgres_timesync > ) Compares the local system time with the time reported by one or more databases.
8474
- The I<--warning > and I<--critical > options represent the number of seconds between
8475
- the two systems before an alert is given. If neither is specified, the default values
8476
- are used, which are '2' and '5'. The warning value cannot be greater than the critical
8477
- value. Due to the non-exact nature of this test, values of '0' or '1' are not recommended.
8466
+ Example 1: Give a critical if any transaction has been open for more than 10 minutes:
8478
8467
8479
- The string returned shows the time difference as well as the time on each side written out.
8468
+ check_postgres_txn_time --port=5432 --critical='10 minutes'
8480
8469
8481
- Example 1: Check that databases on hosts ankh, morpork, and klatch are no more than 3 seconds off from the local time:
8470
+ Example 1: Warn if user 'warehouse' has a transaction open over 30 seconds
8482
8471
8483
- check_postgres_timesync --host=ankh,morpork,klatch --critical=3
8472
+ check_postgres_txn_time --port-5432 --warning=30s --includeuser=warehouse
8484
8473
8485
- For MRTG output, returns one the first line the number of seconds difference between the local
8486
- time and the database time . The fourth line returns the name of the database.
8474
+ For MRTG output, returns the maximum time in seconds a transaction has been open on the
8475
+ first line . The fourth line gives the name of the database.
8487
8476
8488
8477
=head2 B<txn_wraparound >
8489
8478
@@ -8507,6 +8496,24 @@ =head2 B<txn_wraparound>
8507
8496
For MRTG output, returns the highest number of transactions for all databases on line one,
8508
8497
while line 4 indicates which database it is.
8509
8498
8499
+ =head2 B<version >
8500
+
8501
+ (C<symlink: check_postgres_version > ) Checks that the required version of Postgres is running. The
8502
+ I<--warning > and I<--critical > options (only one is required) must be of
8503
+ the format B<X.Y > or B<X.Y.Z > where B<X > is the major version number,
8504
+ B<Y > is the minor version number, and B<Z > is the revision.
8505
+
8506
+ Example 1: Give a warning if the database on port 5678 is not version 8.4.10:
8507
+
8508
+ check_postgres_version --port=5678 -w=8.4.10
8509
+
8510
+ Example 2: Give a warning if any databases on hosts valley,grain, or sunshine is not 8.3:
8511
+
8512
+ check_postgres_version -H valley,grain,sunshine --critical=8.3
8513
+
8514
+ For MRTG output, reports a 1 or a 0 indicating success or failure on the first line. The
8515
+ fourth line indicates the current version. The version must be provided via the C<--mrtg > option.
8516
+
8510
8517
=head2 B<wal_files >
8511
8518
8512
8519
(C<symlink: check_postgres_wal_files > ) Checks how many WAL files exist in the F<pg_xlog> directory, which is found
@@ -8549,23 +8556,16 @@ =head2 B<archive_ready>
8549
8556
8550
8557
For MRTG output, reports the number of ready WAL files on line 1.
8551
8558
8552
- =head2 B<version >
8553
-
8554
- (C<symlink: check_postgres_version > ) Checks that the required version of Postgres is running. The
8555
- I<--warning > and I<--critical > options (only one is required) must be of
8556
- the format B<X.Y > or B<X.Y.Z > where B<X > is the major version number,
8557
- B<Y > is the minor version number, and B<Z > is the revision.
8558
-
8559
- Example 1: Give a warning if the database on port 5678 is not version 8.4.10:
8560
-
8561
- check_postgres_version --port=5678 -w=8.4.10
8562
-
8563
- Example 2: Give a warning if any databases on hosts valley,grain, or sunshine is not 8.3:
8559
+ =head2 B<rebuild_symlinks >
8564
8560
8565
- check_postgres_version -H valley,grain,sunshine --critical=8.3
8561
+ =head2 B< rebuild_symlinks_force >
8566
8562
8567
- For MRTG output, reports a 1 or a 0 indicating success or failure on the first line. The
8568
- fourth line indicates the current version. The version must be provided via the C<--mrtg > option.
8563
+ This action requires no other arguments, and does not connect to any databases,
8564
+ but simply creates symlinks in the current directory for each action, in the form
8565
+ B<check_postgres_E<lt> action_nameE<gt> >.
8566
+ If the file already exists, it will not be overwritten. If the action is rebuild_symlinks_force,
8567
+ then symlinks will be overwritten. The option --symlinks is a shorter way of saying
8568
+ --action=rebuild_symlinks
8569
8569
8570
8570
=head1 BASIC FILTERING
8571
8571
0 commit comments