Add notification, trigger, action, condition and evaluation API
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Feb 2017 06:13:17 +0000 (01:13 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 1 Mar 2017 03:10:48 +0000 (22:10 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/action/action.h [new file with mode: 0644]
include/lttng/action/notify.h [new file with mode: 0644]
include/lttng/condition/buffer-usage.h [new file with mode: 0644]
include/lttng/condition/condition.h [new file with mode: 0644]
include/lttng/condition/evaluation.h [new file with mode: 0644]
include/lttng/lttng.h
include/lttng/notification/channel.h [new file with mode: 0644]
include/lttng/notification/notification.h [new file with mode: 0644]
include/lttng/trigger/trigger.h [new file with mode: 0644]

diff --git a/include/lttng/action/action.h b/include/lttng/action/action.h
new file mode 100644 (file)
index 0000000..311f5a0
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 (file)
index 0000000..6c0d0ca
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 (file)
index 0000000..7c8834e
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 (file)
index 0000000..9830dbf
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <lttng/lttng.h>
+
+#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 (file)
index 0000000..841284c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <lttng/condition/condition.h>
+
+#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 */
index 5478641b2eb66f0d6139281c2d4c7a61220f8cd4..966d593dd9c48eb9dd7cebdb8e6ac66bf5b48673 100644 (file)
@@ -35,6 +35,8 @@
 #include <lttng/session.h>
 #include <lttng/snapshot.h>
 
+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 (file)
index 0000000..77a9e6e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 (file)
index 0000000..2f4cb1d
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 (file)
index 0000000..ea9c16e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 */
This page took 0.033327 seconds and 5 git commands to generate.