zoukankan      html  css  js  c++  java
  • 监控服务器端口状态

    import socket
    import re
    import sys
    import getopt
    import string
    def check_server(address,port):
       s=socket.socket()
       print "Attempting to connect to %s on port %s" % (address, port)
       try:
           s.connect((address,port))
           print "Connected to %s on port %s" % (address, port)
           return True
       except socket.error, e:
          print "Connection to %s on port %s failed: %s" %(address, port,e)
          return False
    if __name__=="__main__":
       try:
        opts,args=getopt.getopt(sys.argv[1:],"i:p:",["help","ip=","port="])
       except getopt.GetoptErrir as err:
         print(err)
         sys.exit(2)
       ip="null"
       port="null"
       for o,a in opts:
         if o in ("-i","--ip"):
          ip=a
         elif o in ("-p","--port"):
          port=a
         elif o in ("-h","--help"):
          print "help"
         else:
             print "nihao"
       print opts
       check=check_server(ip,string.atoi('80'))
       print "check_server returned %s" % check
       sys.exit(not check)
  • 相关阅读:
    CKeditor3.6.2 配置与精简
    CKEditor与CKFinder整合并实现文件上传功能
    实体关联关系映射:
    status pending状态
    wx:for
    小程序
    获取指定控件的值
    报表
    dataGridView 设置
    SQLite 的使用
  • 原文地址:https://www.cnblogs.com/dlutxm/p/2998030.html
Copyright © 2011-2022 走看看