Feature #632
openSeveral commands could benefit from an "all" option
100%
Description
Several commands (destroy
, list
, snapshot
, start
, stop
, view
) could use an -A, --all-sessions
option. The option would obviate the need for a session_name
argument or -s, --session
option (and ignore the default supplied by .lttngrc
) and apply to all sessions known by the session daemon.
This could be used, for example, when several sessions are created and configured, and the user wishes to start/stop them all at once.
The name -A, --all-sessions
preserves the possibility of extending the option to commands that already have an -a, --all
or -a, --all-events
option, such as enable-event
and disable-event
. This would be useful if an event has been defined in several sessions which are already being started/stopped as a group using -A, --all-sessions
.
The -A, --all-sessions
option could even be eventually extended to add-context
, enable-channel
, and disable-channel
.
To give an advanced example, enable-event -A
would enable the event(s) in all sessions where it exists (if started) or can be created (if not started yet); each session where the command causes an error would have the error reported but processing would continue to the next session. The output would be something like:
$ lttng start -A Session sessionnameone: Tracing started for session sessionnameone Session sessionnametwo: Warning: Tracing already started for session sessionnametwo Session sessionnamethree: Tracing started for session sessionnamethree
Besides the usual "unrecognized command or option" errors, return codes would need to be created for the overall outcomes: all session commands succeeded (CMD_SUCCESS), some or all session commands resulted in a warning (CMD_WARNING), etc. This would reflect an ordering of the CMD_* constants in command.h (maybe CMD_SUCCESS < CMD_UNDEFINED < CMD_UNSUPPORTED < CMD_WARNING < CMD_ERROR < CMD_FATAL).