mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +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
|
||||
local value=$($TRIGGER_FUNCTION $OPT_VARIABLE)
|
||||
local trg_exit_status=$?
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
# No value. Maybe we failed to connect to MySQL?
|
||||
warn "Detected value is empty; something failed? Trigger exit status: $trg_exit_status"
|
||||
matched=""
|
||||
cycles_true=0
|
||||
elif [ $value -gt $OPT_THRESHOLD ]; then
|
||||
elif (( $(echo "$value $OPT_THRESHOLD" | awk '{print ($1 > $2)}') )); then
|
||||
matched="yes"
|
||||
cycles_true=$(($cycles_true + 1))
|
||||
else
|
||||
|
@@ -402,6 +402,27 @@ unlike(
|
||||
"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.
|
||||
# #############################################################################
|
||||
|
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