/** * Print out some of the common information about the Flow Processor * configuration * */ static void DisplayFlowConfig(void) { SPPFLOW_CONFIG *cp = &s_config; FLOWCACHE *fcp = &s_fcache; LogMessage(",-----------[Flow Config]----------------------\n"); LogMessage("| Stats Interval: %d\n", cp->stats_interval); LogMessage("| Hash Method: %d\n", cp->hashid); LogMessage("| Memcap: %d\n", cp->memcap); LogMessage("| Rows : %d\n", flowcache_row_count(fcp)); LogMessage("| Overhead Bytes: %d(%%%.2lf)\n", flowcache_overhead_bytes(fcp), calc_percent(flowcache_overhead_bytes(fcp),cp->memcap)); LogMessage("`----------------------------------------------\n"); }
void flowcache_stats(FILE *stream, FLOWCACHE *flowcachep) { int could_hold; int i; time_t low_time = 0, high_time = 0, diff_time = 0; int diff_hours = 0, diff_min = 0, diff_sec = 0; int diff_blocks = 0; FLOW *flow_mrup, *flow_lrup; #ifdef INDEPTH_DEBUG printf("table max depth: %u\n", sfxhash_maxdepth(flowcachep->ipv4_table)); #endif /* INDEPTH_DEBUG */ if((flowcache_mru(flowcachep, &flow_mrup) == FLOW_SUCCESS) && (flowcache_lru(flowcachep, &flow_lrup) == FLOW_SUCCESS)) { low_time = flow_lrup->stats.last_packet; high_time = flow_mrup->stats.last_packet; diff_time = high_time - low_time; diff_hours = diff_time / 3600; diff_min = (diff_time - (3600 * diff_hours)) / 60; diff_sec = diff_time % 60; } diff_blocks = flowcachep->ipv4_table->mc.nblocks - flowcache_overhead_blocks(flowcachep); //could_hold = flowcachep->ipv4_table->mc.memcap / // (sizeof(FLOW) + sizeof(FLOWKEY) + sizeof(SFXHASH_NODE)); /* this is a bad calculation -- should clean this up */ if(diff_blocks > 0) { could_hold = (flowcachep->ipv4_table->mc.memused - flowcache_overhead_bytes(flowcachep)) / diff_blocks; could_hold = flowcachep->ipv4_table->mc.memcap / could_hold; } else { could_hold = diff_blocks; } flow_printf(",----[ FLOWCACHE STATS ]----------\n"); flow_printf("Memcap: %u Overhead Bytes %u used(%%%f)/blocks (%u/%u)\nOverhead blocks: %u Could Hold: (%u)\n", flowcachep->ipv4_table->mc.memcap, flowcache_overhead_bytes(flowcachep), calc_percent(flowcachep->ipv4_table->mc.memused, flowcachep->ipv4_table->mc.memcap), flowcachep->ipv4_table->mc.memused, flowcachep->ipv4_table->mc.nblocks, flowcache_overhead_blocks(flowcachep), could_hold); flow_printf("IPV4 count: %u frees: %u\nlow_time: %u, high_time: %u," " diff: %dh:%02d:%02ds\n", sfxhash_count(flowcachep->ipv4_table), sfxhash_anr_count(flowcachep->ipv4_table), (unsigned) low_time, (unsigned) high_time, diff_hours,diff_min,diff_sec); flow_printf(" finds: " STDu64 " reversed: " STDu64 "(%%%f) \n find_success: " STDu64 " " "find_fail: " STDu64 "\npercent_success: (%%%f) new_flows: " STDu64 "\n", flowcachep->total.find_ops, flowcachep->total.reversed_ops, calc_percent64(flowcachep->total.reversed_ops, flowcachep->total.find_ops), flowcachep->total.find_success, flowcachep->total.find_fail, calc_percent64(flowcachep->total.find_success, flowcachep->total.find_ops), flowcachep->total.new_flows); for(i=0;i<256;i++) { if(flowcachep->per_proto[i].find_ops > 0) { flow_printf(" Protocol: %d (%%%f)\n" " finds: " STDu64 "\n" " reversed: " STDu64 "(%%%f)\n" " find_success: " STDu64 "\n" " find_fail: " STDu64 "\n" " percent_success: (%%%f)\n" " new_flows: " STDu64 "\n", i, calc_percent64(flowcachep->per_proto[i].find_ops, flowcachep->total.find_ops), flowcachep->per_proto[i].find_ops, flowcachep->per_proto[i].reversed_ops, calc_percent64(flowcachep->per_proto[i].reversed_ops, flowcachep->per_proto[i].find_ops), flowcachep->per_proto[i].find_success, flowcachep->per_proto[i].find_fail, calc_percent64(flowcachep->per_proto[i].find_success, flowcachep->per_proto[i].find_ops), flowcachep->per_proto[i].new_flows); } } }