- 论坛徽章:
- 16
|
首先祝各位国庆快乐,现在来请教个问题,现在下边的文本内容如下,现在要统计 node开头的行里面3个范围(53,102),(103,122),(223,376)里面有多少个active和down的,注意53-102,103-122,223-376这3个范围里可能有没出现在文本里,比如node-245.xxxx-yy.com。 注意某些主机名字是node-xxx,有的是node-NNN.xxx-yy.com。
同时要统计 renderG开头的行的'1-202','167-181(注意这里的167-181是需要排除掉的,其实就是1-166,182-202这2个当做一个整体'这个范围里active/down的个数, 还有 '167-204','181-202'(同理排除181-202,然后当做一个整体( 这个里的active/down的个数。范围里的主机未必在文本出现。
这个问题用python处理非常容易理解。就把文本$1,$4放字典里面,然后把既定范围放list, 判断list是否在dict的key里面,再就放一个新的dict,最后统计新的dict的active/down的数量,最后清空dict.- #!/usr/bin/env python
- import subprocess
- spec ={'node': ((53,102),(103,122),(223,376)),
- 'renderG' : (('1-166','181-202'),('167-180','203-204'))
- }
- cmd ="qbhosts | awk '/node/||/renderG/'"
- output = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE).communicate()[0]
- d ={}
- for i in output.splitlines():
- items = i.split()
- if not items[0].endswith("xxx.com"):
- items[0]=items[0]+".xxx.com"
- d[items[0]] = items[3]
- for k,v in spec.items() :
- for i in v:
- # set default value for m1,m2.
- m1=m2=None
- if type(i[0]) == str or type(i[1]) == str :
- begin = i[0].split("-")[0]
- m1 = i[0].split("-")[1]
- m2 = i[1].split("-")[0]
- end = i[1].split("-")[1]
- host = [ "%s-%03d.xxx.com" %(k,m ) for m in xrange(int(begin),int(end)+1) if m not in xrange(int(m1)+1,int(m2))]
- else :
- begin,end = i[0],i[1]
- host = [ "%s-%03d.xxx.com" %(k,m) for m in xrange(begin,end+1) ]
- #print "--------\n",host,"\n----------------"
- temp = {}
- for h in host :
- if h in d.keys():
- temp[h] = d[h]
- #else : print "%s doesn't exist."%h
- act = len([k1 for k1,v1 in temp.items() if v1 =="active" ])
- down = len([k1 for k1,v1 in temp.items() if v1 =="down" ])
- # duplicate hostname node-347 and node-238
- if m1 and m2 :
- print "\n%s[%03d-%03d,%03d-%03d].xxx.com have %d active node(s), %d down node(s)\n" % (k,int(begin),int(m1),int(m2),int(end),act,down)
- else:
- print "\n%s[%03d-%03d].xxx.com have %d active node(s), %d down node(s)\n" % (k,int(begin),int(end),act,down)
- temp.clear()
复制代码 renderG-001.xxxx-yy.com 00:22:19:AE:97:90 10.7.16.1 active 1/1 /efx G96
renderG-002.xxxx-yy.com 00:22:19:AE:97:9D 10.7.16.2 active 1/1 /efx G96
renderG-003.xxxx-yy.com 00:22:19:AE:97:AA 10.7.16.3 active 1/1 /efx G96
renderG-004.xxxx-yy.com 00:22:19:AE:97:B7 10.7.16.4 active 1/1 /efx G96
renderG-005.xxxx-yy.com 00:22:19:AE:97:C4 10.7.16.5 active 1/1 /efx G96
renderG-006.xxxx-yy.com 00:22:19:AE:97 1 10.7.16.6 active 1/1 /efx G96
renderG-007.xxxx-yy.com 00:22:19:AE:97 E 10.7.16.7 active 1/1 /efx G96
renderG-008.xxxx-yy.com 00:22:19:AE:97:EB 10.7.16.8 active 1/1 /efx G96
renderG-009.xxxx-yy.com 00:26:B9:28:47 E 172.16.5.144 down 0/0 /efx G96
renderG-009.xxxx-yy.com 00:22:19:C1:B9:0D 10.7.16.9 active 1/1 /efx G96
renderG-009.xxxx-yy.com 00:26:B9:28:47 1 10.7.16.9 down 0/1 /efx G96
renderG-010.xxxx-yy.com 00:22:19:AE:98:05 10.7.16.10 active 1/1 /efx G96
renderG-011.xxxx-yy.com 00:22:19:AE:98:12 10.7.16.11 active 1/1 /efx G96
renderG-012.xxxx-yy.com 00:22:19:AE:98:1F 10.7.16.12 active 1/1 /efx G96
renderG-013.xxxx-yy.com 00:22:19:AE:98:2C 10.7.16.13 active 1/1 /efx G96
renderG-014.xxxx-yy.com 00:22:19:AE:98:39 10.7.16.14 active 1/1 /efx G96
renderG-015.xxxx-yy.com 00:22:19:AE:98:46 10.7.16.15 active 1/1 /efx G96
renderG-016.xxxx-yy.com 00:22:19:AE:98:53 10.7.16.16 active 1/1 /efx G96
renderG-017.xxxx-yy.com 00:26:B9:28:8F 2 10.7.16.21 active 1/1 /efx G96
renderG-018.xxxx-yy.com 00:26:B9:28:8F F 10.7.16.22 down 0/1 /efx G96
renderG-019.xxxx-yy.com 00:26:B9:28:8F:C5 10.7.16.20 active 1/1 /efx G96
renderG-020.xxxx-yy.com 00:26:B9:28:8F:B8 10.7.16.19 active 1/1 /efx G96
renderG-021.xxxx-yy.com 00:26:B9:28:8F:AB 10.7.16.18 active 1/1 /efx G96
renderG-022.xxxx-yy.com 00:26:B9:28:90:3A 10.7.16.29 active 1/1 /efx G96
renderG-023.xxxx-yy.com 00:26:B9:28:90:2D 10.7.16.28 active 1/1 /efx G96
renderG-024.xxxx-yy.com 00:26:B9:28:0F:73 10.7.16.24 active 1/1 /efx G96
renderG-025.xxxx-yy.com 00:26:B9:28:90:47 10.7.16.30 active 1/1 /efx G96
renderG-026.xxxx-yy.com 00:26:B9:28:90:20 10.7.16.27 active 1/1 /efx G96
renderG-027.xxxx-yy.com 00:26:B9:28:90:13 10.7.16.26 active 1/1 /efx G96
renderG-028.xxxx-yy.com 00:26:B9:28:90:54 10.7.16.31 active 1/1 /efx G96
renderG-029.xxxx-yy.com 00:26:B9:28:90:06 10.7.16.25 active 1/1 /efx G96
renderG-030.xxxx-yy.com 00:26:B9:28:90:61 10.7.16.32 active 1/1 /efx G96
renderG-031.xxxx-yy.com 00:26:B9:28:8F:9E 10.7.16.17 active 1/1 /efx G96
renderG-032.xxxx-yy.com 00:26:B9:28:8F:EC 10.7.16.23 active 1/1 /efx G96
renderG-033.xxxx-yy.com 00:26:B9:28:54:FD 10.7.16.33 down 0/1 /efx G96
renderG-034.xxxx-yy.com 00:26:B9:28:55:0A 10.7.16.34 active 1/1 /efx G96
renderG-035.xxxx-yy.com 00:26:B9:28:55:17 10.7.16.35 active 1/1 /efx G96
renderG-036.xxxx-yy.com 00:26:B9:28:55:24 10.7.16.36 active 1/1 /efx G96
renderG-037.xxxx-yy.com 00:26:B9:28:55:31 10.7.16.37 active 1/1 /efx G96
renderG-038.xxxx-yy.com 00:26:B9:28:55:3E 10.7.16.38 active 1/1 /efx G96
renderG-039.xxxx-yy.com 00:26:B9:28:55:4B 10.7.16.39 active 1/1 /efx G96
renderG-040.xxxx-yy.com 00:26:B9:28:55:58 10.7.16.40 active 1/1 /efx G96
renderG-041.xxxx-yy.com 00:26:B9:28:55:65 10.7.16.41 active 1/1 /efx G96
renderG-042.xxxx-yy.com 00:26:B9:28:55:72 10.7.16.42 active 1/1 /efx G96
renderG-043.xxxx-yy.com 00:26:B9:28:55:7F 10.7.16.43 active 1/1 /efx G96
renderG-044.xxxx-yy.com 00:26:B9:28:55:8C 10.7.16.44 active 1/1 /efx G96
renderG-045.xxxx-yy.com 00:26:B9:28:55:99 10.7.16.45 active 1/1 /efx G96
renderG-046.xxxx-yy.com 00:26:B9:28:55:A6 10.7.16.46 active 1/1 /efx G96
renderG-047.xxxx-yy.com 00:26:B9:28:55:B3 10.7.16.47 active 1/1 /efx G96
renderG-048.xxxx-yy.com 00:26:B9:28:55:C0 10.7.16.48 active 1/1 /efx G96
renderG-049.xxxx-yy.com 00:26:B9:28:0E:BD 10.7.16.49 active 1/1 /efx G96
renderG-050.xxxx-yy.com 00:26:B9:28:0E:CA 10.7.16.50 active 1/1 /efx G96
renderG-051.xxxx-yy.com 00:26:B9:28:0E 7 10.7.16.51 active 1/1 /efx G96
renderG-052.xxxx-yy.com 00:26:B9:28:0E:E4 10.7.16.52 active 1/1 /efx G96
renderG-054.xxxx-yy.com 00:26:B9:28:0E:FE 10.7.16.54 active 1/1 /efx G96
renderG-055.xxxx-yy.com 00:26:B9:28:0F:0B 10.7.16.55 active 1/1 /efx G96
renderG-056.xxxx-yy.com 00:26:B9:28:0F:18 10.7.16.56 active 1/1 /efx G96
renderG-057.xxxx-yy.com 00:26:B9:28:0F:25 10.7.16.57 active 1/1 /efx G96
renderG-058.xxxx-yy.com 00:26:B9:28:0F:32 10.7.16.58 active 1/1 /efx G96
renderG-059.xxxx-yy.com 00:26:B9:28:0F:3F 10.7.16.59 active 1/1 /efx G96
renderG-060.xxxx-yy.com 00:26:B9:28:0F:4C 10.7.16.60 active 1/1 /efx G96
renderG-061.xxxx-yy.com 00:26:B9:28:0F:59 10.7.16.61 active 1/1 /efx G96
renderG-062.xxxx-yy.com 00:26:B9:28:0F:66 10.7.16.62 active 1/1 /efx G96
renderG-063.xxxx-yy.com 00:22:19:C1:B9:00 172.16.10.50 down 0/0 /efx G96
renderG-063.xxxx-yy.com 00:22:19:C1:B9:41 172.16.5.83 active 1/1 /efx G96
renderG-063.xxxx-yy.com 00:26:B9:28:47:C4 10.7.16.63 down 0/0 /efx G96
renderG-064.xxxx-yy.com 00:26:B9:28:0F:80 10.7.16.64 active 1/1 /efx G96
renderG-065.xxxx-yy.com 00:26:B9:28:C8:9C 10.7.16.65 active 1/1 /efx G96
renderG-066.xxxx-yy.com 00:26:B9:28:C8:A9 10.7.16.66 active 1/1 /efx G96
renderG-067.xxxx-yy.com 00:26:B9:28:C8:B6 10.7.16.67 active 1/1 /efx G96
renderG-068.xxxx-yy.com 00:26:B9:28:C8:C3 10.7.16.68 active 1/1 /efx G96
renderG-069.xxxx-yy.com 00:26:B9:28:C8 0 10.7.16.69 active 1/1 /efx G96
renderG-070.xxxx-yy.com 00:26:B9:28:C8 D 10.7.16.70 active 1/1 /efx G96
renderG-071.xxxx-yy.com 00:26:B9:28:C8:EA 10.7.16.71 active 1/1 /efx G96
renderG-072.xxxx-yy.com 00:26:B9:28:C8:F7 10.7.16.72 active 1/1 /efx G96
renderG-073.xxxx-yy.com 00:26:B9:28:C9:04 10.7.16.73 active 1/1 /efx G96
renderG-074.xxxx-yy.com 00:26:B9:28:C9:11 10.7.16.74 active 1/1 /efx G96
renderG-075.xxxx-yy.com 00:26:B9:28:C9:1E 10.7.16.75 active 1/1 /efx G96
renderG-076.xxxx-yy.com 00:26:B9:28:C9:2B 10.7.16.76 active 1/1 /efx G96
renderG-077.xxxx-yy.com 00:26:B9:28:C9:38 10.7.16.77 active 1/1 /efx G96
renderG-078.xxxx-yy.com 00:26:B9:28:C9:45 10.7.16.78 active 1/1 /efx G96
renderG-079.xxxx-yy.com 00:26:B9:28:C9:52 10.7.16.79 active 1/1 /efx G96
renderG-080.xxxx-yy.com 00:26:B9:28:C9:5F 10.7.16.80 active 1/1 /efx G96
renderG-081.xxxx-yy.com 00:26:B9:28:88:69 10.7.16.81 down 0/1 /efx G96
renderG-081.xxxx-yy.com 00:26:B9:28 0:1F 172.16.10.142 active 1/1 /efx G96
renderG-082.xxxx-yy.com 00:26:B9:28:88:B7 10.7.16.87 down 0/1 /efx G96
renderG-085.xxxx-yy.com 00:26:B9:28:88:90 10.7.16.84 down 0/1 /efx G96
renderG-086.xxxx-yy.com 00:22:19:C1:B9:34 172.16.5.188 active 1/1 /efx G96
renderG-087.xxxx-yy.com 00:26:B9:28:88:AA 172.16.5.31 down 0/1 /efx G96
renderG-087.xxxx-yy.com 00:26:B9:28:88:EB 10.7.16.91 down 0/1 /efx G96
renderG-088.xxxx-yy.com 00:26:B9:28:47:F8 10.7.16.88 down 0/1 /efx G96
renderG-088.xxxx-yy.com 00:22:19:C1:B9:1A 172.16.10.2 active 1/1 /efx G96
renderG-089.xxxx-yy.com 00:26:B9:28:89:05 10.7.16.93 down 0/1 /efx G96
renderG-090.xxxx-yy.com 00:26:B9:28:88:F8 10.7.16.92 down 0/1 /efx G96
renderG-091.xxxx-yy.com 00:26:B9:28:88:9D 10.7.16.85 down 0/1 /efx G96
renderG-092.xxxx-yy.com 00:26:B9:28:89:12 172.16.5.202 down 0/1 /efx G96
renderG-093.xxxx-yy.com 00:26:B9:28:88:76 10.7.16.82 down 0/1 /efx G96
renderG-094.xxxx-yy.com 00:26:B9:28:88:DE 10.7.16.90 down 0/1 /efx G96
renderG-095.xxxx-yy.com 00:26:B9:28:89:1F 10.7.16.95 down 0/1 /efx G96
renderG-095.xxxx-yy.com 00:26:B9:28:88:83 10.7.16.83 down 0/1 /efx G96
renderG-096.xxxx-yy.com 00:26:B9:28:89:2C 10.7.16.96 down 0/1 /efx G96
renderG-096.xxxx-yy.com 00:26:B9:28:88:D1 10.7.16.89 down 0/1 /efx G96
renderG-097.xxxx-yy.com 00:22:19:C1:B8:A5 172.16.5.164 down 0/1 /efx G96
renderG-097.xxxx-yy.com 00:26:B9:28:47:4F 10.7.16.97 down 0/0 /efx G96
renderG-098.xxxx-yy.com 00:26:B9:28:47:5C 10.7.16.98 down 0/0 /efx G96
renderG-098.xxxx-yy.com 00:22:19:C1:B8:B2 172.16.10.38 down 0/1 /efx G96
renderG-099.xxxx-yy.com 00:26:B9:28:47:69 10.7.16.99 down 0/0 /efx G96
renderG-099.xxxx-yy.com 00:22:19:C1:B8:BF 172.16.10.89 active 1/1 /efx G96
renderG-100.xxxx-yy.com 00:26:B9:28:47:76 10.7.16.100 down 0/0 /efx G96
renderG-100.xxxx-yy.com 00:22:19:C1:B8:CC 172.16.5.113 active 1/1 /efx G96
renderG-101.xxxx-yy.com 00:22:19:C1:B8:D9 172.16.10.36 active 1/1 /efx G96
renderG-101.xxxx-yy.com 00:26:B9:28:47:83 10.7.16.101 down 0/1 /efx G96
renderG-102.xxxx-yy.com 00:26:B9:28:47:9D 172.16.5.78 down 0/0 /efx G96
renderG-102.xxxx-yy.com 00:22:19:C1:B8:E6 172.16.10.74 active 1/1 /efx G96
renderG-102.xxxx-yy.com 00:26:B9:28:47:90 10.7.16.102 down 0/0 /efx G96
renderG-103.xxxx-yy.com 00:26:B9:28:56:B2 10.7.16.103 active 1/1 /efx G96
renderG-104.xxxx-yy.com 00:26:B9:28:56:BF 10.7.16.104 active 1/1 /efx G96
renderG-105.xxxx-yy.com 00:26:B9:28:56:CC 10.7.16.105 active 1/1 /efx G96
renderG-108.xxxx-yy.com 00:26:B9:28:56:F3 10.7.16.108 active 1/1 /efx G96
renderG-109.xxxx-yy.com 00:26:B9:28:57:00 10.7.16.109 active 1/1 /efx G96
renderG-110.xxxx-yy.com 00:26:B9:28:57:0D 10.7.16.110 active 1/1 /efx G96
renderG-111.xxxx-yy.com 00:26:B9:28:57:1A 10.7.16.111 active 1/1 /efx G96
renderG-112.xxxx-yy.com 00:26:B9:28:57:27 10.7.16.112 active 1/1 /efx G96
renderG-113.xxxx-yy.com 00:26:B9:28:57:34 10.7.16.113 active 1/1 /efx G96
renderG-114.xxxx-yy.com 00:26:B9:28:57:41 10.7.16.114 active 1/1 /efx G96
renderG-115.xxxx-yy.com 00:26:B9:28:57:4E 10.7.16.115 active 1/1 /efx G96
renderG-116.xxxx-yy.com 00:26:B9:28:57:5B 10.7.16.116 active 1/1 /efx G96
renderG-117.xxxx-yy.com 00:26:B9:28:57:68 10.7.16.117 active 1/1 /efx G96
renderG-118.xxxx-yy.com 00:26:B9:28:57:75 10.7.16.118 active 1/1 /efx G96
renderG-119.xxxx-yy.com 00:22:19:C4:55:92 10.7.16.119 active 1/1 /efx G96
renderG-120.xxxx-yy.com 00:22:19:C4:55:9F 10.7.16.120 active 1/1 /efx G96
renderG-121.xxxx-yy.com 00:22:19:C4:55:AC 10.7.16.121 active 1/1 /efx G96
renderG-122.xxxx-yy.com 00:22:19:C4:55:B9 10.7.16.122 active 1/1 /efx G96
renderG-123.xxxx-yy.com 00:22:19:C4:55:C6 10.7.16.123 active 1/1 /efx G96
renderG-124.xxxx-yy.com 00:22:19:C4:55:D3 10.7.16.124 active 1/1 /efx G96
renderG-125.xxxx-yy.com 00:22:19:C4:55:E0 10.7.16.125 active 1/1 /efx G96
renderG-126.xxxx-yy.com 00:22:19:C4:55:ED 10.7.16.126 active 1/1 /efx G96
renderG-127.xxxx-yy.com 00:22:19:C4:55:FA 10.7.16.127 active 1/1 /efx G96
renderG-128.xxxx-yy.com 00:22:19:C4:56:07 10.7.16.128 active 1/1 /efx G96
renderG-129.xxxx-yy.com 00:22:19:C4:56:14 10.7.16.129 active 1/1 /efx G96
renderG-130.xxxx-yy.com 00:22:19:C4:56:21 10.7.16.130 active 1/1 /efx G96
renderG-131.xxxx-yy.com 00:22:19:C4:56:2E 10.7.16.131 active 1/1 /efx G96
renderG-132.xxxx-yy.com 00:22:19:C4:56:3B 10.7.16.132 active 1/1 /efx G96
renderG-133.xxxx-yy.com 00:22:19:C4:56:48 10.7.16.133 active 1/1 /efx G96
renderG-134.xxxx-yy.com 00:22:19:C4:56:55 10.7.16.134 active 1/1 /efx G96
renderG-135.xxxx-yy.com 00:26:B9:28:4F:81 10.7.16.135 active 1/1 /efx G96
renderG-136.xxxx-yy.com 00:26:B9:28:4F:8E 10.7.16.136 active 1/1 /efx G96
renderG-137.xxxx-yy.com 00:26:B9:28:4F:9B 10.7.16.137 active 1/1 /efx G96
renderG-138.xxxx-yy.com 00:26:B9:28:4F:A8 10.7.16.138 active 1/1 /efx G96
renderG-139.xxxx-yy.com 00:26:B9:28:4F:B5 10.7.16.139 active 1/1 /efx G96
renderG-140.xxxx-yy.com 00:26:B9:28:4F:C2 10.7.16.140 active 1/1 /efx G96
renderG-141.xxxx-yy.com 00:26:B9:28:4F:CF 10.7.16.141 active 1/1 /efx G96
renderG-142.xxxx-yy.com 00:26:B9:28:4F:DC 10.7.16.142 active 1/1 /efx G96
renderG-143.xxxx-yy.com 00:26:B9:28:4F:E9 10.7.16.143 active 1/1 /efx G96
renderG-144.xxxx-yy.com 00:26:B9:28:4F:F6 10.7.16.144 down 0/0 /efx G96
renderG-144.xxxx-yy.com 00:22:19:C1:B9:68 172.16.10.48 active 1/1 /efx G96
renderG-145.xxxx-yy.com 00:26:B9:28:50:03 10.7.16.145 active 1/1 /efx G96
renderG-146.xxxx-yy.com 00:26:B9:28:50:10 10.7.16.146 active 1/1 /efx G96
renderG-147.xxxx-yy.com 00:26:B9:28:50:1D 10.7.16.147 active 1/1 /efx G96
renderG-148.xxxx-yy.com 00:26:B9:28:50:2A 10.7.16.148 active 1/1 /efx G96
renderG-149.xxxx-yy.com 00:26:B9:28:50:37 10.7.16.149 active 1/1 /efx G96
renderG-150.xxxx-yy.com 00:26:B9:28:50:44 10.7.16.150 active 1/1 /efx G96
renderG-151.xxxx-yy.com 00:26:B9:28:A1:96 10.7.16.151 active 1/1 /efx G96
renderG-152.xxxx-yy.com 00:26:B9:28:A1:A3 10.7.16.152 active 1/1 /efx G96
renderG-153.xxxx-yy.com 00:26:B9:28:A1:B0 10.7.16.153 active 1/1 /efx G96
renderG-154.xxxx-yy.com 00:26:B9:28:A1:BD 10.7.16.154 active 1/1 /efx G96
renderG-155.xxxx-yy.com 00:26:B9:28:A1:CA 10.7.16.155 active 1/1 /efx G96
renderG-156.xxxx-yy.com 00:26:B9:28:A1:D7 10.7.16.156 active 1/1 /efx G96
renderG-157.xxxx-yy.com 00:26:B9:28:A1:E4 10.7.16.157 active 1/1 /efx G96
renderG-158.xxxx-yy.com 00:26:B9:28:A1:F1 10.7.16.158 active 1/1 /efx G96
renderG-159.xxxx-yy.com 00:26:B9:28:A1:FE 10.7.16.159 active 1/1 /efx G96
renderG-160.xxxx-yy.com 00:26:B9:28:A2:0B 10.7.16.160 active 1/1 /efx G96
renderG-161.xxxx-yy.com 00:26:B9:28:A2:18 10.7.16.161 active 1/1 /efx G96
renderG-162.xxxx-yy.com 00:26:B9:28:A2:25 10.7.16.162 active 1/1 /efx G96
renderG-163.xxxx-yy.com 00:26:B9:28:A2:32 10.7.16.163 active 1/1 /efx G96
renderG-164.xxxx-yy.com 00:26:B9:28:A2:3F 10.7.16.164 active 1/1 /efx G96
renderG-165.xxxx-yy.com 00:26:B9:28:A2:4C 10.7.16.165 active 1/1 /efx G96
renderG-166.xxxx-yy.com 00:26:B9:28:A2:59 10.7.16.166 active 1/1 /efx G96
renderG-167.xxxx-yy.com 00:25:90:1B:1E:04 10.7.21.1 down 0/1 /efx G96
renderG-167.xxxx-yy.com 00:26:B9:28:D0:46 172.16.10.86 down 0/0 /efx G96
renderG-167.xxxx-yy.com 00:26:B9:28:CF:F8 172.16.5.159 active 1/1 /efx G96
renderG-168.xxxx-yy.com 00:26:B9:28:D0:39 172.16.10.149 active 1/1 /efx G96
renderG-168.xxxx-yy.com 00:25:90:1D:02:52 10.7.21.2 down 0/0 /efx G96
renderG-169.xxxx-yy.com 00:25:90:1D:CD:84 10.7.21.3 down 0/1 /efx G96
renderG-169.xxxx-yy.com 00:26:B9:28:CF:DE 172.16.5.49 active 1/1 /efx G96
renderG-170.xxxx-yy.com 00:25:90:1B:15:78 10.7.21.4 down 0/1 /efx G96
renderG-170.xxxx-yy.com 00:26:B9:28:CF:EB 172.16.5.71 active 1/1 /efx G96
renderG-171.xxxx-yy.com 00:25:90:1C:0F:A8 10.7.21.5 down 0/1 /efx G96
renderG-171.xxxx-yy.com 00:26:B9:28:CF:B7 172.16.10.44 active 1/1 /efx G96
renderG-172.xxxx-yy.com 00:25:90:1B:1D:EC 10.7.21.6 down 0/1 /efx G96
renderG-173.xxxx-yy.com 00:25:90:1D:07:FC 10.7.21.7 down 0/1 /efx G96
renderG-173.xxxx-yy.com 00:26:B9:28:CF:9D 172.16.10.184 down 0/0 /efx G96
renderG-174.xxxx-yy.com 00:26:B9:28:D0:60 172.16.5.94 down 0/1 /efx G96
renderG-174.xxxx-yy.com 00:25:90:1F:7B:48 10.7.21.8 down 0/1 /efx G96
renderG-175.xxxx-yy.com 00:25:90:1D:CD:E4 10.7.21.9 down 0/1 /efx G96
renderG-176.xxxx-yy.com 00:25:90:1D:04:20 10.7.21.10 down 0/1 /efx G96
renderG-176.xxxx-yy.com 00:26:B9:28:D0:05 172.16.5.14 active 1/1 /efx G96
renderG-177.xxxx-yy.com 00:25:90:1B:1E:06 10.7.21.11 down 0/1 /efx G96
renderG-177.xxxx-yy.com 00:26:B9:28:CF:AA 172.16.5.112 active 1/1 /efx G96
renderG-178.xxxx-yy.com 00:25:90:1D:02:54 10.7.21.12 down 0/1 /efx G96
renderG-179.xxxx-yy.com 00:25:90:1D:CD:86 10.7.21.13 down 0/1 /efx G96
renderG-179.xxxx-yy.com 00:26:B9:28:D0:12 172.16.10.148 active 1/1 /efx G96
renderG-180.xxxx-yy.com 00:26:B9:28:CF:C4 172.16.10.43 active 1/1 /efx G96
renderG-180.xxxx-yy.com 00:25:90:1B:15:7A 10.7.21.14 down 0/1 /efx G96
renderG-180.xxxx-yy.com 00:26:B9:28:D0:53 172.16.10.151 down 0/0 /efx G96
renderG-181.xxxx-yy.com 00:25:90:1C:0F:AA 10.7.16.167 down 0/0 /efx G96
renderG-181.xxxx-yy.com 00:26:B9:28:D0:2C 172.16.5.101 active 1/1 /efx G96
renderG-182.xxxx-yy.com 00:26:B9:28:CF:D1 172.16.5.107 active 1/1 /efx G96
renderG-182.xxxx-yy.com 00:25:90:1B:1D:EE 10.7.16.168 down 0/0 /efx G96
renderG-183.xxxx-yy.com 00:22:19:C4:20:1B 10.7.16.169 active 1/1 /efx G96
renderG-184.xxxx-yy.com 00:22:19:C4:20:28 10.7.16.170 active 1/1 /efx G96
renderG-185.xxxx-yy.com 00:22:19:C4:20:35 10.7.16.171 active 1/1 /efx G96
renderG-186.xxxx-yy.com 00:22:19:C4:20:42 10.7.16.172 active 1/1 /efx G96
renderG-187.xxxx-yy.com 00:22:19:C4:20:4F 10.7.16.173 active 1/1 /efx G96
renderG-188.xxxx-yy.com 00:22:19:C4:20:5C 10.7.16.174 active 1/1 /efx G96
renderG-189.xxxx-yy.com 00:22:19:C4:20:69 10.7.16.175 active 1/1 /efx G96
renderG-190.xxxx-yy.com 00:22:19:C4:20:76 10.7.16.176 active 1/1 /efx G96
renderG-191.xxxx-yy.com 00:22:19:C4:20:83 10.7.16.177 active 1/1 /efx G96
renderG-192.xxxx-yy.com 00:22:19:C4:20:90 10.7.16.178 active 1/1 /efx G96
renderG-193.xxxx-yy.com 00:22:19:C4:20:9D 10.7.16.179 active 1/1 /efx G96
renderG-194.xxxx-yy.com 00:22:19:C4:20:AA 10.7.16.180 active 1/1 /efx G96
renderG-195.xxxx-yy.com 00:22:19:C4:20:B7 10.7.16.181 active 1/1 /efx G96
renderG-196.xxxx-yy.com 00:22:19:C4:20:C4 10.7.16.182 active 1/1 /efx G96
renderG-197.xxxx-yy.com 00:22:19:C4:20:D1 10.7.16.183 active 1/1 /efx G96
renderG-198.xxxx-yy.com 00:22:19:C4:20:DE 10.7.16.184 active 1/1 /efx G96
renderG-199.xxxx-yy.com 00:22:19:C1:B9:4E 172.16.5.62 down 0/1 /efx G96
renderG-200.xxxx-yy.com 00:22:19:C1:B8:F3 172.16.10.75 active 1/1 /efx G96
node-244.xxxx-yy.com 04:7D:7B:87:0B:8C 10.7.1.22 active 1/1 /lgt G128
node-246.xxxx-yy.com 04:7D:7B:B0:66:C1 10.7.1.24 down 0/1 /lgt G128
node-247.xxxx-yy.com 04:7D:7B:B0:65:3E 10.7.1.25 active 1/1 /lgt G128
node-248.xxxx-yy.com 04:7D:7B:87:0B:F2 10.7.1.26 active 1/1 /lgt G128
node-249.xxxx-yy.com 04:7D:7B:87:13:5C 10.7.1.27 active 1/1 /lgt G128
node-250.xxxx-yy.com 04:7D:7B:B0:69:31 10.7.1.28 active 1/1 /lgt G128
node-251.xxxx-yy.com 04:7D:7B:B0:6B:5F 10.7.1.29 active 1/1 /lgt G96
node-252.xxxx-yy.com 08:9E:01:93:26:26 10.7.1.30 active 1/1 /lgt G128
node-253 04:7D:7B:B0:69:1F 10.7.1.31 active 1/1 /lgt G128
node-254.xxxx-yy.com 04:7D:7B:B0:66:79 10.7.1.32 active 1/1 /lgt G128
node-255 04:7D:7B:87:09:25 10.7.1.33 active 1/1 /lgt G128
node-256 04:7D:7B:87:0C:7F 10.7.1.34 active 1/1 /lgt G128
node-257 04:7D:7B:87:04:24 10.7.1.35 active 1/1 /lgt G128
node-258 04:7D:7B:87:0E:80 10.7.1.36 active 1/1 /lgt G128
node-259 04:7D:7B:B0:64:CC 10.7.1.37 active 1/1 /lgt G128
node-260 08:9E:01:F7:4F:A4 10.7.1.38 active 1/1 /lgt G128
node-261 04:7D:7B:87:10:95 10.7.1.39 active 1/1 /lgt G128
node-262 04:7D:7B:87:17:3D 10.7.1.40 active 1/1 /lgt G128
node-263 04:7D:7B:87:11:1F 10.7.1.41 active 1/1 /lgt G128
node-264 04:7D:7B:B0:63:CD 10.7.1.42 active 1/1 /lgt G128
node-265.xxxx-yy.com 04:7D:7B:87:07:33 10.7.1.43 down 0/0 /lgt G96
node-266 04:7D:7B:87:04:6C 10.7.1.44 active 1/1 /lgt G128
node-267 04:7D:7B:87:08:14 10.7.1.45 active 1/1 /lgt G128
node-268 04:7D:7B:87:0F:B1 10.7.1.46 active 1/1 /lgt G128
node-269 04:7D:7B:B0:67:C9 10.7.1.47 active 1/1 /lgt G48
node-270 04:7D:7B:87:15:87 172.16.10.10 active 1/1 /lgt G96
node-271 04:7D:7B:87:18:E7 10.7.1.49 active 1/1 /lgt G96
node-272 04:7D:7B:87:14:6D 10.7.1.50 active 1/1 /lgt G128
node-273 04:7D:7B:87:19:68 10.7.1.51 active 1/1 /lgt G128
node-275 04:7D:7B:B0:62:9E 10.7.1.53 active 1/1 /lgt G128
node-276 04:7D:7B:B0:68:C8 10.7.1.54 active 1/1 /lgt G128
node-277 04:7D:7B:B0:66:88 10.7.1.55 active 1/1 /lgt G128
node-278 04:7D:7B:B0:67:AE 10.7.1.56 active 1/1 /lgt G128
node-279 04:7D:7B:B0:64:D2 10.7.1.57 active 1/1 /lgt G128
node-280 04:7D:7B:B0:69:9A 10.7.1.58 active 1/1 /lgt G128
node-281 04:7D:7B:B0:66:37 10.7.1.59 active 1/1 /lgt G96
node-282 04:7D:7B:87:16:17 10.7.1.60 active 1/1 /lgt G128
node-283 04:7D:7B:B0:63:B5 10.7.1.61 active 1/1 /lgt G128
node-284 04:7D:7B:87:18:09 10.7.1.62 active 1/1 /lgt G128
node-285 04:7D:7B:A5:A7:AB 10.7.1.63 active 1/1 /lgt G128
node-286 04:7D:7B:B0:5E:15 10.7.1.64 active 1/1 /lgt G96
node-287 04:7D:7B:B0:60:BE 10.7.1.65 active 1/1 /lgt G128
node-288 04:7D:7B:B0:63:85 10.7.1.66 active 0/1 /lgt G96
node-289 04:7D:7B:B0:68:80 10.7.1.67 active 0/1 /lgt G96
node-290 04:7D:7B:B0:6D:24 10.7.1.68 active 1/1 /lgt G96
node-291 04:7D:7B:87:08:E9 10.7.1.69 down 0/0 /lgt G96
node-292 04:7D:7B:B0:66:A3 10.7.1.70 active 0/1 /lgt G96
node-293 04:7D:7B:B0:66:1F 10.7.1.71 active 0/1 /lgt G96
node-294 04:7D:7B:B0:65:11 10.7.1.72 active 1/1 /lgt G96
node-295 04:7D:7B:87:11:FD 10.7.1.73 active 1/1 /lgt G96
node-296 04:7D:7B:86:AD:4E 10.7.1.74 active 1/1 /lgt G96
node-297 04:7D:7B:B0:6A:9F 10.7.1.75 active 1/1 /lgt G96
node-298 04:7D:7B:87:16:E0 10.7.1.76 active 1/1 /lgt G96
node-299 04:7D:7B:B0:64:7E 10.7.1.77 active 1/1 /lgt G96
node-300 04:7D:7B:87:09:3A 10.7.1.78 active 1/1 /lgt G96
node-301 04:7D:7B:87:0D:A8 10.7.1.79 active 1/1 /lgt G96
node-302 04:7D:7B:B0:60:AF 10.7.1.80 active 1/1 /lgt G96
node-303 04:7D:7B:B0:58:D8 10.7.1.81 down 0/1 /lgt G96
node-304 04:7D:7B:B0:67:51 10.7.1.82 active 1/1 /lgt G96
node-305 04:7D:7B:B0:68:FB 10.7.1.83 active 1/1 /lgt G96
node-306 04:7D:7B:B0:64:9F 10.7.1.84 active 1/1 /lgt G96
node-307 04:7D:7B:B0:5F:C2 10.7.1.85 down 0/0 /lgt G48
node-308 04:7D:7B:87:05:C2 10.7.1.86 down 0/1 /lgt G96
node-309 04:7D:7B:87:0E:83 10.7.1.87 active 1/1 /lgt G96
node-310 04:7D:7B:87:08:80 10.7.1.88 active 1/1 /lgt G96
node-311 04:7D:7B:87:15:D8 10.7.1.89 active 1/1 /lgt G96
node-312 04:7D:7B:B0:63:C1 10.7.1.90 active 1/1 /lgt G96
node-313 04:7D:7B:B0:66:A9 10.7.1.91 active 1/1 /lgt G96
node-314 04:7D:7B:B0:64:C6 10.7.1.92 active 1/1 /lgt G96
node-315 04:7D:7B:87:17:F1 10.7.1.93 active 1/1 /lgt G96
node-316 04:7D:7B:87:06:5E 10.7.1.94 active 1/1 /lgt G96
node-317 04:7D:7B:67:0F:37 10.7.1.95 active 1/1 /lgt G96
node-318 04:7D:7B:87:04:F3 10.7.1.96 active 1/1 /lgt G96
node-319 04:7D:7B:B0:65:17 10.7.1.97 down 0/0 /lgt G96
node-320 04:7D:7B:B0:65:68 10.7.1.98 active 1/1 /lgt G96
node-321 04:7D:7B:B0:67:54 10.7.1.99 active 1/1 /lgt G96
node-322 04:7D:7B:B0:61:84 10.7.1.100 active 1/1 /lgt G96
node-323 04:7D:7B:86:A5:85 10.7.1.101 active 1/1 /lgt G96
node-324 04:7D:7B:B0:63:6A 10.7.1.102 active 1/1 /lgt G96
node-325 04:7D:7B:B0:59:14 10.7.1.103 active 1/1 /lgt G96
node-326 04:7D:7B:B0:66:D3 10.7.1.104 active 1/1 /lgt G96
node-327 04:7D:7B:87:16:62 10.7.1.105 active 1/1 /lgt G96
node-328 04:7D:7B:B0:6D:2A 10.7.1.106 down 0/0 /lgt G96
node-329 04:7D:7B:6E:08:43 10.7.1.107 active 1/1 /lgt G96
node-330 04:7D:7B:87:05:71 10.7.1.108 active 1/1 /lgt G96
node-331 04:7D:7B:B0:62:FE 10.7.1.109 active 1/1 /lgt G96
node-332 04:7D:7B:87:15:E7 10.7.1.110 active 1/1 /lgt G96
node-333 04:7D:7B:87:06:34 10.7.1.111 down 0/0 /lgt G96
node-334 04:7D:7B:87:0B:23 10.7.1.112 active 1/1 /lgt G96
node-335 04:7D:7B:87:0A:93 10.7.1.113 active 1/1 /lgt G96
node-336 04:7D:7B:87:0F:FF 10.7.1.114 active 1/1 /lgt G96
node-337 04:7D:7B:B0:6D:03 10.7.1.115 active 0/0 /lgt G96
附上awk的,思路应该没问题,但结果不对,比较难debug。(只对renderG的,这个完成了node很容易加,就是if/else )
awk 'BEGIN{FS="[- ]+"
a["renderG"]= "1 202 167 180 | 167 204 181 202"
} /^node/ || /^renderG/{ if($5 !~/[a-zA-Z]+/)b[$2"-"$1]=$6 ;else b[$2"-"$1]=$5 ;c[$2"-"$1]=$1}
END{
for(i in a){
len = split(a,m,"|" # 1 202 167 180 和167...204
for(t=1;t<=len;t++)
{ split(m[t],x)
for(f=x[1];f<=x[2];f++) temp[f] = i
for(n=x[3];n<=x[4];n++) delete temp[n]
for(host in b) {
for (Number in temp)
if(host +0 == Number && i ==c[host] )
count++
}
print x[1],x[4],count
delete temp ;count =0
}
}
}'
但awk就很麻烦了,我考虑用python这种思路,把范围存到数组a来做index, value是renderG和node,然后把文本内容放数组b, key是$1(node-xxx/renderG-xxx),value是active/down, 然后把a的既定范围和b比较,若存在就计时器放数temp, 循环完毕,统计temp,然后删除,但涉及到3层以上嵌套循环,比较难以理解,尤其是代码里面{}的位置,所以我的awk也没办法完成,各位大拿有什么好的办法吗?
|
|