Listen or established connection per port

Hi everyone,

Is there a way to collect the number of establised connection per port ? Currently i’m using inputs.netstat but i’m just getting the number of connection for all port. If possible I would like to isolate imap and smtp ports.

Regards