]> source.dussan.org Git - rspamd.git/commitdiff
* Add statistics for fuzzy storage
authorcebka@lenovo-laptop <cebka@lenovo-laptop>
Wed, 17 Mar 2010 14:58:31 +0000 (17:58 +0300)
committercebka@lenovo-laptop <cebka@lenovo-laptop>
Wed, 17 Mar 2010 14:58:31 +0000 (17:58 +0300)
src/controller.c
src/fuzzy_storage.c
src/main.h

index 4133aad1274b23c58e490aa439db7bc50f921edf..64df87d6c6d80c3c25ba6c4cd7f9852d6872acc0 100644 (file)
@@ -354,6 +354,8 @@ process_stat_command (struct controller_session *session)
        r += snprintf (out_buf + r, sizeof (out_buf) - r, "Shared chunks allocated: %ld" CRLF, (long int)mem_st.shared_chunks_allocated);
        r += snprintf (out_buf + r, sizeof (out_buf) - r, "Chunks freed: %ld" CRLF, (long int)mem_st.chunks_freed);
        r += snprintf (out_buf + r, sizeof (out_buf) - r, "Oversized chunks: %ld" CRLF, (long int)mem_st.oversized_chunks);
+       r += snprintf (out_buf + r, sizeof (out_buf) - r, "Fuzzy hashes stored: %u" CRLF, session->worker->srv->stat->fuzzy_hashes);
+       r += snprintf (out_buf + r, sizeof (out_buf) - r, "Fuzzy hashes expired: %u" CRLF, session->worker->srv->stat->fuzzy_hashes_expired);
        /* Now write statistics for each statfile */
        cur_cl = g_list_first (session->cfg->classifiers);
        while (cur_cl) {
index c3a29e17f3919f31cf580eb579373cf3102a9143..f6ed7b0d6d185008e15216dbe7e84f07752f1ec0 100644 (file)
@@ -60,6 +60,7 @@ static uint32_t                 mods = 0;
 /* For evtimer */
 static struct timeval           tmv;
 static struct event             tev;
+static struct rspamd_stat      *server_stat;
 
 struct rspamd_fuzzy_node {
        int32_t                         value;
@@ -141,6 +142,8 @@ sync_cache (struct rspamd_worker *wrk)
                                cur = g_list_next (cur);
                                g_queue_delete_link (hashes[i], tmp);
                                bloom_del (bf, node->h.hash_pipe);
+                               server_stat->fuzzy_hashes_expired ++;
+                               server_stat->fuzzy_hashes --;
                                g_free (node);
                                continue;
                        }
@@ -224,6 +227,7 @@ read_hashes_file (struct rspamd_worker *wrk)
                }
                g_queue_push_head (hashes[node->h.block_size % BUCKETS], node);
                bloom_add (bf, node->h.hash_pipe);
+               server_stat->fuzzy_hashes ++;
        }
 
        (void)unlock_file (fd, FALSE);
@@ -314,6 +318,7 @@ process_write_command (struct fuzzy_cmd *cmd)
        g_queue_push_head (hashes[cmd->blocksize % BUCKETS], h);
        bloom_add (bf, cmd->hash);
        mods++;
+       server_stat->fuzzy_hashes ++;
        msg_info ("fuzzy hash was successfully added");
 
        return TRUE;
@@ -345,6 +350,7 @@ process_delete_command (struct fuzzy_cmd *cmd)
                        g_queue_delete_link (hashes[cmd->blocksize % BUCKETS], tmp);
                        bloom_del (bf, cmd->hash);
                        msg_info ("fuzzy hash was successfully deleted");
+                       server_stat->fuzzy_hashes --;
                        res = TRUE;
                        mods++;
                        continue;
@@ -468,6 +474,8 @@ start_fuzzy_storage (struct rspamd_worker *worker)
 
        event_init ();
 
+       server_stat = worker->srv->stat;
+
        init_signals (&signals, sig_handler);
        sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
@@ -503,6 +511,7 @@ start_fuzzy_storage (struct rspamd_worker *worker)
 
        gperf_profiler_init (worker->srv->cfg, "fuzzy");
 
+
        event_loop (0);
        exit (EXIT_SUCCESS);
 }
index 0fffe15186b1570c0ccb6cd1a07b2f60fd44888b..f79c7cd6553aad5df7b57be27457771a169c38ea 100644 (file)
@@ -84,6 +84,8 @@ struct rspamd_stat {
        unsigned int connections_count;                                                         /**< total connections count                                            */
        unsigned int control_connections_count;                                         /**< connections count to control interface                     */
        unsigned int messages_learned;                                                          /**< messages learned                                                           */
+       unsigned int fuzzy_hashes;                                                                      /**< number of fuzzy hashes stored                                      */
+       unsigned int fuzzy_hashes_expired;                                                      /**< number of fuzzy hashes expired                                     */
 };
 
 /**