mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #39189 from morganwillcock/sockstat
Fix NetBSD sockstat parsing
This commit is contained in:
commit
30f83156cb
@ -1057,23 +1057,23 @@ def _netbsd_remotes_on(port, which_end):
|
||||
Parses output of shell 'sockstat' (NetBSD)
|
||||
to get connections
|
||||
|
||||
$ sudo sockstat -4
|
||||
$ sudo sockstat -4 -n
|
||||
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
|
||||
root python2.7 1456 29 tcp4 *.4505 *.*
|
||||
root python2.7 1445 17 tcp4 *.4506 *.*
|
||||
root python2.7 1294 14 tcp4 127.0.0.1.11813 127.0.0.1.4505
|
||||
root python2.7 1294 41 tcp4 127.0.0.1.61115 127.0.0.1.4506
|
||||
root python2.7 1456 29 tcp *.4505 *.*
|
||||
root python2.7 1445 17 tcp *.4506 *.*
|
||||
root python2.7 1294 14 tcp 127.0.0.1.11813 127.0.0.1.4505
|
||||
root python2.7 1294 41 tcp 127.0.0.1.61115 127.0.0.1.4506
|
||||
|
||||
$ sudo sockstat -4 -c -p 4506
|
||||
$ sudo sockstat -4 -c -n -p 4506
|
||||
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
|
||||
root python2.7 1294 41 tcp4 127.0.0.1.61115 127.0.0.1.4506
|
||||
root python2.7 1294 41 tcp 127.0.0.1.61115 127.0.0.1.4506
|
||||
'''
|
||||
|
||||
port = int(port)
|
||||
remotes = set()
|
||||
|
||||
try:
|
||||
cmd = salt.utils.shlex_split('sockstat -4 -c -p {0}'.format(port))
|
||||
cmd = salt.utils.shlex_split('sockstat -4 -c -n -p {0}'.format(port))
|
||||
data = subprocess.check_output(cmd) # pylint: disable=minimum-python-version
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.error('Failed "sockstat" with returncode = {0}'.format(ex.returncode))
|
||||
@ -1085,7 +1085,7 @@ def _netbsd_remotes_on(port, which_end):
|
||||
chunks = line.split()
|
||||
if not chunks:
|
||||
continue
|
||||
# ['root', 'python2.7', '1456', '37', 'tcp4',
|
||||
# ['root', 'python2.7', '1456', '37', 'tcp',
|
||||
# '127.0.0.1.4505-', '127.0.0.1.55703']
|
||||
# print chunks
|
||||
if 'COMMAND' in chunks[1]:
|
||||
|
Loading…
Reference in New Issue
Block a user