python - How to do port monitoring.
为情所困
为情所困 2017-06-30 09:54:51
0
1
997

windwos, how to do it like phpstudy. If the port is killed, the light will turn red... If the port is monitored, it will turn green... And it is real-time... Please give me some guidance...

为情所困
为情所困

reply all(1)
仅有的幸福

I have never done a real-time one, but I want to make a semi-real-time one. Use the socket to communicate with the target port every 30 seconds. If the communication fails, it will alarm.

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
    s.connect((conn_ip,conn_port))
    logging.info('IP:'+str(conn_ip)+',PORT:'+str(conn_port)+',connect successful')
except Exception as e:
    logging.warning('IP:'+str(conn_ip)+',PORT:'+str(conn_port)+',connect failed!!check the client!!')
    send_msg(conn_ip,conn_port) #发送报警短信
finally:
    s.close()

This is a rough version, that’s what it means...I don’t know if it will be helpful to you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!