[Check_postgres-commit] [commit 3/4] For query_time action, show the offending database.

check_postgres at bucardo.org check_postgres at bucardo.org
Thu Feb 4 16:33:28 UTC 2010


Committed by Greg Sabino Mullane <greg at endoint.com>

Subject: [commit 3/4] For query_time action, show the offending database.

---
 check_postgres.pl |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/check_postgres.pl b/check_postgres.pl
index 8b75c47..c75ace1 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -3898,10 +3898,14 @@ sub check_query_time {
 
 		$found = 1;
 		my $max = 0;
-		SLURP: while ($db->{slurp} =~ /(.+?)\s+\|\s+(\-?\d+)\s*/gsm) {
+		my $maxdb = '?';
+		SLURP: while ($db->{slurp} =~ /\s*(.+?)\s+\|\s+(\-?\d+)\s*/gsm) {
 			my ($dbname,$current) = ($1, int $2);
 			next SLURP if skip_item($dbname);
-			$max = $current if $current > $max;
+			if ($current > $max) {
+				$max = $current;
+				$maxdb = $dbname;
+			}
 		}
 		if ($MRTG) {
 			$stats{$db->{dbname}} = $max;
@@ -3913,6 +3917,8 @@ sub check_query_time {
 		$db->{perf} .= "$critical" if length $critical;
 
 		my $msg = msg('qtime-msg', $max);
+		$msg .= " db=$maxdb";
+
 		if (length $critical and $max >= $critical) {
 			add_critical $msg;
 		}
-- 
1.6.2.2



More information about the Check_postgres-commit mailing list