From: cebka@lenovo-laptop Date: Mon, 1 Mar 2010 16:00:03 +0000 (+0300) Subject: * Add percents of spam and ham detected to stat command output X-Git-Tag: 0.3.0~74 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1b0e6fb87830abe07f2e1ad01da353a4e3f07a83;p=rspamd.git * Add percents of spam and ham detected to stat command output --- diff --git a/rspamc.pl.in b/rspamc.pl.in index d53084509..86abbc1cd 100755 --- a/rspamc.pl.in +++ b/rspamc.pl.in @@ -235,8 +235,8 @@ sub do_control_command { syswrite $sock, "weights $cfg{'statfile'} $len" . $CRLF; syswrite $sock, $input . $CRLF; while (defined (my $reply = <$sock>)) { - last if $line =~ /^END/; - print $_; + last if $reply =~ /^END/; + print $reply; } } elsif ($cfg{'command'} =~ /(reload|shutdown)/i) { diff --git a/src/controller.c b/src/controller.c index 9061563d8..50b2b5f34 100644 --- a/src/controller.c +++ b/src/controller.c @@ -338,8 +338,12 @@ process_stat_command (struct controller_session *session) memory_pool_stat (&mem_st); r = snprintf (out_buf, sizeof (out_buf), "Messages scanned: %u" CRLF, session->worker->srv->stat->messages_scanned); - r += snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as spam: %u" CRLF, session->worker->srv->stat->messages_spam); - r += snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as ham: %u" CRLF, session->worker->srv->stat->messages_ham); + if (session->worker->srv->stat->messages_scanned > 0) { + r += snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as spam: %u, %.2f%%" CRLF, session->worker->srv->stat->messages_spam, + (double)session->worker->srv->stat->messages_spam / (double)session->worker->srv->stat->messages_scanned * 100.); + r += snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as ham: %u, %.2f%%" CRLF, session->worker->srv->stat->messages_ham, + (double)session->worker->srv->stat->messages_ham / (double)session->worker->srv->stat->messages_scanned * 100.); + } r += snprintf (out_buf + r, sizeof (out_buf) - r, "Messages learned: %u" CRLF, session->worker->srv->stat->messages_learned); r += snprintf (out_buf + r, sizeof (out_buf) - r, "Connections count: %u" CRLF, session->worker->srv->stat->connections_count); r += snprintf (out_buf + r, sizeof (out_buf) - r, "Control connections count: %u" CRLF, session->worker->srv->stat->control_connections_count);