pt-stalk fails to correctly detect if --function value is a file or not

Bug #1097600 reported by Ovais Tariq on 2013-01-09
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to

Bug Description

I am hitting this bug in pt-stalk 2.1.8 but I think it has been present since long. The problem is that I have a binary file /sbin/status present and /sbin is part of $PATH, hence for the default value of --function "status" is thought of as a plugin file by pt-stalk. The relevant part of code that points to this problem is the following:

1017 set_trg_func() {
1018 local func="$1"
1019 if [ -f "$func" ]; then <-- this is the check that causing the problem
1020 # Trigger function is a file with Bash code; source it.
1021 . "$func"
1022 TRIGGER_FUNCTION="trg_plugin"
1023 return 0 # success
1024 else
1025 # Trigger function is name of a built-in function.
1026 func=$(echo "$func" | tr '[:upper:]' '[:lower:]')
1027 if [ "$func" = "status" -o "$func" = "processlist" ]; then
1028 TRIGGER_FUNCTION="trg_$func"
1029 return 0 # success
1030 fi
1031 fi
1032 return 1 # error
1033 }

The problem manifests itself as follows:

[root@ovaistariq-net msb_5_5_16]# pt-stalk --variable Threads_running --threshold 1 -- -umsandbox -pmsandbox -S /tmp/mysql_sandbox5516.sock
/usr/bin/pt-stalk: line 1021: .: /sbin/status: cannot execute binary file
2013_01_09_08_04_32 Starting /usr/bin/pt-stalk --function=status --variable=Threads_running --threshold=1 --match= --cycles=5 --interval=1 --iterations= --run-time=30 --sleep=300 --dest=/var/lib/pt-stalk --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=/var/run/ --plugin=
/usr/bin/pt-stalk: line 1112: trg_plugin: command not found
2013_01_09_08_04_32 Detected value is empty; something failed? Trigger exit status: 0


[root@ovaistariq-net msb_5_5_16]# pt-stalk --version
/usr/bin/pt-stalk: line 1021: .: /sbin/status: cannot execute binary file
pt-stalk 2.1.8

Daniel Nichter (daniel-nichter) wrote :

Thanks Ovais, we'll look into it.

tags: added: percona-28651 pt-stalk
removed: issue-28651
Changed in percona-toolkit:
status: New → Triaged

Percona now uses JIRA for bug reports so this bug report is migrated to:

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers