From: Jérémie Galarneau Date: Mon, 7 Mar 2016 22:38:04 +0000 (-0500) Subject: Add channel discarded events and lost packets stats accessors X-Git-Tag: v2.8.0-rc1~117 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5ba3702f9f88e499d9b440a9cd88b5efa3931ab2;p=lttng-tools.git Add channel discarded events and lost packets stats accessors Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/channel.h b/include/lttng/channel.h index e770f6835..622ce85e9 100644 --- a/include/lttng/channel.h +++ b/include/lttng/channel.h @@ -20,6 +20,7 @@ #include #include +#include #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 diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 575fbf019..d436094ff 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -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. */ diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index c7665922f..6c10c910d 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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. *