From: Jérémie Galarneau Date: Fri, 24 Feb 2017 06:13:17 +0000 (-0500) Subject: Add notification, trigger, action, condition and evaluation API X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=526c7763e5bcac268e2957291176e3223be82f08 Add notification, trigger, action, condition and evaluation API Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/action/action.h b/include/lttng/action/action.h new file mode 100644 index 000000000..311f5a0fb --- /dev/null +++ b/include/lttng/action/action.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_ACTION_H +#define LTTNG_ACTION_H + +struct lttng_action; + +#ifdef __cplusplus +extern "C" { +#endif + +enum lttng_action_type { + LTTNG_ACTION_TYPE_UNKNOWN = -1, + LTTNG_ACTION_TYPE_NOTIFY = 0, +}; + +extern enum lttng_action_type lttng_action_get_type( + struct lttng_action *action); + +extern void lttng_action_destroy(struct lttng_action *action); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_ACTION_H */ diff --git a/include/lttng/action/notify.h b/include/lttng/action/notify.h new file mode 100644 index 000000000..6c0d0ca25 --- /dev/null +++ b/include/lttng/action/notify.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_ACTION_NOTIFY_H +#define LTTNG_ACTION_NOTIFY_H + +struct lttng_action; + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct lttng_action *lttng_action_notify_create(void); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_ACTION_NOTIFY_H */ diff --git a/include/lttng/condition/buffer-usage.h b/include/lttng/condition/buffer-usage.h new file mode 100644 index 000000000..7c8834eab --- /dev/null +++ b/include/lttng/condition/buffer-usage.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_CONDITION_BUFFER_USAGE_H +#define LTTNG_CONDITION_BUFFER_USAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct lttng_condition; +struct lttng_evaluation; + +extern struct lttng_condition * +lttng_condition_buffer_usage_low_create(void); + +extern struct lttng_condition * +lttng_condition_buffer_usage_high_create(void); + +/* threshold_percent expressed as [0.0, 1.0]. */ +extern enum lttng_condition_status +lttng_condition_buffer_usage_get_threshold_percentage( + struct lttng_condition *condition, + double *threshold_percent); + +/* threshold_percent expressed as [0.0, 1.0]. */ +extern enum lttng_condition_status +lttng_condition_buffer_usage_set_threshold_percentage( + struct lttng_condition *condition, + double threshold_percent); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_get_threshold( + struct lttng_condition *condition, + uint64_t *threshold_bytes); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_set_threshold( + struct lttng_condition *condition, + uint64_t threshold_bytes); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_get_session_name( + struct lttng_condition *condition, + const char **session_name); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_set_session_name( + struct lttng_condition *condition, + const char *session_name); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_get_channel_name( + struct lttng_condition *condition, + const char **channel_name); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_set_channel_name( + struct lttng_condition *condition, + const char *channel_name); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_get_domain_type( + struct lttng_condition *condition, + enum lttng_domain_type *type); + +extern enum lttng_condition_status +lttng_condition_buffer_usage_set_domain_type( + struct lttng_condition *condition, + enum lttng_domain_type type); + + +/* LTTng Condition Evaluation */ +extern enum lttng_evaluation_status +lttng_evaluation_buffer_usage_get_usage_percentage( + struct lttng_evaluation *evaluation, + double *usage_percent); + +extern enum lttng_evaluation_status +lttng_evaluation_buffer_usage_get_usage( + struct lttng_evaluation *evaluation, + uint64_t *usage_bytes); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_CONDITION_BUFFER_USAGE_H */ diff --git a/include/lttng/condition/condition.h b/include/lttng/condition/condition.h new file mode 100644 index 000000000..9830dbfb1 --- /dev/null +++ b/include/lttng/condition/condition.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_CONDITION_H +#define LTTNG_CONDITION_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct lttng_condition; + +enum lttng_condition_type { + LTTNG_CONDITION_TYPE_UNKNOWN = -1, + LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW = 0, + LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH = 1, +}; + +enum lttng_condition_status { + LTTNG_CONDITION_STATUS_OK = 0, + LTTNG_CONDITION_STATUS_ERROR = -1, + LTTNG_CONDITION_STATUS_UNKNOWN = -2, + LTTNG_CONDITION_STATUS_INVALID = -3, + LTTNG_CONDITION_STATUS_UNSET = -4, +}; + +extern enum lttng_condition_type lttng_condition_get_type( + struct lttng_condition *condition); + +extern void lttng_condition_destroy(struct lttng_condition *condition); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_CONDITION_H */ diff --git a/include/lttng/condition/evaluation.h b/include/lttng/condition/evaluation.h new file mode 100644 index 000000000..841284cd0 --- /dev/null +++ b/include/lttng/condition/evaluation.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_EVALUATION_H +#define LTTNG_EVALUATION_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct lttng_evaluation; + +enum lttng_evaluation_status { + LTTNG_EVALUATION_STATUS_OK = 0, + LTTNG_EVALUATION_STATUS_ERROR = -1, + LTTNG_EVALUATION_STATUS_INVALID = -2, + LTTNG_EVALUATION_STATUS_UNKNOWN = -2, + LTTNG_EVALUATION_STATUS_UNSET = -3, +}; + +extern enum lttng_condition_type lttng_evaluation_get_type( + struct lttng_evaluation *evaluation); + +extern void lttng_evaluation_destroy(struct lttng_evaluation *evaluation); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_EVALUATION_H */ diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 5478641b2..966d593dd 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -35,6 +35,8 @@ #include #include +struct lttng_endpoint; + #ifdef __cplusplus extern "C" { #endif @@ -55,6 +57,9 @@ struct lttng_calibrate { char padding[LTTNG_CALIBRATE_PADDING1]; }; +/* Default LTTng session daemon endpoint. */ +extern struct lttng_endpoint *session_daemon_endpoint; + /* * Check if a session daemon is alive. * diff --git a/include/lttng/notification/channel.h b/include/lttng/notification/channel.h new file mode 100644 index 000000000..77a9e6e92 --- /dev/null +++ b/include/lttng/notification/channel.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_NOTIFICATION_CHANNEL_H +#define LTTNG_NOTIFICATION_CHANNEL_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct lttng_endpoint; +struct lttng_notification; +struct lttng_notification_channel; +struct lttng_notification_channel_endpoint; + +/* LTTng Notification channel */ +enum lttng_notification_channel_status { + LTTNG_NOTIFICATION_CHANNEL_STATUS_TIMEOUT = 2, + LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED = 1, + LTTNG_NOTIFICATION_CHANNEL_STATUS_OK = 0, + LTTNG_NOTIFICATION_CHANNEL_STATUS_CLOSED = -1, + LTTNG_NOTIFICATION_CHANNEL_STATUS_NOT_FOUND = -2, + LTTNG_NOTIFICATION_CHANNEL_STATUS_UNSUPPORTED = -3, +}; + +/* TODO Add target parameter (sessiond, relayd, etc.). */ +extern struct lttng_notification_channel *lttng_notification_channel_create( + struct lttng_endpoint *endpoint); + +extern enum lttng_notification_channel_status +lttng_notification_channel_get_next_notification( + struct lttng_notification_channel *channel, + struct lttng_notification **notification, + unsigned int timeout_ms); + +extern enum lttng_notification_channel_status +lttng_notification_channel_subscribe( + struct lttng_notification_channel *channel, + struct lttng_condition *condition); + +extern enum lttng_notification_channel_status +lttng_notification_channel_unsubscribe( + struct lttng_notification_channel *channel, + struct lttng_condition *condition); + +extern void lttng_notification_channel_destroy( + struct lttng_notification_channel *channel); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_NOTIFICATION_CHANNEL_H */ diff --git a/include/lttng/notification/notification.h b/include/lttng/notification/notification.h new file mode 100644 index 000000000..2f4cb1d59 --- /dev/null +++ b/include/lttng/notification/notification.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_NOTIFICATION_H +#define LTTNG_NOTIFICATION_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct lttng_condition; +struct lttng_evaluation; + +extern struct lttng_condition *lttng_notification_get_condition( + struct lttng_notification *notification); + +extern struct lttng_evaluation * +lttng_notification_get_evaluation(struct lttng_notification *notification); + +extern void lttng_notification_destroy(struct lttng_notification *notification); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_NOTIFICATION_H */ diff --git a/include/lttng/trigger/trigger.h b/include/lttng/trigger/trigger.h new file mode 100644 index 000000000..ea9c16edf --- /dev/null +++ b/include/lttng/trigger/trigger.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LTTNG_TRIGGER_H +#define LTTNG_TRIGGER_H + +struct lttng_action; +struct lttng_condition; +struct lttng_trigger; +struct lttng_endpoint; + +#ifdef __cplusplus +extern "C" { +#endif + +enum lttng_register_trigger_status { + LTTNG_REGISTER_TRIGGER_STATUS_OK = 0, + LTTNG_REGISTER_TRIGGER_STATUS_INVALID = -1, +}; + +/* Trigger assumes ownership of both condition and action after call. */ +extern struct lttng_trigger *lttng_trigger_create( + struct lttng_condition *condition, struct lttng_action *action); + +extern void lttng_trigger_destroy(struct lttng_trigger *trigger); + +extern int lttng_register_trigger(struct lttng_trigger *trigger); + +#ifdef __cplusplus +} +#endif + +#endif /* LTTNG_TRIGGER_H */