Skip to content

Feature/add wal utilization check #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make critical and warning options optional, adjusted POD accordingly
  • Loading branch information
Matthias Schmidt committed Apr 13, 2021
commit 88a45951c005202667c58be94bb2869ac25908ac
26 changes: 20 additions & 6 deletions check_postgres.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9078,7 +9078,13 @@ sub check_wal_amount {
## Valid units: s[econd], m[inute], h[our], d[ay]
## All above may be written as plural as well (e.g. "2 hours")

my ($warning, $critical) = validate_range({type => 'size'});
my ($warning, $critical) = ('', '');

# critical and warning states are optional for this check
#
if (length($opt{warning}) || length($opt{critical})) {
($warning, $critical) = validate_range({type => 'size'});
}

## Determine the time interval - the default is one day
my $interval = $opt{interval} || "1 day";
Expand Down Expand Up @@ -10885,8 +10891,11 @@ =head2 B<wal_amount>
performance reasons. If the I<--lsfunc> option is not used then this action must be run as a superuser, in order to access the
contents of the F<pg_xlog> directory. The minimum version to use this action is
Postgres 8.1. The I<--warning> and I<--critical> options are simply the amount of written
data in the F<pg_xlog> directory. The I<--interval> option is the past time period
in which changes to the WAL files are considered, the default is 24 hours.
data in the F<pg_xlog> directory in I<bytes>, specifying with a unit up to zeta byte is supported.
Both options are optional in case if you just want to monitor the amount.
The I<--interval> option is the past time period in I<seconds>, in which changes to the
WAL files are considered, the units s(econds), m(inutes), h(ours),
d(ays), w(eek)s and y(ears) are supported, the default value for this option is "24 hours".

To avoid connecting as a database superuser, a wrapper function around
C<pg_ls_dir()> should be defined as a superuser with SECURITY DEFINER,
Expand All @@ -10904,10 +10913,15 @@ =head2 B<wal_amount>
GRANT EXECUTE ON FUNCTION ls_xlog_dir() to nagios;
COMMIT;

Example 1: Check that the number of ready WAL files is 10 or less on host "pluto",
using a wrapper function C<ls_xlog_dir> to avoid the need for superuser permissions
Example 1: Check that the size of WAL files written in the last 90 minutes do not exceed 512MB
on host "pluto", using a wrapper function C<ls_xlog_dir> to avoid the need for superuser permissions

check_postgres_wal_amount --host=pluto --critical=512MB --lsfunc=ls_xlog_dir --interval=90m

Example 2: Report the size of WAL files written in the last 5 minutes on the database
connectable on the unix socket "/tmp/cptesting_socket" as user "check_postgres_testing"

check_postgres_wal_amount --host=pluto --critical=512MB --lsfunc=ls_xlog_dir --interval=60M
check_postgres_wal_amount --host=/tmp/cptesting_socket --dbuser=check_postgres_testing --interval=5m

For MRTG output, reports the amount of data written on line 1.

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy