pt-stalk fails to correctly detect if --function value is a file or not
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Triaged
|
Undecided
|
Unassigned |
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_
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_
1029 return 0 # success
1030 fi
1031 fi
1032 return 1 # error
1033 }
The problem manifests itself as follows:
[root@ovaistari
/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=
/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
OR
[root@ovaistari
/usr/bin/pt-stalk: line 1021: .: /sbin/status: cannot execute binary file
pt-stalk 2.1.8
Thanks Ovais, we'll look into it.