summaryrefslogtreecommitdiffstats
path: root/src/libserver/rspamd_control.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-12 11:49:50 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-12 11:49:50 +0100
commit783f85f3df791a3f948acd9554094d7b352a8d9b (patch)
tree901b35e54eb6096f281fb3f7c1f54f4eb595a9a6 /src/libserver/rspamd_control.c
parent3b91533451ae4aa258594f604803d383a92eda3d (diff)
downloadrspamd-783f85f3df791a3f948acd9554094d7b352a8d9b.tar.gz
rspamd-783f85f3df791a3f948acd9554094d7b352a8d9b.zip
Handle stats command.
Diffstat (limited to 'src/libserver/rspamd_control.c')
-rw-r--r--src/libserver/rspamd_control.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index d1861a5af..3217798ce 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -334,12 +334,25 @@ rspamd_control_default_cmd_handler (gint fd,
{
struct rspamd_control_reply rep;
gssize r;
+ struct rusage rusg;
memset (&rep, 0, sizeof (rep));
rep.type = cmd->type;
switch (cmd->type) {
case RSPAMD_CONTROL_STAT:
+ if (getrusage (RUSAGE_SELF, &rusg) == -1) {
+ msg_err ("cannot get rusage stats: %s",
+ strerror (errno));
+ }
+ else {
+ rep.reply.stat.utime = tv_to_double (&rusg.ru_utime);
+ rep.reply.stat.systime = tv_to_double (&rusg.ru_stime);
+ rep.reply.stat.maxrss = rusg.ru_maxrss;
+ }
+
+ rep.reply.stat.conns = cd->worker->nconns;
+ rep.reply.stat.utime = rspamd_get_calendar_ticks () - cd->worker->start_time;
break;
case RSPAMD_CONTROL_RELOAD:
break;