-
Notifications
You must be signed in to change notification settings - Fork 176
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
custom_query perfdata multi-row output improvements #122
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4398,9 +4398,17 @@ 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. | ||
my $perfname; | ||
|
||
my $perfdata = ''; | ||
if (! defined $db->{perf}){ | ||
$db->{perf} = ''; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initialize perfdata variables before they are compared |
||
my $grandtotal = @{$db->{slurp}}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check the number of rows returned by the custom query There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
@@ -4413,8 +4421,16 @@ sub check_custom_query { | |
} | ||
$goodrow++; | ||
if ($perfname) { | ||
$db->{perf} .= sprintf ' %s=%s;%s;%s', | ||
perfname($perfname), $r->{$perfname}, $warning, $critical; | ||
if ($grandtotal > 1) { | ||
$perfdata = sprintf ' %s=%s;%s;%s', | ||
perfname($r->{$perfname}), $result, $warning, $critical; | ||
if ($perfdata ne $db->{perf}){ | ||
$db->{perf} .= $perfdata; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If more than one row is returned, store the perfdata to a temporary variable and check if it has already been appended to the output. |
||
} | ||
} else { | ||
$db->{perf} .= sprintf ' %s=%s;%s;%s', | ||
perfname($perfname), $r->{$perfname}, $warning, $critical; | ||
} | ||
} | ||
my $gotmatch = 0; | ||
if (! defined $result) { | ||
|
There was a problem hiding this comment.
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