Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
Exact match host name.
Browse files Browse the repository at this point in the history
  • Loading branch information
gshmu committed Jun 9, 2014
1 parent 95d8798 commit a934845
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions set_goagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"""
re_avg_time = re.compile(r'\d+/(\d+)', re.M)
re_loss_percent = re.compile(r'(\d+)%', re.M)
re_find_dns_name = re.compile(r'dNSName=([^:]+)', re.M)
# Exact match host name. old:([^:]+)
re_find_dns_name = re.compile(r'dNSName=[^:]*?\b(google\.\w+\.?\w*)', re.M)

#ip_set = [('0.0.0', min, max), ]
#ip_set = [('203.208.46', 140, 145), ]
Expand Down Expand Up @@ -60,17 +61,18 @@ def run(self):
# Don't check high loss ip's host.
host_name = find_host(self.ip_address) if loss_percent < 80 else None

# wait mutex and add to list
global lock
try:
lock.acquire()
ip_list.append((loss_percent, avg_time, self.ip_address, host_name))
#test enable. 测试用,我还是喜欢屏蔽掉,下边会输出排序好的。
print '%-6s%-4s%-16s%s' % (loss_percent, avg_time, self.ip_address, host_name)
except:
pass
finally:
lock.release()
if host_name is not None:
# wait mutex and add to list
global lock
try:
lock.acquire()
ip_list.append((loss_percent, avg_time, self.ip_address, host_name))
#test enable. 测试用,我还是喜欢屏蔽掉,下边会输出排序好的。
print '%-6s%-4s%-16s%s' % (loss_percent, avg_time, self.ip_address, host_name)
except:
pass
finally:
lock.release()


def list_ping(_set):
Expand Down

1 comment on commit a934845

@gshmu
Copy link
Owner Author

@gshmu gshmu commented on a934845 Jun 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经测试,有些域名很多时候会出现403。
所以,host改为精确匹配。同时只将匹配的加入列表排序输出。

Please sign in to comment.