()
| 160 | |
| 161 | |
| 162 | def _check_netstat(): |
| 163 | debug2(' > netstat') |
| 164 | argv = ['netstat', '-n'] |
| 165 | try: |
| 166 | p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null, |
| 167 | env=get_env()) |
| 168 | content = p.stdout.read().decode("ASCII") |
| 169 | p.wait() |
| 170 | except OSError: |
| 171 | _, e = sys.exc_info()[:2] |
| 172 | log('%r failed: %r' % (argv, e)) |
| 173 | return |
| 174 | |
| 175 | # The same IPs may appear multiple times. Consolidate them so the |
| 176 | # debug message doesn't print the same IP repeatedly. |
| 177 | ip_list = [] |
| 178 | for ip in re.findall(r'\d+\.\d+\.\d+\.\d+', content): |
| 179 | if ip not in ip_list: |
| 180 | ip_list.append(ip) |
| 181 | |
| 182 | for ip in sorted(ip_list): |
| 183 | debug3('< %s' % ip) |
| 184 | check_host(ip) |
| 185 | |
| 186 | |
| 187 | def check_host(hostname): |
nothing calls this directly
no test coverage detected