OPT_CONDITION,
OPT_ACTION,
OPT_ID,
- OPT_USER_ID,
+ OPT_OWNER_UID,
OPT_RATE_POLICY,
OPT_NAME,
return c;
}
-static
-struct lttng_condition *handle_condition_session_consumed_size(int *argc, const char ***argv)
-{
- struct lttng_condition *cond = NULL;
- struct argpar_state *state = NULL;
- struct argpar_item *item = NULL;
- const char *threshold_arg = NULL;
- const char *session_name_arg = NULL;
- uint64_t threshold;
- char *error = NULL;
- enum lttng_condition_status condition_status;
-
- state = argpar_state_create(*argc, *argv, event_rule_opt_descrs);
- if (!state) {
- ERR("Failed to allocate an argpar state.");
- goto error;
- }
-
- while (true) {
- enum argpar_state_parse_next_status status;
-
- ARGPAR_ITEM_DESTROY_AND_RESET(item);
- status = argpar_state_parse_next(state, &item, &error);
- if (status == ARGPAR_STATE_PARSE_NEXT_STATUS_ERROR) {
- ERR("%s", error);
- goto error;
- } else if (status == ARGPAR_STATE_PARSE_NEXT_STATUS_ERROR_UNKNOWN_OPT) {
- /* Just stop parsing here. */
- break;
- } else if (status == ARGPAR_STATE_PARSE_NEXT_STATUS_END) {
- break;
- }
-
- assert(status == ARGPAR_STATE_PARSE_NEXT_STATUS_OK);
-
- if (item->type == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_item_opt *item_opt =
- (const struct argpar_item_opt *) item;
-
- switch (item_opt->descr->id) {
- default:
- abort();
- }
- } else {
- const struct argpar_item_non_opt *item_non_opt;
-
- assert(item->type == ARGPAR_ITEM_TYPE_NON_OPT);
-
- item_non_opt = (const struct argpar_item_non_opt *) item;
-
- switch (item_non_opt->non_opt_index) {
- case 0:
- session_name_arg = item_non_opt->arg;
- break;
- case 1:
- threshold_arg = item_non_opt->arg;
- break;
- default:
- ERR("Unexpected argument `%s`.",
- item_non_opt->arg);
- goto error;
- }
- }
- }
-
- *argc -= argpar_state_get_ingested_orig_args(state);
- *argv += argpar_state_get_ingested_orig_args(state);
-
- if (!session_name_arg) {
- ERR("Missing session name argument.");
- goto error;
- }
-
- if (!threshold_arg) {
- ERR("Missing threshold argument.");
- goto error;
- }
-
- if (utils_parse_size_suffix(threshold_arg, &threshold) != 0) {
- ERR("Failed to parse `%s` as a size.", threshold_arg);
- goto error;
- }
-
- cond = lttng_condition_session_consumed_size_create();
- if (!cond) {
- ERR("Failed to allocate a session consumed size condition.");
- goto error;
- }
-
- condition_status = lttng_condition_session_consumed_size_set_session_name(
- cond, session_name_arg);
- if (condition_status != LTTNG_CONDITION_STATUS_OK) {
- ERR("Failed to set session consumed size condition's session name to '%s'.",
- session_name_arg);
- goto error;
- }
-
- condition_status = lttng_condition_session_consumed_size_set_threshold(
- cond, threshold);
- if (condition_status != LTTNG_CONDITION_STATUS_OK) {
- ERR("Failed to set session consumed size condition threshold.");
- goto error;
- }
-
- goto end;
-
-error:
- lttng_condition_destroy(cond);
- cond = NULL;
-
-end:
- argpar_state_destroy(state);
- argpar_item_destroy(item);
- free(error);
- return cond;
-}
-
-static
-struct lttng_condition *handle_condition_buffer_usage_high(int *argc, const char ***argv)
-{
- ERR("High buffer usage threshold conditions are unsupported for the moment.");
- return NULL;
-}
-
-static
-struct lttng_condition *handle_condition_buffer_usage_low(int *argc, const char ***argv)
-{
- ERR("Low buffer usage threshold conditions are unsupported for the moment.");
- return NULL;
-}
-
-static
-struct lttng_condition *handle_condition_session_rotation_ongoing(int *argc, const char ***argv)
-{
- ERR("Session rotation ongoing conditions are unsupported for the moment.");
- return NULL;
-}
-
-static
-struct lttng_condition *handle_condition_session_rotation_completed(int *argc, const char ***argv)
-{
- ERR("Session rotation completed conditions are unsupported for the moment.");
- return NULL;
-}
-
struct condition_descr {
const char *name;
struct lttng_condition *(*handler) (int *argc, const char ***argv);
static const
struct condition_descr condition_descrs[] = {
{ "event-rule-matches", handle_condition_event },
- { "on-session-consumed-size", handle_condition_session_consumed_size },
- { "on-buffer-usage-high", handle_condition_buffer_usage_high },
- { "on-buffer-usage-low", handle_condition_buffer_usage_low },
- { "on-session-rotation-ongoing", handle_condition_session_rotation_ongoing },
- { "on-session-rotation-completed", handle_condition_session_rotation_completed },
};
static
{ OPT_CONDITION, '\0', "condition", true },
{ OPT_ACTION, '\0', "action", true },
{ OPT_NAME, '\0', "name", true },
- { OPT_USER_ID, '\0', "user-id", true },
+ { OPT_OWNER_UID, '\0', "owner-uid", true },
ARGPAR_OPT_DESCR_SENTINEL,
};
char *error = NULL;
char *name = NULL;
int i;
- char *user_id = NULL;
+ char *owner_uid = NULL;
lttng_dynamic_pointer_array_init(&actions, lttng_actions_destructor);
break;
}
- case OPT_USER_ID:
+ case OPT_OWNER_UID:
{
- if (!assign_string(&user_id, item_opt->arg,
- "--user-id")) {
+ if (!assign_string(&owner_uid, item_opt->arg,
+ "--owner-uid")) {
goto error;
}
}
}
- if (user_id) {
+ if (owner_uid) {
enum lttng_trigger_status trigger_status;
char *end;
long long uid;
errno = 0;
- uid = strtol(user_id, &end, 10);
- if (end == user_id || *end != '\0' || errno != 0) {
- ERR("Failed to parse `%s` as a user id.", user_id);
+ uid = strtol(owner_uid, &end, 10);
+ if (end == owner_uid || *end != '\0' || errno != 0) {
+ ERR("Failed to parse `%s` as a user id.", owner_uid);
}
trigger_status = lttng_trigger_set_owner_uid(trigger, uid);
lttng_trigger_destroy(trigger);
free(error);
free(name);
- free(user_id);
+ free(owner_uid);
return ret;
}