X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist_triggers.c;h=bb118e56a217f48c70aeb78a309d28f8c84259ea;hb=19904669a9eb25cd4a0ccd3de82d3ac803dfe877;hp=70ab4c4e540d95c79aae6967207ce20b3f137861;hpb=709fb83f37a5315693a65d8ac6c0c7d1a607745f;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list_triggers.c b/src/bin/lttng/commands/list_triggers.c index 70ab4c4e5..bb118e56a 100644 --- a/src/bin/lttng/commands/list_triggers.c +++ b/src/bin/lttng/commands/list_triggers.c @@ -39,6 +39,81 @@ struct argpar_opt_descr list_trigger_options[] = { ARGPAR_OPT_DESCR_SENTINEL, }; +static void print_condition_session_consumed_size( + const struct lttng_condition *condition) +{ + enum lttng_condition_status condition_status; + const char *session_name; + uint64_t threshold; + + condition_status = + lttng_condition_session_consumed_size_get_session_name( + condition, &session_name); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + lttng_condition_session_consumed_size_get_threshold( + condition, &threshold); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + MSG(" session name: %s", session_name); + MSG(" threshold: %" PRIu64 " bytes", threshold); +} + +static void print_condition_buffer_usage( + const struct lttng_condition *condition) +{ + enum lttng_condition_status condition_status; + const char *session_name, *channel_name; + enum lttng_domain_type domain_type; + uint64_t threshold; + + condition_status = lttng_condition_buffer_usage_get_session_name( + condition, &session_name); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + condition_status = lttng_condition_buffer_usage_get_channel_name( + condition, &channel_name); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + condition_status = lttng_condition_buffer_usage_get_domain_type( + condition, &domain_type); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + MSG(" session name: %s", session_name); + MSG(" channel name: %s", channel_name); + MSG(" domain: %s", lttng_domain_type_str(domain_type)); + + condition_status = lttng_condition_buffer_usage_get_threshold( + condition, &threshold); + if (condition_status == LTTNG_CONDITION_STATUS_OK) { + MSG(" threshold (bytes): %" PRIu64, threshold); + } else { + double threshold_ratio; + + assert(condition_status == LTTNG_CONDITION_STATUS_UNSET); + + condition_status = + lttng_condition_buffer_usage_get_threshold_ratio( + condition, &threshold_ratio); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + MSG(" threshold (ratio): %.2f", threshold_ratio); + } +} + +static void print_condition_session_rotation( + const struct lttng_condition *condition) +{ + enum lttng_condition_status condition_status; + const char *session_name; + + condition_status = lttng_condition_session_rotation_get_session_name( + condition, &session_name); + assert(condition_status == LTTNG_CONDITION_STATUS_OK); + + MSG(" session name: %s", session_name); +} + /* * Returns the human-readable log level name associated with a numerical value * if there is one. The Log4j and JUL domains have discontinuous log level @@ -266,7 +341,7 @@ void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule) goto end; } - _MSG(" rule: %s (type: userspace probe, location: ", name); + _MSG(" rule: %s (type: userspace probe, ", name); userspace_probe_location_type = lttng_userspace_probe_location_get_type(location); @@ -281,12 +356,22 @@ void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule) function_name = lttng_userspace_probe_location_function_get_function_name( location); - _MSG("%s:%s", binary_path, function_name); + _MSG("location type: ELF, location: %s:%s", binary_path, function_name); break; } case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT: - _MSG("SDT not implemented yet"); + { + const char *binary_path, *provider_name, *probe_name; + + binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path( + location); + provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name( + location); + probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name( + location); + _MSG("location type: SDT, location: %s:%s:%s", binary_path, provider_name, probe_name); break; + } default: abort(); } @@ -806,19 +891,29 @@ void print_one_trigger(const struct lttng_trigger *trigger) trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid); assert(trigger_status == LTTNG_TRIGGER_STATUS_OK); - MSG("- id: %s", name); - MSG(" user id: %d", trigger_uid); + MSG("- name: %s", name); + MSG(" owner uid: %d", trigger_uid); condition = lttng_trigger_get_const_condition(trigger); condition_type = lttng_condition_get_type(condition); MSG(" condition: %s", lttng_condition_type_str(condition_type)); switch (condition_type) { + case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE: + print_condition_session_consumed_size(condition); + break; + case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH: + case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW: + print_condition_buffer_usage(condition); + break; + case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING: + case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: + print_condition_session_rotation(condition); + break; case LTTNG_CONDITION_TYPE_ON_EVENT: print_condition_on_event(condition); break; default: - MSG(" (condition type not handled in %s)", __func__); - break; + abort(); } action = lttng_trigger_get_const_action(trigger);