I have a script that uses tshark in conjunction to gawk to get statistics on the number of captured packet per detected IPs. Gawk is however not updating the screen properly but I cannot find a better way to do it.
Which terminal based program or script would you use to monitor newly found IPs and and count the number of packet of those IPs.
I need the script/utility to be do statistics in a dynamical fashion, along the packet capture.
#!/bin/bash
# Monitor the number of packets per newly found IP (source or destination) using ngrep
ngrep|grep -oE "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | tee /root/.config/geany/.$(date-all) | gawk -F '\t' -v clear="$(tput clear)" '
BEGIN{PROCINFO["sorted_in"] = "@ind_str_asc"}
{
count[$1 ? $1 : "Unknown"]++
count[$2 ? $2 : "Unknown"]++
printf "%s", clear
for (c in count)
printf "%5d %s\n", count[c], c
}' |tee /root/.config/geany/.ip-stat-$(date-all)