From dbd100f4931fd1388efb6f54fdc6736133146dd7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Feb 2011 15:41:54 +0000 Subject: [PATCH 08/10] Add an initial round of stats to the Stats interface Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34040 --- bus/stats.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) diff --git a/bus/stats.c b/bus/stats.c index 0cd36ca..d395bc0 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -187,6 +187,7 @@ bus_stats_handle_get_stats (DBusConnection *connection, DBusMessage *reply = NULL; DBusMessageIter iter, arr_iter; static dbus_uint32_t stats_serial = 0; + dbus_uint32_t in_use, in_free_list, allocated; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -197,9 +198,41 @@ bus_stats_handle_get_stats (DBusConnection *connection, if (reply == NULL) goto oom; + /* Globals */ + if (!asv_add_uint32 (&iter, &arr_iter, "Serial", stats_serial++)) goto oom; + _dbus_list_get_stats (&in_use, &in_free_list, &allocated); + if (!asv_add_uint32 (&iter, &arr_iter, "ListMemPoolUsedBytes", in_use) || + !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolCachedBytes", + in_free_list) || + !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolAllocatedBytes", + allocated)) + goto oom; + + /* Connections */ + + if (!asv_add_uint32 (&iter, &arr_iter, "ActiveConnections", + bus_connections_get_n_active (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "IncompleteConnections", + bus_connections_get_n_incomplete (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "MatchRules", + bus_connections_get_total_match_rules (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "PeakMatchRules", + bus_connections_get_peak_match_rules (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "PeakMatchRulesPerConnection", + bus_connections_get_peak_match_rules_per_conn (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "BusNames", + bus_connections_get_total_bus_names (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "PeakBusNames", + bus_connections_get_peak_bus_names (connections)) || + !asv_add_uint32 (&iter, &arr_iter, "PeakBusNamesPerConnection", + bus_connections_get_peak_bus_names_per_conn (connections))) + goto oom; + + /* end */ + if (!close_asv_reply (&iter, &arr_iter)) goto oom; @@ -261,11 +294,37 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, if (reply == NULL) goto oom; + /* Bus daemon per-connection stats */ + if (!asv_add_uint32 (&iter, &arr_iter, "Serial", stats_serial++) || + !asv_add_uint32 (&iter, &arr_iter, "MatchRules", + bus_connection_get_n_match_rules (stats_connection)) || + !asv_add_uint32 (&iter, &arr_iter, "PeakMatchRules", + bus_connection_get_peak_match_rules (stats_connection)) || + !asv_add_uint32 (&iter, &arr_iter, "BusNames", + bus_connection_get_n_services_owned (stats_connection)) || + !asv_add_uint32 (&iter, &arr_iter, "PeakBusNames", + bus_connection_get_peak_bus_names (stats_connection)) || !asv_add_string (&iter, &arr_iter, "UniqueName", bus_connection_get_name (stats_connection))) goto oom; + /* DBusConnection per-connection stats */ + + _dbus_connection_get_stats (stats_connection, + &in_messages, &in_bytes, &in_fds, + &out_messages, &out_bytes, &out_fds); + + if (!asv_add_uint32 (&iter, &arr_iter, "IncomingMessages", in_messages) || + !asv_add_uint32 (&iter, &arr_iter, "IncomingBytes", in_bytes) || + !asv_add_uint32 (&iter, &arr_iter, "IncomingFDs", in_fds) || + !asv_add_uint32 (&iter, &arr_iter, "OutgoingMessages", out_messages) || + !asv_add_uint32 (&iter, &arr_iter, "OutgoingBytes", out_bytes) || + !asv_add_uint32 (&iter, &arr_iter, "OutgoingFDs", out_fds)) + goto oom; + + /* end */ + if (!close_asv_reply (&iter, &arr_iter)) goto oom; -- 1.7.2.3