Andrey Fedorov Andrey Fedorov - 9 months ago 52
Python Question

How do I access netstat data in Python?

I'm trying to need to access/parse all outgoing connections on a particular port number on a Linux machine using a Python script. The simplest implementation seems to be to open a subprocess for netstat and parse its stdout.

I imagine someone somewhere has had this problem before, and am surprised not to find any netstat parsers online. Is this just not big enough of a problem for people to feel the need to share?


The basic information you could need can be found at /proc documentation If you want to see a a example take a look at: A python netstat in less than 100 lines of code