diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-14 16:09:37 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-14 16:09:37 +0100 |
commit | 8e07c3d9d39eee9e5a8196103259a93a9ef7973a (patch) | |
tree | 9868a339c4fd9e399cca4e8f17a1b884d903cb7f /src/libserver | |
parent | 0de0656c3e72e8587f8af7e61107331236f21bf0 (diff) | |
download | rspamd-8e07c3d9d39eee9e5a8196103259a93a9ef7973a.tar.gz rspamd-8e07c3d9d39eee9e5a8196103259a93a9ef7973a.zip |
Add total statistics
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/rspamd_control.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index 12a307625..5443b81a3 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -152,11 +152,14 @@ rspamd_control_connection_close (struct rspamd_control_session *session) static void rspamd_control_write_reply (struct rspamd_control_session *session) { - ucl_object_t *rep, *cur; + ucl_object_t *rep, *cur, *workers; struct rspamd_control_reply_elt *elt; gchar tmpbuf[64]; + gdouble total_utime = 0, total_systime = 0; + guint total_conns = 0; rep = ucl_object_typed_new (UCL_OBJECT); + workers = ucl_object_typed_new (UCL_OBJECT); DL_FOREACH (session->replies, elt) { rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "%P", elt->wrk->pid); @@ -177,6 +180,11 @@ rspamd_control_write_reply (struct rspamd_control_session *session) elt->reply.reply.stat.uptime), "uptime", 0, false); ucl_object_insert_key (cur, ucl_object_fromint ( elt->reply.reply.stat.maxrss), "maxrss", 0, false); + + total_utime += elt->reply.reply.stat.utime; + total_systime += elt->reply.reply.stat.systime; + total_conns += elt->reply.reply.stat.conns; + break; case RSPAMD_CONTROL_RELOAD: ucl_object_insert_key (cur, ucl_object_fromint ( @@ -186,7 +194,22 @@ rspamd_control_write_reply (struct rspamd_control_session *session) break; } - ucl_object_insert_key (rep, cur, tmpbuf, 0, true); + ucl_object_insert_key (workers, cur, tmpbuf, 0, true); + } + + ucl_object_insert_key (rep, workers, "workers", 0, false); + + if (session->cmd.type == RSPAMD_CONTROL_STAT) { + /* Total stats */ + cur = ucl_object_typed_new (UCL_OBJECT); + ucl_object_insert_key (cur, ucl_object_fromint ( + total_conns), "conns", 0, false); + ucl_object_insert_key (cur, ucl_object_fromdouble ( + total_utime), "utime", 0, false); + ucl_object_insert_key (cur, ucl_object_fromdouble ( + total_systime), "systime", 0, false); + + ucl_object_insert_key (rep, cur, "total", 0, false); } rspamd_control_send_ucl (session, rep); |