From 289f66c43d4c18d4c9731aa7ecc446a4ac2b28f9 Mon Sep 17 00:00:00 2001 From: Napsty Date: Wed, 12 Jul 2023 13:55:38 +0200 Subject: [PATCH] Add performance data for dbstats action --- check_postgres.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index b2dd92c..cc7745f 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -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', @@ -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}}) { @@ -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 @@ -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 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