文章详情页
python - 如何做端口监控.
浏览:174日期:2022-06-27 08:48:46
问题描述
windwos,怎么做类似phpstudy那样.如果端口被kill掉了.灯就变红色...端口被监听了就变绿色... 而且是实时的... 求各位大神指导一下...
问题解答
回答1:个人没做过实时的,倒是做个一个半实时的,利用socket每30秒和目标端口通信一次,如果通信失败就报警。
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()
这是一个粗糙版的,大概就是这么个意思…不知道对你有帮助没有
相关文章:
1. dockerfile - [docker build image失败- npm install]2. Docker for Mac 创建的dnsmasq容器连不上/不工作的问题3. docker-compose中volumes的问题4. boot2docker无法启动5. docker网络端口映射,没有方便点的操作方法么?6. docker gitlab 如何git clone?7. dockerfile - 我用docker build的时候出现下边问题 麻烦帮我看一下8. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””9. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?10. docker不显示端口映射呢?
排行榜

网公网安备