custom-intranet/utils/netstat.py
2026-11-08 16:49:31 -07:00

12 lines
297 B
Python

# SPDX-FileCopyrightText: 2017 Open Networking Foundation
#
# SPDX-License-Identifier: Apache-2.0
import psutil
def check_listening_on_port(port):
for c in psutil.net_connections(kind='inet'):
if c.status == 'LISTEN' and c.laddr[1] == port:
return True
return False