X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fmain.c;h=e7c5b6c52d28dfcd1fa80fdf925c8d5317f45b27;hp=ad97a0b9b9871e395ed055860b853b93f55b5e78;hb=a9115ebf4fb48f4a0e81a97384c9ace7df219926;hpb=ce9ee1fb2847b1603c4382c82aef95121f0e3d07 diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index ad97a0b9b..e7c5b6c52 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -98,6 +98,7 @@ enum relay_connection_status { /* command line options */ char *opt_output_path, *opt_working_directory; static int opt_daemon, opt_background, opt_print_version; +enum relay_group_output_by opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_UNKNOWN; /* * We need to wait for listener and live listener threads, as well as @@ -185,6 +186,8 @@ static struct option long_options[] = { { "config", 1, 0, 'f' }, { "version", 0, 0, 'V' }, { "working-directory", 1, 0, 'w', }, + { "group-output-by-session", 0, 0, 's', }, + { "group-output-by-host", 0, 0, 'p', }, { NULL, 0, 0, 0, }, }; @@ -337,6 +340,20 @@ static int set_option(int opt, const char *arg, const char *optname) } } break; + case 's': + if (opt_group_output_by != RELAYD_GROUP_OUTPUT_BY_UNKNOWN) { + ERR("Cannot set --group-output-by-session, another --group-output-by argument is present"); + exit(EXIT_FAILURE); + } + opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_SESSION; + break; + case 'p': + if (opt_group_output_by != RELAYD_GROUP_OUTPUT_BY_UNKNOWN) { + ERR("Cannot set --group-output-by-host, another --group-output-by argument is present"); + exit(EXIT_FAILURE); + } + opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_HOST; + break; default: /* Unknown option or other error. * Error is printed by getopt, just return */ @@ -406,6 +423,23 @@ end: return ret; } +static int parse_env_options(void) +{ + int ret = 0; + char *value = NULL; + + value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV); + if (value) { + opt_working_directory = strdup(value); + if (!opt_working_directory) { + ERR("Failed to allocate working directory string (\"%s\")", + value); + ret = -1; + } + } + return ret; +} + static int set_options(int argc, char **argv) { int c, ret = 0, option_index = 0, retval = 0; @@ -524,6 +558,10 @@ static int set_options(int argc, char **argv) } } + if (opt_group_output_by == RELAYD_GROUP_OUTPUT_BY_UNKNOWN) { + opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_HOST; + } + exit: free(optstring); return retval; @@ -3686,7 +3724,17 @@ int main(int argc, char **argv) int ret = 0, retval = 0; void *status; - /* Parse arguments */ + /* Parse environment variables */ + ret = parse_env_options(); + if (ret) { + retval = -1; + goto exit_options; + } + + /* + * Parse arguments. + * Command line arguments overwrite environment. + */ progname = argv[0]; if (set_options(argc, argv)) { retval = -1;