Skip to content
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

Add performance data for dbstats action #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
12 changes: 10 additions & 2 deletions check_postgres.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5108,6 +5108,8 @@ sub check_dbstats {
## Supports: Cacti
## Assumes psql and target are the same version for the 8.3 check

my $msg = '';
my $perfdata = '';
my ($warning, $critical) = validate_range
({
type => 'cacti',
Expand Down Expand Up @@ -5138,6 +5140,8 @@ sub check_dbstats {
my $dbname = $r->{datname};

next ROW if skip_item($dbname);
# Skip database-wide shared stats entry (see https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-DATABASE-VIEW)
next ROW if $dbname eq '';

## If dbnames were specififed, use those for filtering as well
if (@{$opt{dbname}}) {
Expand All @@ -5150,7 +5154,7 @@ sub check_dbstats {
next ROW unless $keepit;
}

my $msg = '';
$msg .= "Stats for DB $dbname: ";
for my $col (qw/
backends commits rollbacks
read hit
Expand All @@ -5160,11 +5164,15 @@ sub check_dbstats {
$msg .= "$col:";
$msg .= (exists $r->{$col} and length $r->{$col}) ? $r->{$col} : 0;
$msg .= ' ';
$perfdata .= "${dbname}_$col=";
$perfdata .= (exists $r->{$col} and length $r->{$col}) ? $r->{$col} : 0;
$perfdata .= ';;;; ';
}
print "${msg}dbname:$dbname\n";
$msg .= " --- ";
}
}

print "${msg}|${perfdata}\n";
exit 0;

} ## end of check_dbstats
Expand Down