]> source.dussan.org Git - rspamd.git/commitdiff
* Add percents of spam and ham detected to stat command output
authorcebka@lenovo-laptop <cebka@lenovo-laptop>
Mon, 1 Mar 2010 16:00:03 +0000 (19:00 +0300)
committercebka@lenovo-laptop <cebka@lenovo-laptop>
Mon, 1 Mar 2010 16:00:03 +0000 (19:00 +0300)
rspamc.pl.in
src/controller.c

index d53084509797b3e9e7d72f2b52895b9a7d54c383..86abbc1cda33c9e39de027a38b3875c8ba9fb788 100755 (executable)
@@ -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) {
index 9061563d866bc9f5916cd71155506b6ea06c5558..50b2b5f34118abc19000f1c659eeac924080344c 100644 (file)
@@ -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);