Add channel discarded events and lost packets stats accessors
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 7 Mar 2016 22:38:04 +0000 (17:38 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 7 Mar 2016 23:47:22 +0000 (18:47 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/channel.h
src/common/sessiond-comm/sessiond-comm.h
src/lib/lttng-ctl/lttng-ctl.c

index e770f6835a491f35c3dbdea7b4705ad65afefbdc..622ce85e9f30bbcf01cd15cb1a3abc418813f3de 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <lttng/domain.h>
 #include <lttng/event.h>
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -107,6 +108,22 @@ extern int lttng_disable_channel(struct lttng_handle *handle,
 extern void lttng_channel_set_default_attr(struct lttng_domain *domain,
                struct lttng_channel_attr *attr);
 
+/*
+ * Get the discarded event count of a specific LTTng channel.
+ *
+ * Returns 0 on success, or a negative LTTng error code on error.
+ */
+extern int lttng_channel_get_discarded_event_count(struct lttng_channel *chan,
+               uint64_t *discarded_events);
+
+/*
+ * Get the lost packet count of a specific LTTng channel.
+ *
+ * Returns 0 on success, or a negative LTTng error code on error.
+ */
+extern int lttng_channel_get_lost_packet_count(struct lttng_channel *chan,
+               uint64_t *lost_packets);
+
 #ifdef __cplusplus
 }
 #endif
index 575fbf0194f7474662053717c29a0fcef1b2339d..d436094ff36d0c6a71671d380b34c13e1c106c56 100644 (file)
@@ -369,6 +369,14 @@ struct lttcomm_event_extended_header {
        uint32_t nb_exclusions;
 } LTTNG_PACKED;
 
+/*
+ * Channel extended info.
+ */
+struct lttcomm_channel_extended {
+       uint64_t discarded_events;
+       uint64_t lost_packets;
+} LTTNG_PACKED;
+
 /*
  * Data structure for the response from sessiond to the lttng client.
  */
index c7665922f4f014f5b5dd07c6ffae69d6e6887e73..6c10c910d8207be651e41e7c720be9a679e1972c 100644 (file)
@@ -1974,6 +1974,58 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,
        }
 }
 
+int lttng_channel_get_discarded_event_count(struct lttng_channel *channel,
+               uint64_t *discarded_events)
+{
+       int ret = 0;
+       struct lttcomm_channel_extended *chan_ext;
+
+       if (!channel || !discarded_events) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       chan_ext = channel->attr.extended.ptr;
+       if (!chan_ext) {
+               /*
+                * This can happen since the lttng_channel structure is
+                * used for other tasks where this pointer is never set.
+                */
+               *discarded_events = 0;
+               goto end;
+       }
+
+       *discarded_events = chan_ext->discarded_events;
+end:
+       return ret;
+}
+
+int lttng_channel_get_lost_packet_count(struct lttng_channel *channel,
+               uint64_t *lost_packets)
+{
+       int ret = 0;
+       struct lttcomm_channel_extended *chan_ext;
+
+       if (!channel || !lost_packets) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       chan_ext = channel->attr.extended.ptr;
+       if (!chan_ext) {
+               /*
+                * This can happen since the lttng_channel structure is
+                * used for other tasks where this pointer is never set.
+                */
+               *lost_packets = 0;
+               goto end;
+       }
+
+       *lost_packets = chan_ext->lost_packets;
+end:
+       return ret;
+}
+
 /*
  * Check if session daemon is alive.
  *
This page took 0.038713 seconds and 4 git commands to generate.