mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
fixes pt-stalk not being to handle non-integers - issue 1335322
This commit is contained in:
@@ -1245,13 +1245,12 @@ stalk() {
|
|||||||
if [ "$OPT_STALK" ]; then
|
if [ "$OPT_STALK" ]; then
|
||||||
local value=$($TRIGGER_FUNCTION $OPT_VARIABLE)
|
local value=$($TRIGGER_FUNCTION $OPT_VARIABLE)
|
||||||
local trg_exit_status=$?
|
local trg_exit_status=$?
|
||||||
|
|
||||||
if [ -z "$value" ]; then
|
if [ -z "$value" ]; then
|
||||||
# No value. Maybe we failed to connect to MySQL?
|
# No value. Maybe we failed to connect to MySQL?
|
||||||
warn "Detected value is empty; something failed? Trigger exit status: $trg_exit_status"
|
warn "Detected value is empty; something failed? Trigger exit status: $trg_exit_status"
|
||||||
matched=""
|
matched=""
|
||||||
cycles_true=0
|
cycles_true=0
|
||||||
elif [ $value -gt $OPT_THRESHOLD ]; then
|
elif (( $(echo "$value $OPT_THRESHOLD" | awk '{print ($1 > $2)}') )); then
|
||||||
matched="yes"
|
matched="yes"
|
||||||
cycles_true=$(($cycles_true + 1))
|
cycles_true=$(($cycles_true + 1))
|
||||||
else
|
else
|
||||||
|
@@ -402,6 +402,27 @@ unlike(
|
|||||||
"Bug 942114: no bad find usage"
|
"Bug 942114: no bad find usage"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
# ###########################################################################
|
||||||
|
# Test that it handles floating point values
|
||||||
|
# ###########################################################################
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
system("$trunk/bin/pt-stalk --daemonize --variable=PI --dest $dest --no-collect --log $log_file --iterations=1 --run-time=2 --cycles=2 --sleep=1 --function $trunk/t/pt-stalk/samples/plugin003.sh --threshold 3.1415 --pid $pid_file --defaults-file=$cnf >$log_file 2>&1");
|
||||||
|
|
||||||
|
|
||||||
|
sleep 5;
|
||||||
|
PerconaTest::kill_program(pid_file => $pid_file);
|
||||||
|
|
||||||
|
$output = `cat $log_file 2>/dev/null`;
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/matched=yes/,
|
||||||
|
"Accepts floating point values as treshold variable"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
5
t/pt-stalk/samples/plugin003.sh
Normal file
5
t/pt-stalk/samples/plugin003.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
trg_plugin() {
|
||||||
|
echo 3.1416
|
||||||
|
}
|
Reference in New Issue
Block a user