zoukankan      html  css  js  c++  java
  • python 多线程实例

    # -*- coding: utf-8 -*-
    import sys
    import pycontrol.pycontrol as pc
    import time
    import csv
    import ssl
    import json
    import threading
    #ssl._create_default_https_context = ssl._create_unverified_context
    #pool='YXPT_ust_pool'
    def get_f5_pool_status(a,b,c):
      x=a
      y=b
      z=c
      b = pc.BIGIP(
       hostname =x,
       username =y,
       password =z ,
       fromurl = True,
       wsdls=['LocalLB.PoolMember'])
      pools = b.LocalLB.PoolMember
      c = pc.BIGIP(
       hostname = x,
       username = y,
       password = z,
       fromurl = True,
       wsdls=['LocalLB.VirtualServer'])
      p001 = c.LocalLB.VirtualServer
      poolarray=[]
      #a90190319=[90.3.90.1:8080,90.2.223.3:9090,90.2.223.4:9090,90.2.223.1:9090,90.2.223.2:9090,90.2.21.11:7990,90.2.21.12:7990,90.2.90.4:23300,90.3.19.11:7001,90.3.19.12:7001,90.3.19.13:7001,90.3.19.11:8888,90.3.19.12:8888,90.3.19.13:8888,90.3.19.11:40128,90.3.19.12:40128,90.3.19.13:40128, 90.3.90.1:8080,90.3.90.2:8080,90.3.90.3:8080,90.2.90.1:9092,90.2.90.2:9092,90.2.90.1:8086,90.2.90.2:8086,90.2.90.1:8008,90.2.90.2:8008,90.2.90.3:23300,90.2.90.4:23300]
      excludearray=['90.3.22.11:7006', '90.3.237.31:8080', '90.3.237.32:8080', '90.3.237.31:7012', '90.3.237.32:7012',     '90.2.25.1:8090', '90.2.25.2:8090','90.16.38.1:8002','90.3.24.41:7002','90.3.24.42:7002',   '90.3.23.22:16888','90.3.219.50:5555','90.3.219.51:5555', '90.2.24.1:8088', '90.2.24.2:8088',  '90.3.248.90:7001','90.3.219.52:8080', '90.3.219.53:8080', '90.3.215.11:80', '90.3.215.11:90446', '90.3.215.11:90444', '90.3.219.54:23000', '90.3.219.61:23000', '90.3.219.54:29000', '90.3.219.61:29000','90.2.237.906:7004','90.2.237.906:7003','90.2.237.907:7004','90.2.237.907:7003','90.2.237.900:7003','90.2.237.900:7004','90.2.237.903:7004','90.2.237.903:7003','90.3.23.21:7003','90.3.23.22:7003','90.3.222.21:80','90.3.222.22:80','90.3.23.11:80',  '90.3.221.21:7001',   '90.3.221.21:7002',  '90.3.221.21:7003', '90.3.22.12:7006', '90.2.215.2:8091','90.2.215.2:8080','90.3.227.2:9082','90.3.227.3:9084','90.3.222.90:80','90.3.222.21:80','90.3.222.22:80','90.3.222.25:80',  '90.2.908.902:8000','90.3.248.90:40128', '90.3.248.21:40128', '90.3.248.22:40128', '90.3.248.90:8888', '90.3.248.21:8888', '90.3.248.22:8888',  '90.3.248.21:7001', '90.3.248.22:7001','90.2.21.13:8000','90.2.21.14:8000','90.2.247.901:6801', '90.2.247.902:6801', '90.2.247.901:8087', '90.2.247.902:8087', '90.2.247.901:8889', '90.2.229.905:0', '90.2.218.3:9080', '90.2.218.4:9080', '90.2.17.11:7011', '90.2.17.11:9000', '90.2.17.13:7986', '90.2.90.1:9092', '90.2.90.2:9092',  '90.3.215.22:90080', '90.3.215.23:90080', '90.3.215.25:8080', '90.3.215.26:8080', '90.3.215.29:8080', '90.3.215.30:8080', '90.3.215.25:8080', '90.3.215.26:8080', '90.3.215.29:8080', '90.3.215.30:8080', '90.3.219.1:9091', '90.3.219.2:9092', '90.3.219.1:9093', '90.3.219.2:9094', '90.3.219.7:9080', '90.3.219.8:9080', '90.3.219.8:9081', '90.3.219.7:9890', '90.3.219.8:9811', '90.3.215.12:7002', '90.3.215.13:7002', '90.3.215.22:90080', '90.3.215.23:90080', '90.3.245.14:7070', '90.3.245.15:7070', '90.3.253.33:8080', '90.2.247.902:8889',  '90.2.247.901:42908', '90.2.247.902:42908', '90.2.290.30:69000', '90.3.229.90:9092', '90.3.229.21:9092', '90.3.229.25:9091', '90.3.229.26:9091', '90.3.230.1:7002', '90.3.230.2:7002', '90.3.230.3:7002', '90.3.230.4:7002', '90.3.249.27:7003', '90.3.249.27:7004', '90.3.249.27:7007', '90.3.249.27:7008', '90.3.249.28:7005', '90.3.249.28:7006', '90.3.249.28:7009', '90.3.249.28:7090',  '90.3.249.9:7004', '90.3.249.9:7005', '90.3.249.9:7006', '90.3.219.28:7016', '90.3.219.29:7016', '90.3.219.31:7016', '90.3.219.32:7016', '90.3.219.50:8021', '90.3.219.51:8021', '90.3.219.52:9096', '90.3.219.53:9096', '90.3.219.28:7017', '90.3.219.29:7017', '90.3.219.31:7017', '90.3.219.32:7017', '90.3.219.52:9096', '90.3.219.53:9096', '90.3.219.52:2233', '90.3.219.53:2233', '90.3.219.28:1935', '90.3.219.29:1935', '90.3.219.31:1935', '90.3.219.32:1935', '90.3.236.5:80', '90.3.219.52:6666', '90.3.219.53:6666', '90.3.219.52:9999', '90.3.219.53:9999', '90.3.219.54:8081', '90.3.219.61:8081', '90.3.215.12:7002', '90.3.215.13:7002', '90.3.219.28:7018', '90.3.219.29:7018', '90.3.219.31:7018', '90.3.219.32:7018', '90.3.215.22:90443', '90.3.215.23:90443', '90.3.215.14:8080', '90.3.215.3:7002', '90.3.222.5:7003', '90.3.222.5:7004', '90.3.222.5:7005', '90.3.222.5:7006', '90.3.222.6:7003', '90.3.222.6:7004', '90.3.222.6:7005', '90.3.249.41:8080', '90.3.249.42:8080', '90.3.229.90:9092', '90.3.229.21:9092', '90.3.229.25:9091', '90.3.229.26:9091',  '90.3.222.6:11211', '90.16.35.1:9094', '90.16.35.21:8089', '90.16.35.22:8089', '90.16.49.22:8089', '90.3.219.82:90086', '90.3.215.22:90443', '90.3.215.23:90443', '90.3.215.22:7090', '90.3.215.23:7090', '90.3.219.52:6668', '90.3.219.53:6668', '90.3.219.52:8888', '90.3.219.53:8888', '90.3.219.82:1290', '90.3.215.90:7002', '90.3.215.11:7002', '90.3.219.52:9988', '90.3.219.53:9988', '90.3.219.50:7070', '90.3.219.51:7070', '90.3.219.52:6667', '90.3.219.53:6667',  '90.3.219.28:7019', '90.3.219.29:7019', '90.3.219.31:7019', '90.3.219.32:7019', '90.3.222.5:8001', '90.3.222.5:8002', '90.3.222.6:8001', '90.3.222.6:8002', '90.3.219.54:8089', '90.3.219.61:8089', '90.3.215.25:90080', '90.3.215.26:90080', '90.3.215.29:90080', '90.3.215.30:90080', '90.3.219.1:8251', '90.3.219.2:8251', '90.3.246.7:7011', '90.3.246.7:7012', '90.3.246.8:7021', '90.3.246.8:7022', '90.3.215.25:90080', '90.3.215.26:90080', '90.3.215.29:90080', '90.3.215.30:90080', '90.3.219.81:90993', '90.3.219.82:90993', '90.3.290.3:17001', '90.3.290.4:17001', '90.3.219.28:8025', '90.3.219.29:8025', '90.3.219.31:8025', '90.3.219.32:8025', '90.3.219.81:8270', '90.3.219.82:8270', '90.3.215.25:90080', '90.3.215.26:90080', '90.3.215.29:90080', '90.3.215.30:90080', '90.3.249.6:7003', '90.3.249.9:7003', '90.16.35.23:8080', '90.16.35.24:8080','90.16.32.30:8000', '90.16.32.31:8000', '90.16.32.30:8080', '90.16.32.31:8080', '90.16.32.1:9097', '90.16.32.2:9097', '90.16.32.3:9097', '90.16.32.34:9097', '90.16.32.35:9097', '90.16.32.4:9097', '90.16.32.1:8088', '90.16.32.12:8088', '90.16.32.13:8088', '90.16.32.14:8088', '90.16.32.15:8088', '90.16.32.2:8088', '90.16.32.3:8088', '90.16.32.4:8088', '90.16.32.5:8088', '90.16.32.6:8088', '90.16.32.7:8088', '90.16.32.8:8088', '90.16.32.12:9096', '90.16.32.13:9096', '90.16.32.14:9096', '90.16.32.15:9096', '90.16.32.3:9096', '90.16.32.4:9096', '90.16.32.1:8090', '90.16.32.12:8090', '90.16.32.13:8090', '90.16.32.14:8090', '90.16.32.15:8090', '90.16.32.2:8090', '90.16.32.3:8090', '90.16.32.4:8090', '90.16.32.5:8090', '90.16.32.6:8090', '90.16.32.7:8090', '90.16.32.8:8090', '90.16.37.90:9008', '90.16.37.11:9008', '90.16.32.1:8087', '90.16.32.12:8087', '90.16.32.13:8087', '90.16.32.14:8087', '90.16.32.15:8087', '90.16.32.2:8087', '90.16.32.4:8087', '90.16.32.1:8091', '90.16.32.12:8091', '90.16.32.13:8091', '90.16.32.14:8091', '90.16.32.15:8091', '90.16.32.2:8091', '90.16.32.3:8091', '90.16.32.4:8091', '90.16.32.5:8091', '90.16.32.6:8091', '90.16.32.7:8091', '90.16.32.8:8091','90.16.32.1:8086', '90.16.32.12:8086', '90.16.32.13:8086', '90.16.32.14:8086', '90.16.32.15:8086', '90.16.32.2:8086', '90.16.32.3:8086', '90.16.32.4:8086', '90.16.32.5:8086', '90.16.32.6:8086', '90.16.32.7:8086', '90.16.32.8:8086', '90.16.32.1:8081', '90.16.32.2:8081', '90.16.32.3:8081', '90.16.32.4:8081', '90.16.32.90:6001', '90.16.32.11:6001', '90.16.32.1:8085', '90.16.32.2:8085', '90.16.32.3:8085', '90.16.32.4:8085', '90.16.32.5:8085', '90.16.32.6:8085', '90.16.32.3:9091', '90.16.32.4:9091','90.16.33.3:9980', '90.16.33.4:9980', '90.16.33.5:9980', '90.16.32.1:8089', '90.16.32.2:8089', '90.16.32.3:8089', '90.16.32.34:8089', '90.16.32.35:8089', '90.16.32.4:8089', '90.16.32.7:9092', '90.16.32.8:9092', '90.16.32.7:9093', '90.16.32.8:9093', '90.16.36.2:80', '90.16.35.1:5000', '90.16.35.2:5000', '90.16.35.3:5000',  '90.16.35.5:5000',  '90.16.32.1:8082', '90.16.32.2:8082',  '90.16.32.4:8082','90.2.237.904:7003', '90.2.237.904:7004', '90.2.237.904:7005', '90.2.237.904:7006', '90.2.237.905:7003', '90.2.237.905:7004', '90.2.237.905:7005', '90.2.237.905:7006', '90.2.237.906:7005', '90.2.237.906:7006', '90.2.237.907:7005', '90.2.237.907:7006','90.2.237.900:7005', '90.2.237.900:7006', '90.2.237.901:7003', '90.2.237.901:7004', '90.2.237.901:7005', '90.2.237.901:7006', '90.2.237.902:7003', '90.2.237.902:7004', '90.2.237.902:7005', '90.2.237.902:7006', '90.2.237.903:7005', '90.2.237.903:7006','90.2.247.905:25014' ,'90.2.247.906:25014']
    
      #excludearray=['90.2.229.905:0', '90.2.247.901:6801', '90.2.247.902:6801', '90.2.247.901:8087', '90.2.247.902:8087', '90.2.247.901:8889', '90.2.17.11:7011', '90.2.17.11:9000', '90.2.17.13:7986', '90.16.35.1:9094', '90.16.35.21:8089', '90.16.35.22:8089', '90.16.49.22:8089', '90.2.247.902:8889', '90.2.247.902:90900', '90.2.247.901:42908', '90.2.247.902:42908', '90.2.290.11:12998', '90.2.290.30:69000', '90.3.229.90:9092', '90.3.229.21:9092', '90.3.229.25:9091', '90.3.229.26:9091', '90.3.230.1:7002', '90.3.230.2:7002', '90.3.230.3:7002', '90.3.230.4:7002', '90.3.249.27:7003', '90.3.249.27:7004', '90.3.249.27:7007', '90.3.249.27:7008', '90.3.249.28:7005', '90.3.249.28:7006', '90.3.249.28:7009', '90.3.249.28:7090', '90.2.218.3:9080', '90.2.218.4:9080', '90.16.35.23:8080', '90.16.35.24:8080']
      allpool=p001.get_list()
      for x in allpool:
       poolarray.append(p001.get_default_pool_name(virtual_servers=[x])[0])
      list=[[] for i in range(len(poolarray))]
      i=0
      for p in poolarray:
       a = pools.get_object_status(pool_names=[p])
       for x in a:
         for y in x:
            node=y.member.address +':'+ str(y.member.port)
            if node in excludearray:
              pass
            else:
               list[i].append(p+'=>'+y.member.address +':'+ str(y.member.port)+'=>'+y.object_status.availability_status +'=>'+y.object_status.enabled_status+'=>'+y.object_status.status_description)
       i=i+1
      return list 
    listall=[]
    ##椒江ESB_F5
    def fun1():
    list1=get_f5_pool_status('90.2.900.1','xxxx','xxxx')
    for bb in list1:
      listall.append(bb)
    ##核心F5
    def fun2():
    list2=get_f5_pool_status('90.2.247.1','xxxx','xxxx')
    for aa in list2:
      listall.append(aa)
    ##椒江办公F5
    def fun3():
    list3=get_f5_pool_status('90.3.900.1','xxxx','xxxx')
    for cc in list3:
       listall.append(cc)
    ##椒江一般业务
    def fun4():
    list4=get_f5_pool_status('90.2.901.1','xxxx','xxxx')
    for dd in list4:
       listall.append(dd)
    ##网银
    def fun5():
    list5=get_f5_pool_status('900.1.1.78','xx','xx')
    for ee in list5:
       listall.append(ee)
    ##门户
    def fun6():
    list6=get_f5_pool_status('90.3.900.1','xxxx','xxxx')
    for ff in list6:
       listall.append(ff)
    ##直销银行
    def fun7():
    list7=get_f5_pool_status('90.5.16.32','xxxx','xxxx')
    for gg in list7:
        listall.append(gg)
    ##
    threads = []
    t1 = threading.Thread(target=fun1,name='fun1')
    threads.append(t1)
    t2 = threading.Thread(target=fun2,name='fun2')
    threads.append(t2)
    t3 = threading.Thread(target=fun3,name='fun3')
    threads.append(t3)
    t4 = threading.Thread(target=fun4,name='fun4')
    threads.append(t4)
    t5 = threading.Thread(target=fun5,name='fun5')
    threads.append(t5)
    t6 = threading.Thread(target=fun6,name='fun6')
    threads.append(t6)
    t7 = threading.Thread(target=fun7,name='fun7')
    threads.append(t7)
    if __name__ == '__main__':
    for t in threads:
       t.setDaemon(True)
       t.start()
    for t in threads:
      t.join()
    while [] in listall:
      listall.remove([])
    f5dict={'f5dict': listall}
    print json.dumps(f5dict)
  • 相关阅读:
    iOS之NSString类型为什么要用copy修饰
    【转】高频使用的git清单
    【转】把Git Repository建到U盘上去
    python程序的打开运行方式
    python运算符的优先级顺序
    iOS之正则表达式(一)
    iOS之input file调用相册控制器消失跳转到登陆页
    监督学习与无监督学习
    常用的文件打开模式
    编码格式
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348680.html
Copyright © 2011-2022 走看看