MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / get_connects

Method get_connects

class/projectModel/nodejsModel.py:1813–1831  ·  view source on GitHub ↗

@name 获取进程连接信息 @author hwliang<2021-08-09> @param pid @return dict

(self,pid)

Source from the content-addressed store, hash-verified

1811
1812
1813 def get_connects(self,pid):
1814 ''&#x27;
1815 @name 获取进程连接信息
1816 @author hwliang<2021-08-09>
1817 @param pid<int>
1818 @return dict
1819 ''&#x27;
1820 connects = 0
1821 try:
1822 if pid == 1: return connects
1823 tp = '/proc/' + str(pid) + '/fd/'
1824 if not os.path.exists(tp): return connects
1825 for d in os.listdir(tp):
1826 fname = tp + d
1827 if os.path.islink(fname):
1828 l = os.readlink(fname)
1829 if l.find('socket:') != -1: connects += 1
1830 except:pass
1831 return connects
1832
1833
1834 def format_connections(self,connects):

Callers 1

Calls 3

listdirMethod · 0.80
existsMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected