92cd2a58e4f39b510dae13598765a469b7346e53
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 poptOption long_options
[] = {
45 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
46 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
47 {"session", 's', POPT_ARG_STRING
, &opt_session_name
, 0, 0, 0},
48 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
49 {"userspace", 'u', POPT_ARG_NONE
, 0, OPT_USERSPACE
, 0, 0},
50 {"all", 0, POPT_ARG_VAL
, &opt_pid_all
, 1, 0, 0},
51 {"pid", 'p', POPT_ARG_INT
, &opt_pid
, 0, 0, 0},
58 static void usage(FILE *ofp
)
60 fprintf(ofp
, "usage: lttng disable-channel NAME[,NAME2,...] [options]\n");
62 fprintf(ofp
, " -h, --help Show this help\n");
63 fprintf(ofp
, " -s, --session Apply on session name\n");
64 fprintf(ofp
, " -k, --kernel Apply for the kernel tracer\n");
65 fprintf(ofp
, " -u, --userspace Apply for the user-space tracer\n");
66 fprintf(ofp
, " --all If -u, apply on all traceable apps\n");
67 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(void)
78 int ret
= CMD_SUCCESS
;
80 struct lttng_domain dom
;
82 if (set_session_name(opt_session_name
) < 0) {
88 dom
.type
= LTTNG_DOMAIN_KERNEL
;
91 /* Strip channel list */
92 channel_name
= strtok(opt_channels
, ",");
93 while (channel_name
!= NULL
) {
94 /* Kernel tracer action */
96 DBG("Disabling kernel channel %s", channel_name
);
97 ret
= lttng_disable_channel(&dom
, channel_name
);
101 MSG("Kernel channel disabled %s", channel_name
);
103 } else if (opt_userspace
) { /* User-space tracer action */
105 * TODO: Waiting on lttng UST 2.0
108 } else if (opt_pid
!= 0) {
110 ret
= CMD_NOT_IMPLEMENTED
;
113 ERR("Please specify a tracer (--kernel or --userspace)");
118 channel_name
= strtok(NULL
, ",");
126 * cmd_disable_channels
128 * Disable channel to trace session
130 int cmd_disable_channels(int argc
, const char **argv
)
133 static poptContext pc
;
135 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
136 poptReadDefaultConfig(pc
, 0);
138 while ((opt
= poptGetNextOpt(pc
)) != -1) {
154 opt_channels
= (char*) poptGetArg(pc
);
155 if (opt_channels
== NULL
) {
156 ERR("Missing channel name(s).\n");
162 ret
= disable_channels();
This page took 0.036239 seconds and 3 git commands to generate.