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

Method get_connects

class/projectModel/javaModel.py:2193–2212  ·  view source on GitHub ↗

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

(self, pid)

Source from the content-addressed store, hash-verified

2191 return load_info
2192
2193 def get_connects(self, pid):
2194 ''&#x27;
2195 @name 获取进程连接信息
2196 @author hwliang<2021-08-09>
2197 @param pid<int>
2198 @return dict
2199 ''&#x27;
2200 connects = 0
2201 try:
2202 if pid == 1: return connects
2203 tp = '/proc/' + str(pid) + '/fd/'
2204 if not os.path.exists(tp): return connects
2205 for d in os.listdir(tp):
2206 fname = tp + d
2207 if os.path.islink(fname):
2208 l = os.readlink(fname)
2209 if l.find('socket:') != -1: connects += 1
2210 except:
2211 pass
2212 return connects
2213
2214 def object_to_dict(self, obj):
2215 ''&#x27;

Callers 1

Calls 3

listdirMethod · 0.80
existsMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected