char path[LTTNG_PATH_MAX];
} LTTNG_PACKED;
+/* For the LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD command. */
+struct lttng_rotation_schedule_get_timer_period {
+ uint64_t rotate_timer;
+} LTTNG_PACKED;
+
+/* For the LTTNG_ROTATION_SCHEDULE_GET_SIZE command. */
+struct lttng_rotation_schedule_get_size {
+ uint64_t rotate_size;
+} LTTNG_PACKED;
+
#endif /* LTTNG_ROTATE_INTERNAL_ABI_H */
extern int lttng_rotation_set_schedule(
struct lttng_rotation_schedule_attr *attr);
+/*
+ * Ask the sessiond for the value of the rotate timer (in micro-seconds) of the
+ * session.
+ *
+ * On success, return 0 and set the value or rotate_timer, on error return a
+ * negative value.
+ */
+extern int lttng_rotation_schedule_get_timer_period(const char *session_name,
+ uint64_t *rotate_timer);
+
+/*
+ * Ask the sessiond for the value of the rotate size (in micro-seconds) of the
+ * session.
+ *
+ * On success, return 0 and set the value or rotate_size, on error return
+ * a negative value.
+ */
+extern int lttng_rotation_schedule_get_size(const char *session_name,
+ uint64_t *rotate_size);
+
#ifdef __cplusplus
}
#endif
case LTTNG_ROTATION_GET_INFO:
case LTTNG_SESSION_GET_CURRENT_OUTPUT:
case LTTNG_ROTATION_SET_SCHEDULE:
+ case LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD:
+ case LTTNG_ROTATION_SCHEDULE_GET_SIZE:
need_domain = 0;
break;
default:
case LTTNG_DATA_PENDING:
case LTTNG_ROTATE_SESSION:
case LTTNG_ROTATION_GET_INFO:
+ case LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD:
+ case LTTNG_ROTATION_SCHEDULE_GET_SIZE:
break;
default:
/* Setup lttng message with no payload */
ret = LTTNG_OK;
break;
}
+ case LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD:
+ {
+ struct lttng_rotation_schedule_get_timer_period *get_timer;
+
+ get_timer = zmalloc(sizeof(struct lttng_rotation_schedule_get_timer_period));
+ if (!get_timer) {
+ ret = ENOMEM;
+ goto error;
+ }
+ get_timer->rotate_timer = cmd_ctx->session->rotate_timer_period;
+
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, get_timer,
+ sizeof(struct lttng_rotation_schedule_get_timer_period));
+ free(get_timer);
+ if (ret < 0) {
+ ret = -ret;
+ goto error;
+ }
+
+ ret = LTTNG_OK;
+ break;
+ }
+ case LTTNG_ROTATION_SCHEDULE_GET_SIZE:
+ {
+ struct lttng_rotation_schedule_get_size *get_size;
+
+ get_size = zmalloc(sizeof(struct lttng_rotation_schedule_get_size));
+ if (!get_size) {
+ ret = ENOMEM;
+ goto error;
+ }
+ get_size->rotate_size = cmd_ctx->session->rotate_size;
+
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, get_size,
+ sizeof(struct lttng_rotation_schedule_get_size));
+ free(get_size);
+ if (ret < 0) {
+ ret = -ret;
+ goto error;
+ }
+
+ ret = LTTNG_OK;
+ break;
+ }
default:
ret = LTTNG_ERR_UND;
break;
goto end;
}
- if (session->snapshot_mode || session->live_timer) {
+ if (session->snapshot_mode || session->live_timer ||
+ session->rotate_timer_period || session->rotate_size) {
ret = config_writer_open_element(writer, config_element_attributes);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- } else {
+ } else if (session->live_timer) {
ret = config_writer_write_element_unsigned_int(writer,
config_element_live_timer_interval, session->live_timer);
if (ret) {
goto end;
}
}
+ if (session->rotate_timer_period) {
+ ret = config_writer_write_element_unsigned_int(writer,
+ config_element_rotation_timer_interval,
+ session->rotate_timer_period);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+ }
+
+ if (session->rotate_size) {
+ ret = config_writer_write_element_unsigned_int(writer,
+ config_element_rotation_size,
+ session->rotate_size);
+ if (ret) {
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ goto end;
+ }
+ }
/* /attributes */
ret = config_writer_close_element(writer);
return ret;
}
+/*
+ * List the rotate settings (timer/size if any).
+ */
+static int list_rotate_settings(const char *session_name)
+{
+ int ret;
+ uint64_t size, timer;
+
+ ret = lttng_rotation_schedule_get_timer_period(session_name, &timer);
+ if (ret) {
+ goto end;
+ }
+
+ ret = lttng_rotation_schedule_get_size(session_name, &size);
+ if (ret) {
+ goto end;
+ }
+
+ if (!timer && !size) {
+ ret = 0;
+ goto end;
+ }
+
+ _MSG("Automatic rotation schedule settings:\n");
+
+ if (timer) {
+ _MSG(" timer period: %" PRIu64" µs\n", timer);
+ if (lttng_opt_mi) {
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_rotation_timer_interval, timer);
+ if (ret) {
+ goto end;
+ }
+ }
+ }
+ if (size) {
+ _MSG(" size threshold: %" PRIu64" bytes\n", size);
+ if (lttng_opt_mi) {
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_rotation_size, size);
+ if (ret) {
+ goto end;
+ }
+ }
+ }
+ _MSG("\n");
+
+end:
+ return ret;
+}
+
/*
* Machine interface
* Find the session with session_name as name
goto end;
}
+ ret = list_rotate_settings(session_name);
+ if (ret) {
+ goto end;
+ }
+
/* Domain listing */
if (opt_domain) {
ret = list_domains(session_name);
extern const char * const config_element_targets;
extern const char * const config_element_target_pid;
extern const char * const config_element_rotation_timer_interval;
+extern const char * const config_element_rotation_size;
extern const char * const config_element_rotation_schedule;
extern const char * const config_domain_type_kernel;
const char * const config_element_target_pid = "pid_target";
LTTNG_HIDDEN const char * const config_element_rotation_timer_interval = "rotation_schedule_timer_period";
+LTTNG_HIDDEN const char * const config_element_rotation_size = "rotation_schedule_size";
LTTNG_HIDDEN const char * const config_element_rotation_schedule = "rotation_schedule";
const char * const config_domain_type_kernel = "KERNEL";
<xs:all>
<xs:element name="snapshot_mode" type="xs:boolean" minOccurs="0"/>
<xs:element name="live_timer_interval" type="uint32_type" minOccurs="0"/> <!-- usec -->
- <xs:element name="rotation_timer_interval" type="uint64_type" minOccurs="0"/> <!-- usec -->
+ <xs:element name="rotation_schedule_timer_period" type="uint64_type" minOccurs="0"/> <!-- usec -->
+ <xs:element name="rotation_schedule_size" type="uint64_type" minOccurs="0"/> <!-- bytes -->
</xs:all>
</xs:complexType>
LTTNG_ROTATION_GET_INFO = 46,
LTTNG_ROTATION_SET_SCHEDULE = 47,
LTTNG_SESSION_GET_CURRENT_OUTPUT = 48,
+ LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD = 49,
+ LTTNG_ROTATION_SCHEDULE_GET_SIZE = 50,
};
enum lttcomm_relayd_command {
end:
return ret;
}
+
+int lttng_rotation_schedule_get_timer_period(const char *session_name,
+ uint64_t *rotate_timer)
+{
+ struct lttcomm_session_msg lsm;
+ struct lttng_rotation_schedule_get_timer_period *get_timer = NULL;
+ int ret;
+
+ memset(&lsm, 0, sizeof(lsm));
+ lsm.cmd_type = LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD;
+ lttng_ctl_copy_string(lsm.session.name, session_name,
+ sizeof(lsm.session.name));
+
+ ret = lttng_ctl_ask_sessiond(&lsm, (void **) &get_timer);
+ if (ret < 0) {
+ ret = -1;
+ goto end;
+ }
+
+ *rotate_timer = get_timer->rotate_timer;
+
+ ret = 0;
+
+end:
+ free(get_timer);
+ return ret;
+}
+
+int lttng_rotation_schedule_get_size(const char *session_name,
+ uint64_t *rotate_size)
+{
+ struct lttcomm_session_msg lsm;
+ struct lttng_rotation_schedule_get_size *get_size = NULL;
+ int ret;
+
+ memset(&lsm, 0, sizeof(lsm));
+ lsm.cmd_type = LTTNG_ROTATION_SCHEDULE_GET_SIZE;
+ lttng_ctl_copy_string(lsm.session.name, session_name,
+ sizeof(lsm.session.name));
+
+ ret = lttng_ctl_ask_sessiond(&lsm, (void **) &get_size);
+ if (ret < 0) {
+ ret = -1;
+ goto end;
+ }
+
+ *rotate_size = get_size->rotate_size;
+
+ ret = 0;
+
+end:
+ free(get_size);
+ return ret;
+}