2 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <sys/types.h>
28 #include "../command.h"
31 #include <common/defaults.h>
32 #include <common/sessiond-comm/sessiond-comm.h>
33 #include <common/uri.h>
35 static int opt_kernel
;
36 static int opt_userspace
;
37 static char *opt_session_name
;
39 static struct lttng_handle
*handle
;
46 static struct poptOption long_options
[] = {
47 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
48 {"help", 'h', POPT_ARG_NONE
, NULL
, OPT_HELP
, NULL
, NULL
},
49 {"list-options", 0, POPT_ARG_NONE
, NULL
, OPT_LIST_OPTIONS
, NULL
, NULL
},
50 {"session", 's', POPT_ARG_STRING
, &opt_session_name
, 0, 0, 0},
51 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
52 {"userspace", 'u', POPT_ARG_VAL
, &opt_userspace
, 1, 0, 0},
59 static void usage(FILE *ofp
)
61 fprintf(ofp
, "usage: lttng disable-consumer [-u|-k] [OPTIONS]\n");
63 fprintf(ofp
, "Disable the consumer for a tracing session. This call can\n");
64 fprintf(ofp
, "be done BEFORE tracing has started.\n");
66 fprintf(ofp
, "Options:\n");
67 fprintf(ofp
, " -h, --help Show this help\n");
68 fprintf(ofp
, " --list-options Simple listing of options\n");
69 fprintf(ofp
, " -s, --session NAME Apply to session name\n");
70 fprintf(ofp
, " -k, --kernel Apply to the kernel tracer\n");
71 fprintf(ofp
, " -u, --userspace Apply to the user-space tracer\n");
76 * Disable consumer command.
78 static int disable_consumer(char *session_name
)
80 int ret
= CMD_SUCCESS
;
81 struct lttng_domain dom
;
83 memset(&dom
, 0, sizeof(dom
));
85 /* Create lttng domain */
87 dom
.type
= LTTNG_DOMAIN_KERNEL
;
88 } else if (opt_userspace
) {
89 dom
.type
= LTTNG_DOMAIN_UST
;
91 ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
96 handle
= lttng_create_handle(session_name
, &dom
);
102 ret
= lttng_disable_consumer(handle
);
104 ERR("Disabling consumer for session %s: %s", session_name
,
105 lttng_strerror(ret
));
109 MSG("Consumer disabled successfully");
112 lttng_destroy_handle(handle
);
117 * The 'disable-consumer <options>' first level command
119 * Returns one of the CMD_* result constants.
121 int cmd_disable_consumer(int argc
, const char **argv
)
123 int opt
, ret
= CMD_SUCCESS
;
124 static poptContext pc
;
125 char *session_name
= NULL
;
127 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
128 poptReadDefaultConfig(pc
, 0);
130 while ((opt
= poptGetNextOpt(pc
)) != -1) {
135 case OPT_LIST_OPTIONS
:
136 list_cmd_options(stdout
, long_options
);
145 /* Get session name */
146 if (!opt_session_name
) {
147 session_name
= get_session_name();
148 if (session_name
== NULL
) {
153 session_name
= opt_session_name
;
156 ret
= disable_consumer(session_name
);
159 if (opt_session_name
== NULL
) {
This page took 0.074463 seconds and 4 git commands to generate.