Welcome to netmatt — a simple netstat -p |grep LISTEN replacement in Python
From oldest/worst to newest/best:
net-listeners-callout.py- just reformats
netstatoutput (requires root)
- just reformats
net-listeners-proc.py- reads network state and matching commands from
/proc/[pid]/fd/*directly (requires root)
- reads network state and matching commands from
net-listeners-proc-custom.py- matches network state to commands by reading
/proc/pid_inode_mapcreated by kernel module in directorypid_inode_map
- matches network state to commands by reading
net-listeners-proc-unified.py- uses
/proc/pid_inode_mapif exists; otherwise falls back to iterating/proc/[pid]/fd/* - it's the unification of
net-listeners-proc.pyandnet-listeners-proc-custom.py
- uses
pid_inode_map- Linux kernel module to create proc file
/proc/pid_inode_mapso non-root users can get a listing of which processes own which IP:Port combinations
- Linux kernel module to create proc file
Full writeup is over at matt.sh/netmatt