LP #1125665: pt-stalk --no-stalk silently clobbers other options, acts magically

Description

**Reported in Launchpad by Ryan Lowe last update 22-03-2013 22:57:32

pt-stalk exists "because no more iterations" incorrectly:

pi@raspberrypi ~ $ ./pt-stalk --version
pt-stalk 2.1.9

pi@raspberrypi ~ $ PTDEBUG=1 ./pt-stalk --collect --no-stalk --interval=1 --iterations=3600
2013_02_14_15_23_00 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 --plugin=
2013_02_14_15_23_00 Not running with root privileges!
2013_02_14_15_23_00 Not stalking; collect triggered immediately
2013_02_14_15_23_00 Collect 1 triggered
2013_02_14_15_23_00 Collect 1 PID 30319
2013_02_14_15_23_00 Collect 1 done
2013_02_14_15_23_01 Waiting up to 90 seconds for collectors to finish...
2013_02_14_15_24_33 Killing collector 30319
2013_02_14_15_24_33 Exiting because no more iterations
2013_02_14_15_24_33 ./pt-stalk exit status 0

Note that it's --iterations=3600 in my command, but --iterations=1 in what was invoked. I'm confused.

Environment

None

Smart Checklist

Activity

Show:

lpjirasync January 24, 2018 at 4:06 PM

**Comment from Launchpad by: Daniel Nichter on: 04-03-2013 23:32:22

Ok, I decided to change this a little. The 2.1 way of --no-stalk is magical, and magic usually doesn't turn out well. 2.1 --no-stalk clobbers these options:

OPT_ITERATIONS=1
OPT_CYCLES=0
OPT_SLEEP=0
OPT_INTERVAL=0

There's no way to override that. So 2.1 --no-stalk is magically "collect once and exit", rather than simply being "don't stalk, just collect." as one would more reasonably expect, I think.

So in 2.2, i.e. in the attached branch, I have made --no-stalk do just that, and all other options* are left-as-is. *Not all options: --cycles is disabled because if we're not stalking then we're not waiting for it to be true. And --pid, --log, and --daemonize still have no affect. This is all documented.

These changes mean that now to collect once and exit, you must: --no-stalk --iterations 1. Also, as the docs state: " You probably also want to specify values for L<"--interval">, L<"--iterations">, and L<"--sleep">." This is because the tool uses its defaults, so simply doing --no-stalk will result in 60s collections every 5 minutes forever.

lpjirasync January 24, 2018 at 4:06 PM

**Comment from Launchpad by: Daniel Nichter on: 01-03-2013 22:45:54

We can use Ryan's branch that I just linked to make further changes.

lpjirasync January 24, 2018 at 4:06 PM

**Comment from Launchpad by: Daniel Nichter on: 01-03-2013 22:44:32

It's not a bug, we just need to update the docs which currently only say:

"""
If this option is negate, L<"--daemonize">, L<"--log">, L<"--pid">, and other
stalking-related options have no effect; the tool simply collects diagnostic
data and exits.
"""

lpjirasync January 24, 2018 at 4:06 PM

**Comment from Launchpad by: Daniel Nichter on: 15-02-2013 16:24:00

I think --no-stalk is the reason: iirc, that option causes the tool to collect once (hence --iterations=1) and exit.

Done

Details

Assignee

Reporter

Priority

Smart Checklist

Created January 24, 2018 at 4:06 PM
Updated January 24, 2018 at 4:06 PM
Resolved January 24, 2018 at 4:06 PM