From 568bc1be8881a5f500d1b230cf96cf73d9b54ca4 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Sat, 17 May 2008 09:13:40 -0400 Subject: [PATCH] Make the second column to custom_query optional. --- check_postgres.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index 3ead325df..83d730edc 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -2533,8 +2533,10 @@ sub check_custom_query { next; } - while ($db->{slurp} =~ /(\S+)\s+\|\s+(.+)$/gm) { - my ($data, $msg) = ($1,$2); + my $goodrow = 0; + while ($db->{slurp} =~ /(\S+)(?:\s+\|\s+(.+))?$/gm) { + my ($data, $msg) = ($1,$2||''); + $goodrow++; $db->{perf} .= " $msg"; my $gotmatch = 0; if (length $critical) { @@ -2560,6 +2562,10 @@ sub check_custom_query { } } ## end each row returned + + if (!$goodrow) { + add_unknown 'Invalid format returned by custom query'; + } } return; @@ -2852,11 +2858,12 @@ Takes no B<--warning> or B<--critical> options. Runs a custom query of your choosing, and parses the results. The query itself is passed in through the C argument, and should be kept as simple as possible. If at all possible, wrap it in -a view of function to keep things easier to manage. The query should return exactly two columns: the first -is the result that will be checked, and the second is any performance data you want sent. At least one -of warning or critical must be set. What they are set to depends on the type of query you are running. -There are four types of custom_queries that can be run, specified by the C argument. If none -is specified, this action defaults to 'integer'. The four types are: +a view or a function to keep things easier to manage. The query should return one or two columns: the first +is the result that will be checked, and the second is any performance data you want sent. + +At least one warning or critical argument must be specified. What these are set to depends on the type of +query you are running. There are four types of custom_queries that can be run, specified by the C +argument. If none is specified, this action defaults to 'integer'. The four types are: B: Does a simple integer comparison. The first column should be a simple integer, and the warning and -- 2.39.5