diff options
author | Greg Sabino Mullane | 2011-02-03 17:48:13 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2011-02-03 17:48:13 +0000 |
commit | 0e19ac78a0c09598decba328f841a0269f0bcac9 (patch) | |
tree | 166fbf408a86947c9f5d3f3ffc20865ff30b3682 /check_postgres.pl | |
parent | 879f964645ebeda86c06842cc3b40215e6b97732 (diff) |
Move the archive_ready sub up
Diffstat (limited to 'check_postgres.pl')
-rwxr-xr-x | check_postgres.pl | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index 0b4e2ab0d..b39d473f1 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -2613,6 +2613,47 @@ sub validate_integer_for_time { } ## end of validate_integer_for_time +sub check_archive_ready { + + ## Check on the number of WAL archive with status "ready" + ## Supports: Nagios, MRTG + ## Must run as a superuser + ## Critical and warning are the number of files + ## Example: --critical=10 + + my ($warning, $critical) = validate_range({type => 'integer', leastone => 1}); + + $SQL = q{SELECT count(*) FROM pg_ls_dir('pg_xlog/archive_status') WHERE pg_ls_dir ~ E'^[0-9A-F]{24}.ready$';}; + + my $info = run_command($SQL, {regex => qr[\d] }); + + my $found = 0; + for $db (@{$info->{db}}) { + my $r = $db->{slurp}[0]; + my $numfiles = $r->{count}; + if ($MRTG) { + $stats{$db->{dbname}} = $numfiles; + $statsmsg{$db->{dbname}} = ''; + next; + } + my $msg = qq{$numfiles}; + $db->{perf} .= " '$db->{host}'=$numfiles;$warning;$critical"; + if (length $critical and $numfiles > $critical) { + add_critical $msg; + } + elsif (length $warning and $numfiles > $warning) { + add_warning $msg; + } + else { + add_ok $msg; + } + } + + return; + +} ## end of check_archive_ready + + sub check_autovac_freeze { ## Check how close all databases are to autovacuum_freeze_max_age @@ -7207,46 +7248,6 @@ sub check_wal_files { } ## end of check_wal_files -sub check_archive_ready { - - ## Check on the number of WAL archive with status "ready" - ## Supports: Nagios, MRTG - ## Must run as a superuser - ## Critical and warning are the number of files - ## Example: --critical=10 - - my ($warning, $critical) = validate_range({type => 'integer', leastone => 1}); - - $SQL = q{SELECT count(*) FROM pg_ls_dir('pg_xlog/archive_status') WHERE pg_ls_dir ~ E'^[0-9A-F]{24}.ready$';}; - - my $info = run_command($SQL, {regex => qr[\d] }); - - my $found = 0; - for $db (@{$info->{db}}) { - my $r = $db->{slurp}[0]; - my $numfiles = $r->{count}; - if ($MRTG) { - $stats{$db->{dbname}} = $numfiles; - $statsmsg{$db->{dbname}} = ''; - next; - } - my $msg = qq{$numfiles}; - $db->{perf} .= " '$db->{host}'=$numfiles;$warning;$critical"; - if (length $critical and $numfiles > $critical) { - add_critical $msg; - } - elsif (length $warning and $numfiles > $warning) { - add_warning $msg; - } - else { - add_ok $msg; - } - } - - return; - -} ## end of check_archive_ready - =pod |