@load mysite # get local_nets global conn_count = 0; global conn_per_orig: table[addr] of count &default=0; global conn_attempt_per_orig: table[addr] of count &default=0; function print_results() { print fmt("Total number of successful connections: %d", conn_count); for ( orig in conn_per_orig ) { print fmt("Number successful connections from host %s: %d out of %d attempts", orig, conn_per_orig[orig], conn_attempt_per_orig[orig] ); } } event connection_established(c: connection) { local id = c$id; ++conn_count; if (! is_local_addr(id$orig_h) ) # only count remote hosts ++conn_per_orig[id$orig_h]; } event new_connection(c: connection) { local orig = c$id$orig_h; if (! is_local_addr(orig) ) # only count remote hosts ++conn_attempt_per_orig[orig]; } event bro_done() { print_results(); }