2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <sys/types.h>
32 static char *opt_channels
;
33 static char *opt_kernel
;
34 static char *opt_session_name
;
35 static int opt_pid_all
;
36 static int opt_userspace
;
44 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
, 0, OPT_HELP
, 0, 0},
49 {"session", 's', POPT_ARG_STRING
, &opt_session_name
, 0, 0, 0},
50 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
51 {"userspace", 'u', POPT_ARG_NONE
, 0, OPT_USERSPACE
, 0, 0},
52 {"all", 0, POPT_ARG_VAL
, &opt_pid_all
, 1, 0, 0},
53 {"pid", 'p', POPT_ARG_INT
, &opt_pid
, 0, 0, 0},
60 static void usage(FILE *ofp
)
62 fprintf(ofp
, "usage: lttng disable-channel NAME[,NAME2,...] [options]\n");
64 fprintf(ofp
, " -h, --help Show this help\n");
65 fprintf(ofp
, " -s, --session Apply on session name\n");
66 fprintf(ofp
, " -k, --kernel Apply for the kernel tracer\n");
67 fprintf(ofp
, " -u, --userspace Apply for the user-space tracer\n");
68 fprintf(ofp
, " --all If -u, apply on all traceable apps\n");
69 fprintf(ofp
, " -p, --pid PID If -u, apply on a specific PID\n");
74 * Disabling channel using the lttng API.
76 static int disable_channels(char *session_name
)
78 int ret
= CMD_SUCCESS
;
80 struct lttng_domain dom
;
83 dom
.type
= LTTNG_DOMAIN_KERNEL
;
86 handle
= lttng_create_handle(session_name
, &dom
);
92 /* Strip channel list */
93 channel_name
= strtok(opt_channels
, ",");
94 while (channel_name
!= NULL
) {
95 /* Kernel tracer action */
97 DBG("Disabling kernel channel %s", channel_name
);
98 ret
= lttng_disable_channel(handle
, channel_name
);
102 MSG("Kernel channel disabled %s", channel_name
);
104 } else if (opt_userspace
) { /* User-space tracer action */
106 * TODO: Waiting on lttng UST 2.0
109 } else if (opt_pid
!= 0) {
111 ret
= CMD_NOT_IMPLEMENTED
;
114 ERR("Please specify a tracer (--kernel or --userspace)");
119 channel_name
= strtok(NULL
, ",");
123 lttng_destroy_handle(handle
);
129 * cmd_disable_channels
131 * Disable channel to trace session
133 int cmd_disable_channels(int argc
, const char **argv
)
136 static poptContext pc
;
137 char *session_name
= NULL
;
139 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
140 poptReadDefaultConfig(pc
, 0);
142 while ((opt
= poptGetNextOpt(pc
)) != -1) {
158 opt_channels
= (char*) poptGetArg(pc
);
159 if (opt_channels
== NULL
) {
160 ERR("Missing channel name(s).\n");
166 if (!opt_session_name
) {
167 session_name
= get_session_name();
168 if (session_name
== NULL
) {
173 session_name
= opt_session_name
;
176 ret
= disable_channels(session_name
);
This page took 0.044619 seconds and 4 git commands to generate.