pt-stalk --nostalk does not work

Bug #954990 reported by Jay Janssen
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Low
Daniel Nichter
2.0
Won't Fix
Undecided
Unassigned
2.1
Fix Released
Low
Daniel Nichter

Bug Description

~/percona/percona-toolkit-2.0.4# ~/bin/pt-stalk --version
pt-stalk 2.0.4
~/percona/percona-toolkit-2.0.4# ~/bin/pt-stalk --nostalk
Unknown option: --nostalk

Usage: pt-stalk [OPTIONS] [-- MYSQL OPTIONS]

For more information, 'man pt-stalk' or 'perldoc /root/bin/pt-stalk'.

Quoth the changelog:
Changelog for Percona Toolkit

v2.0.4 released 2012-03-07
  ...
  * Added --[no]stalk to pt-stalk (bug 932331)

Related branches

Revision history for this message
Jay Janssen (jay-janssen) wrote :

Looks like --no-stalk works, maybe just need a doc update?

Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

I think it is rather standard for negatable options to accept both --no-stalk and --nostalk forms, so perhaps we should keep this as a real bug and see whether it's feasible to change the option-parsing library. The Perl tools accept both forms, as I recall.

Changed in percona-toolkit:
status: New → Confirmed
importance: Undecided → Low
tags: added: option-parsing pt-stalk
Revision history for this message
Jay Janssen (jay-janssen) wrote :

since --stalk is the default, should --no-stalk be documented better in the --help?

Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

Currently,

  --stalk Watch the server and wait for the trigger to occur.

I believe it would be better to have

  --[no]stalk Watch the server and wait for the trigger to occur.

So that's another bug. Finally,

  --stalk yes

But to match the Perl tools, a boolean option should be shown as TRUE or FALSE.

Revision history for this message
Jay Janssen (jay-janssen) wrote :

--[no]stalk Watch the server and wait for the trigger for to occur. If FALSE (or --nostalk), does a collection immediately without stalking.

Some derivation of the last sentence is what I think would be good to include.

Revision history for this message
Bill Karwin (bill-karwin) wrote :

The current version of pt-stalk (2.1.1) usage match neither the current documentation nor the suggested usage Baron described above.

$ ./pt-stalk --version
pt-stalk 2.1.1

$ ./pt-stalk --help
...
Command line options:
  --stalk Watch the server and wait for the trigger to occur.
...
Options and values after processing arguments:
  --stalk yes
...

$ ./pt-stalk --stalk no --dest ~/collected --pid ./pt-stalk.pid
2012_04_15_09_21_20 Starting ./pt-stalk --function=status --variable=Threads_running --threshold=25 --match= --cycles=5 --interval=1 --iterations= --run-time=30 --sleep=300 --dest=/home/bill/collected --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=./pt-stalk.pid
2012_04_15_09_21_20 Not running with root privileges!
2012_04_15_09_21_20 Check results: Threads_running=1, matched=no, cycles_true=0
2012_04_15_09_21_21 Check results: Threads_running=1, matched=no, cycles_true=0
...

$ ./pt-stalk --stalk false --dest ~/collected --pid ./pt-stalk.pid
2012_04_15_09_21_41 Starting ./pt-stalk --function=status --variable=Threads_running --threshold=25 --match= --cycles=5 --interval=1 --iterations= --run-time=30 --sleep=300 --dest=/home/bill/collected --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=./pt-stalk.pid
2012_04_15_09_21_41 Not running with root privileges!
2012_04_15_09_21_41 Check results: Threads_running=1, matched=no, cycles_true=0
2012_04_15_09_21_42 Check results: Threads_running=1, matched=no, cycles_true=0
...

$ ./pt-stalk --nostalk --dest ~/collected --pid ./pt-stalk.pid
Unknown option: --nostalk

$ ./pt-stalk --no-stalk --dest ~/collected --pid ./pt-stalk.pid
2012_04_15_09_22_16 Starting ./pt-stalk --function=status --variable=Threads_running --threshold=25 --match= --cycles=0 --interval=0 --iterations=1 --run-time=30 --sleep=0 --dest=/home/bill/collected --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=./pt-stalk.pid
2012_04_15_09_22_16 Not running with root privileges!
2012_04_15_09_22_16 Not stalking; collect triggered immediately
...

As shown above, I found through experimentation that the --stalk option can be negated ONLY with "--no-stalk", but this is not clear from the documentation. I suggest the following perldoc rewrite to make it more clear:

...
--stalk
default: yes; negatable: yes

Watch the server and wait for the trigger to occur.

You can make the tool gather one sample of diagnostic data immediately by negating this option in the form "--no-stalk". This is useful for example if a problem is currently happening, but pt-stalk is not stalking. If you negate stalking, "--daemonize", "--log", "--pid", and other stalking-related options have no effect; the tool simply collects diagnostic data once and exits. The tool still respects safeguard options, such as "--disk-bytes-free" and "--disk-pct-free".

See also "--collect".
...

Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

It's probably best if we fix the option-parsing library so that negatable options can't take a value. I still have the complaint that the tool prints out "yes" and "no" instead of matching the Perl tools' TRUE/FALSE.

Revision history for this message
Olivier Doucet (odoucet) wrote :

I also have problems with no-stalk but different error (maybe this is a different bug ?) :

./pt-stalk --no-stalk
2012_05_01_16_09_23 Starting ./pt-stalk --function=status --variable=Threads_running --threshold=25 --match= --cycles=0 --interval=0 --iterations=1 --run-time=30 --sleep=0 --dest=/var/lib/pt-stalk --prefix= --notify-by-email= --log=/var/log/pt-stalk.log --pid=/var/run/pt-stalk.pid
2012_05_01_16_09_23 Not stalking; collect triggered immediately
2012_05_01_16_09_23 Collect triggered
./pt-stalk: line 524: 100 - : syntax error: operand expected (error token is " ")

./pt-stalk --version
pt-stalk 2.1.1
perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi

Changed in percona-toolkit:
milestone: none → 2.1.3
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

The --help yes/no is now fixed: it shows TRUE/FALSE like the Perl tools:

  --config (No value)
  --help TRUE
  --read-samples (No value)
  --save-samples (No value)
  --sleep 5
  --summarize-mounts TRUE
  --summarize-network TRUE
  --summarize-processes TRUE
  --version FALSE

Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

--nofoo now works like --no-foo.

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-774

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.