@name 获取进程连接信息 @author hwliang<2021-08-09> @param pid @return dict
(self, pid)
| 2191 | return load_info |
| 2192 | |
| 2193 | def get_connects(self, pid): |
| 2194 | ''' |
| 2195 | @name 获取进程连接信息 |
| 2196 | @author hwliang<2021-08-09> |
| 2197 | @param pid<int> |
| 2198 | @return dict |
| 2199 | ''' |
| 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 | ''' |
no test coverage detected