Skip to content

Instantly share code, notes, and snippets.

@vorburger
Created January 11, 2014 10:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vorburger/8369050 to your computer and use it in GitHub Desktop.
Save vorburger/8369050 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# https://lists.fedoraproject.org/pipermail/test/2009-May/081959.html
# from http://askubuntu.com/questions/4499/how-can-i-diagnose-debug-maximum-number-of-clients-reached-x-errors/6639#6639
from subprocess import Popen, PIPE
client_sockets = []
match = 0
ns = Popen(["netstat", "-an", "--unix"], stdout=PIPE)
output = ns.communicate()[0]
for line in output.split('\n'):
if line.find("X11-unix") != -1:
match = 1
elif match:
match = 0
print line
lineSplit = line.split()
lineLen = len(lineSplit)
print lineLen
if lineLen == 6:
inode = lineSplit[5]
elif lineLen == 9:
inode = lineSplit[7]
else:
inode = line.split()[6]
print inode
client_sockets.append(inode)
lsof = Popen(["lsof", "-U", "+c0", "-w"], stdout=PIPE)
output = lsof.communicate()[0]
for line in output.split('\n'):
try:
inode = line.split()[7]
if inode in client_sockets:
print line
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment