欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python 定時(shí)任務(wù)去檢測服務(wù)器端口是否通的實(shí)例

 更新時(shí)間:2019年01月26日 09:45:33   作者:ywmack  
今天小編就為大家分享一篇python 定時(shí)任務(wù)去檢測服務(wù)器端口是否通的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

如下所示:

import socket
import threading
import time
 
def testconn( host , port ):
  sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sk.settimeout(1)
  try:
    sk.connect((host,port))
    return host+" Server is "+str(port)+" connect"
  except Exception:
    return host+" Server is "+str(port)+" not connect!"
  sk.close()
 
class Test(threading.Thread):
  def __init__(self):
    pass
  def test(self):
    print testconn('172.31.32.3',22)
  def run(self):
    while True:
      #print time.strftime('%Y-%m-%d %H:%M:%S')
      self.test()
      time.sleep(1)
a=Test()
a.run()

以上這篇python 定時(shí)任務(wù)去檢測服務(wù)器端口是否通的實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論