Very, very, incredibly useful for multi-node traces.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fprintf(fp, " none, all, scope, header, (context OR ctx)\n");
fprintf(fp, " (default: payload,context)\n");
fprintf(fp, " -f, --fields name1<,name2,...> Print additional fields:\n");
- fprintf(fp, " all, trace, trace:domain, trace:procname,\n");
- fprintf(fp, " trace:vpid, loglevel.\n");
+ fprintf(fp, " all, trace, trace:hostname, trace:domain,\n");
+ fprintf(fp, " trace:procname, trace:vpid, loglevel.\n");
fprintf(fp, " --clock-cycles Timestamp in cycles\n");
fprintf(fp, " --clock-offset seconds Clock offset in seconds\n");
fprintf(fp, " --clock-seconds Print the timestamps as [sec.ns]\n");
opt_trace_procname_field = 1;
else if (!strcmp(str, "trace:vpid"))
opt_trace_vpid_field = 1;
+ else if (!strcmp(str, "trace:hostname"))
+ opt_trace_hostname_field = 1;
else if (!strcmp(str, "loglevel"))
opt_loglevel_field = 1;
else {
(context OR ctx), (default: payload,context).
.TP
.BR "-f, --fields name1<,name2,...>"
-Print additional fields: all, trace, trace:domain, trace:procname,
-trace:vpid, loglevel.
+Print additional fields: all, trace, trace:hostname, trace:domain,
+trace:procname, trace:vpid, loglevel.
.TP
.BR "--clock-raw"
Disregard internal clock offset (use raw value)
opt_trace_domain_field,
opt_trace_procname_field,
opt_trace_vpid_field,
+ opt_trace_hostname_field,
opt_loglevel_field,
opt_delta_field = 1;
else
fprintf(pos->fp, " ");
}
+ if ((opt_trace_hostname_field && !opt_all_fields) && stream_class->trace->env.hostname[0] != '\0') {
+ set_field_names_print(pos, ITEM_HEADER);
+ if (pos->print_names) {
+ fprintf(pos->fp, "trace:hostname = ");
+ }
+ fprintf(pos->fp, "%s", stream_class->trace->env.hostname);
+ if (pos->print_names)
+ fprintf(pos->fp, ", ");
+ dom_print = 1;
+ }
if ((opt_trace_domain_field && !opt_all_fields) && stream_class->trace->env.domain[0] != '\0') {
set_field_names_print(pos, ITEM_HEADER);
if (pos->print_names) {
strncpy(env->procname, right, TRACER_ENV_LEN);
env->procname[TRACER_ENV_LEN - 1] = '\0';
printf_verbose("env.procname = \"%s\"\n", env->procname);
+ } else if (!strcmp(left, "hostname")) {
+ char *right;
+
+ if (env->hostname[0]) {
+ fprintf(fd, "[warning] %s: duplicated env hostname\n", __func__);
+ goto error; /* ret is 0, so not an actual error, just warn. */
+ }
+ right = concatenate_unary_strings(&node->u.ctf_expression.right);
+ if (!right) {
+ fprintf(fd, "[warning] %s: unexpected unary expression for env hostname\n", __func__);
+ goto error; /* ret is 0, so not an actual error, just warn. */
+ }
+ strncpy(env->hostname, right, TRACER_ENV_LEN);
+ env->hostname[TRACER_ENV_LEN - 1] = '\0';
+ printf_verbose("env.hostname = \"%s\"\n", env->hostname);
} else if (!strcmp(left, "domain")) {
char *right;
trace->env.vpid = -1;
trace->env.procname[0] = '\0';
+ trace->env.hostname[0] = '\0';
trace->env.domain[0] = '\0';
trace->env.sysname[0] = '\0';
trace->env.release[0] = '\0';
opt_trace_domain_field,
opt_trace_procname_field,
opt_trace_vpid_field,
+ opt_trace_hostname_field,
opt_loglevel_field,
opt_delta_field,
opt_clock_cycles,
/* All strings below: "" if unset. */
char procname[TRACER_ENV_LEN];
+ char hostname[TRACER_ENV_LEN];
char domain[TRACER_ENV_LEN];
char sysname[TRACER_ENV_LEN];
char release[TRACER_ENV_LEN];