diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-02-08 15:41:54 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-06-24 16:01:56 +0100 |
commit | f69ac31dd940181a07daa9d00e5e83920b1fa1a0 (patch) | |
tree | 69e283281e3e939c503be3ab772ee5fc6aa732cc /bus/stats.c | |
parent | fce1f6b55fc0f9716dc2e049acc10697fb9b6f84 (diff) |
Add an initial round of stats to the Stats interface
Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34040
Diffstat (limited to 'bus/stats.c')
-rw-r--r-- | bus/stats.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/bus/stats.c b/bus/stats.c index 0cd36ca00..d395bc0e8 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; |