process_stat_command (struct controller_session *session)
{
gchar out_buf[BUFSIZ];
- gint r;
- guint64 used, total, rev;
+ gint r, i;
+ guint64 used, total, rev, ham = 0, spam = 0;
time_t ti;
memory_pool_stat_t mem_st;
struct classifier_config *ccf;
memory_pool_stat (&mem_st);
r = rspamd_snprintf (out_buf, sizeof (out_buf), "Messages scanned: %ud" CRLF, session->worker->srv->stat->messages_scanned);
if (session->worker->srv->stat->messages_scanned > 0) {
- r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as spam: %ud, %.2f%%" CRLF, session->worker->srv->stat->messages_spam,
- (double)session->worker->srv->stat->messages_spam / (double)session->worker->srv->stat->messages_scanned * 100.);
- r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as ham: %ud, %.2f%%" CRLF, session->worker->srv->stat->messages_ham,
- (double)session->worker->srv->stat->messages_ham / (double)session->worker->srv->stat->messages_scanned * 100.);
+ for (i = METRIC_ACTION_REJECT; i <= METRIC_ACTION_NOACTION; i ++) {
+ r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages with action %s: %ud" CRLF,
+ str_action_metric (i), session->worker->srv->stat->actions_stat[i]);
+ if (i < METRIC_ACTION_GREYLIST) {
+ spam += session->worker->srv->stat->actions_stat[i];
+ }
+ else {
+ ham += session->worker->srv->stat->actions_stat[i];
+ }
+ }
+ r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as spam: %ud, %.2f%%" CRLF, spam,
+ (double)spam / (double)session->worker->srv->stat->messages_scanned * 100.);
+ r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages treated as ham: %ud, %.2f%%" CRLF, ham,
+ (double)ham / (double)session->worker->srv->stat->messages_scanned * 100.);
}
r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages learned: %ud" CRLF, session->worker->srv->stat->messages_learned);
r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Connections count: %ud" CRLF, session->worker->srv->stat->connections_count);
*/
struct rspamd_stat {
guint messages_scanned; /**< total number of messages scanned */
- guint messages_spam; /**< messages treated as spam */
- guint messages_ham; /**< messages treated as ham */
- guint connections_count; /**< total connections count */
- guint control_connections_count; /**< connections count to control interface */
+ guint actions_stat[METRIC_ACTION_NOACTION + 1]; /**< statistic for each action */
+ guint connections_count; /**< total connections count */
+ guint control_connections_count; /**< connections count to control interface */
guint messages_learned; /**< messages learned */
guint fuzzy_hashes; /**< number of fuzzy hashes stored */
guint fuzzy_hashes_expired; /**< number of fuzzy hashes expired */
metric_res->metric);
}
+ if (G_LIKELY (action <= METRIC_ACTION_NOACTION)) {
+ task->worker->srv->stat->actions_stat[action] ++;
+ }
+
if (!task->is_json) {
r = print_metric_data_rspamc (task, outbuf, sizeof (outbuf), metric_res, metric_res->metric, ms, rs, action);
}
/* Increase counters */
task->worker->srv->stat->messages_scanned++;
- if (default_score >= default_required_score) {
- task->worker->srv->stat->messages_spam ++;
- }
- else {
- task->worker->srv->stat->messages_ham ++;
- }
return TRUE;
}
}
task->worker->srv->stat->messages_scanned++;
- if (default_score >= default_required_score) {
- task->worker->srv->stat->messages_spam ++;
- }
- else {
- task->worker->srv->stat->messages_ham ++;
- }
return TRUE;
}