From 53b388b669df265fd4621fb863e0d2119e9a18c7 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 16 May 2010 17:52:05 +0200 Subject: [PATCH] Improve flow hash debugging, switch to csv output. --- src/flow-hash.c | 5 ++++- src/flow.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/flow-hash.c b/src/flow-hash.c index 72100b11d8..1f98f831b2 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -79,6 +79,9 @@ void FlowHashDebugInit(void) { SCSpinInit(&flow_hash_count_lock, 0); #endif flow_hash_count_fp = fopen("flow-debug.log", "w+"); + if (flow_hash_count_fp != NULL) { + fprintf(flow_hash_count_fp, "ts,all,tcp,udp,icmp,other\n"); + } } void FlowHashDebugPrint(uint32_t ts) { @@ -98,7 +101,7 @@ void FlowHashDebugPrint(uint32_t ts) { avg_icmp= (float)(flow_hash_loop_count[FLOW_DEBUG_STATS_PROTO_ICMP]/(float)(flow_hash_count[FLOW_DEBUG_STATS_PROTO_ICMP])); if (flow_hash_loop_count[FLOW_DEBUG_STATS_PROTO_OTHER] != 0) avg_other= (float)(flow_hash_loop_count[FLOW_DEBUG_STATS_PROTO_OTHER]/(float)(flow_hash_count[FLOW_DEBUG_STATS_PROTO_OTHER])); - fprintf(flow_hash_count_fp, "%"PRIu32": all %02.3f, tcp %02.3f, udp %02.3f, icmp %02.3f, other %02.3f\n", ts, avg_all, avg_tcp, avg_udp, avg_icmp, avg_other); + fprintf(flow_hash_count_fp, "%"PRIu32",%02.3f,%02.3f,%02.3f,%02.3f,%02.3f\n", ts, avg_all, avg_tcp, avg_udp, avg_icmp, avg_other); fflush(flow_hash_count_fp); memset(&flow_hash_count, 0, sizeof(flow_hash_count)); memset(&flow_hash_loop_count, 0, sizeof(flow_hash_loop_count)); diff --git a/src/flow.c b/src/flow.c index bbd23f03d1..f8c3ba6681 100644 --- a/src/flow.c +++ b/src/flow.c @@ -708,13 +708,13 @@ void *FlowManagerThread(void *td) } /* Get the time */ - last_sec = (uint32_t)ts.tv_sec; memset(&ts, 0, sizeof(ts)); TimeGet(&ts); SCLogDebug("ts %" PRIdMAX "", (intmax_t)ts.tv_sec); - if (((uint32_t)ts.tv_sec - last_sec) > 60) { + if (((uint32_t)ts.tv_sec - last_sec) > 600) { FlowHashDebugPrint((uint32_t)ts.tv_sec); + last_sec = (uint32_t)ts.tv_sec; } /* see if we still have enough spare flows */