From f325ef59020b0acc33b6d05e96c8df7b58373715 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 27 Mar 2020 16:24:48 +0100 Subject: [PATCH] api,bearer: add 'attempts' and 'failed-attempts' statistics When we're reusing over and over the same bearer object, we can provide statistical information about the number of connection attempts that have been done and how many of them failed. --- cli/mmcli-bearer.c | 16 +++- cli/mmcli-output.c | 2 + cli/mmcli-output.h | 2 + .../libmm-glib/libmm-glib-sections.txt | 4 + .../org.freedesktop.ModemManager1.Bearer.xml | 36 +++++-- libmm-glib/mm-bearer-stats.c | 93 ++++++++++++++++++- libmm-glib/mm-bearer-stats.h | 16 ++-- src/mm-base-bearer.c | 32 ++++--- 8 files changed, 168 insertions(+), 33 deletions(-) diff --git a/cli/mmcli-bearer.c b/cli/mmcli-bearer.c index 279e568a..2dfdab35 100644 --- a/cli/mmcli-bearer.c +++ b/cli/mmcli-bearer.c @@ -248,6 +248,8 @@ print_bearer_info (MMBearer *bearer) gchar *duration = NULL; gchar *bytes_rx = NULL; gchar *bytes_tx = NULL; + gchar *attempts = NULL; + gchar *failed_attempts = NULL; if (stats) { guint64 val; @@ -261,11 +263,19 @@ print_bearer_info (MMBearer *bearer) val = mm_bearer_stats_get_tx_bytes (stats); if (val) bytes_tx = g_strdup_printf ("%" G_GUINT64_FORMAT, val); + val = mm_bearer_stats_get_attempts (stats); + if (val) + attempts = g_strdup_printf ("%" G_GUINT64_FORMAT, val); + val = mm_bearer_stats_get_failed_attempts (stats); + if (val) + failed_attempts = g_strdup_printf ("%" G_GUINT64_FORMAT, val); } - mmcli_output_string_take (MMC_F_BEARER_STATS_DURATION, duration); - mmcli_output_string_take (MMC_F_BEARER_STATS_BYTES_RX, bytes_rx); - mmcli_output_string_take (MMC_F_BEARER_STATS_BYTES_TX, bytes_tx); + mmcli_output_string_take (MMC_F_BEARER_STATS_DURATION, duration); + mmcli_output_string_take (MMC_F_BEARER_STATS_BYTES_RX, bytes_rx); + mmcli_output_string_take (MMC_F_BEARER_STATS_BYTES_TX, bytes_tx); + mmcli_output_string_take (MMC_F_BEARER_STATS_ATTEMPTS, attempts); + mmcli_output_string_take (MMC_F_BEARER_STATS_FAILED_ATTEMPTS, failed_attempts); } mmcli_output_dump (); diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c index 25877b0b..7418fc18 100644 --- a/cli/mmcli-output.c +++ b/cli/mmcli-output.c @@ -226,6 +226,8 @@ static FieldInfo field_infos[] = { [MMC_F_BEARER_STATS_DURATION] = { "bearer.stats.duration", "duration", MMC_S_BEARER_STATS, }, [MMC_F_BEARER_STATS_BYTES_RX] = { "bearer.stats.bytes-rx", "bytes rx", MMC_S_BEARER_STATS, }, [MMC_F_BEARER_STATS_BYTES_TX] = { "bearer.stats.bytes-tx", "bytes tx", MMC_S_BEARER_STATS, }, + [MMC_F_BEARER_STATS_ATTEMPTS] = { "bearer.stats.attempts", "attempts", MMC_S_BEARER_STATS, }, + [MMC_F_BEARER_STATS_FAILED_ATTEMPTS] = { "bearer.stats.failed-attempts", "attempts", MMC_S_BEARER_STATS, }, [MMC_F_CALL_GENERAL_DBUS_PATH] = { "call.dbus-path", "dbus path", MMC_S_CALL_GENERAL, }, [MMC_F_CALL_PROPERTIES_NUMBER] = { "call.properties.number", "number", MMC_S_CALL_PROPERTIES, }, [MMC_F_CALL_PROPERTIES_DIRECTION] = { "call.properties.direction", "direction", MMC_S_CALL_PROPERTIES, }, diff --git a/cli/mmcli-output.h b/cli/mmcli-output.h index bd7b317a..76ca2026 100644 --- a/cli/mmcli-output.h +++ b/cli/mmcli-output.h @@ -243,6 +243,8 @@ typedef enum { MMC_F_BEARER_STATS_DURATION, MMC_F_BEARER_STATS_BYTES_RX, MMC_F_BEARER_STATS_BYTES_TX, + MMC_F_BEARER_STATS_ATTEMPTS, + MMC_F_BEARER_STATS_FAILED_ATTEMPTS, MMC_F_CALL_GENERAL_DBUS_PATH, MMC_F_CALL_PROPERTIES_NUMBER, MMC_F_CALL_PROPERTIES_DIRECTION, diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt index 64bd2e02..83dd52f8 100644 --- a/docs/reference/libmm-glib/libmm-glib-sections.txt +++ b/docs/reference/libmm-glib/libmm-glib-sections.txt @@ -1128,6 +1128,8 @@ MMBearerStats mm_bearer_stats_get_duration mm_bearer_stats_get_rx_bytes mm_bearer_stats_get_tx_bytes +mm_bearer_stats_get_attempts +mm_bearer_stats_get_failed_attempts mm_bearer_stats_get_dictionary mm_bearer_stats_new @@ -1135,6 +1137,8 @@ mm_bearer_stats_new_from_dictionary mm_bearer_stats_set_duration mm_bearer_stats_set_rx_bytes mm_bearer_stats_set_tx_bytes +mm_bearer_stats_set_attempts +mm_bearer_stats_set_failed_attempts MMBearerStatsClass MMBearerStatsPrivate diff --git a/introspection/org.freedesktop.ModemManager1.Bearer.xml b/introspection/org.freedesktop.ModemManager1.Bearer.xml index e86ef00d..b82c9d36 100644 --- a/introspection/org.freedesktop.ModemManager1.Bearer.xml +++ b/introspection/org.freedesktop.ModemManager1.Bearer.xml @@ -244,28 +244,50 @@