Skip to content

custom_query perfdata multi-row output improvements #122

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
custom_query perfdata multi-row variable names
Allow custom_query checks with multiple rows of output to populate the second returned column as the perfdata variable name. Pass the result value as the perfdata value. Helpful for count(*) GROUP BY queries.
  • Loading branch information
swanson8r authored Sep 25, 2017
commit 4dd5aa252b718b4492fa1c8d055b76c56986b5b8
17 changes: 13 additions & 4 deletions check_postgres.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4398,9 +4398,13 @@ sub check_custom_query {

my $goodrow = 0;

## The other column tells it the name to use as the perfdata value
## If there is a single row and at least 2 columns,
## the other column tells it the name to use as the perfdata value
## If there are multiple rows and at least 2 columns,
## use the second column value as the perfdata name,
## use the result value as the perfdata value.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments to explain exactly how the query results are processed into performance data

my $perfname;

my $grandtotal = @{$db->{slurp}};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the number of rows returned by the custom query

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get the returned custom query row count

for my $r (@{$db->{slurp}}) {
my $result = $r->{result};
if (! defined $perfname) {
Expand All @@ -4413,8 +4417,13 @@ sub check_custom_query {
}
$goodrow++;
if ($perfname) {
$db->{perf} .= sprintf ' %s=%s;%s;%s',
perfname($perfname), $r->{$perfname}, $warning, $critical;
if ($grandtotal > 1) {
$db->{perf} = sprintf ' %s=%s;%s;%s',
perfname($r->{$perfname}), $result, $warning, $critical;
} else {
$db->{perf} .= sprintf ' %s=%s;%s;%s',
perfname($perfname), $r->{$perfname}, $warning, $critical;
}
}
my $gotmatch = 0;
if (! defined $result) {
Expand Down
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