diff --git a/pupy/modules/netstat.py b/pupy/modules/netstat.py index 61d2e64e..dd69ef3f 100644 --- a/pupy/modules/netstat.py +++ b/pupy/modules/netstat.py @@ -61,7 +61,9 @@ class NetStatModule(PupyModule): if limit and not stype in limit: continue - if connection['status'] in ('CLOSE_WAIT', 'TIME_WAIT', 'TIME_WAIT2'): + if connection.get('me'): + color = 'green' + elif connection['status'] in ('CLOSE_WAIT', 'TIME_WAIT', 'TIME_WAIT2'): color = 'darkgrey' elif ( '127.0.0.1' in connection['laddr'] or '::1' in connection['laddr'] ): color = 'grey' diff --git a/pupy/packages/all/pupyps.py b/pupy/packages/all/pupyps.py index 5b4906d1..4a225327 100644 --- a/pupy/packages/all/pupyps.py +++ b/pupy/packages/all/pupyps.py @@ -100,6 +100,8 @@ def users(): def connections(): connections = [] + me = psutil.Process() + for connection in psutil.net_connections(): obj = { k:v for k,v in connection.__dict__.iteritems() } if connection.pid: @@ -108,6 +110,11 @@ def connections(): 'pid', 'exe', 'name', 'username' }) ) + if connection.pid == me.pid: + obj.update({ + 'me': True + }) + connections.append(obj) return connections