首页 > 编程语言 > 详细

python ping监控

时间:2018-03-08 01:59:57      阅读:246      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/python
# coding=utf-8
importos,sys,time
importlogging
host=‘114.114.114.114‘
logging.basicConfig(level=logging.DEBUG,
    format=‘%(asctime)-30s%(message)s‘,
    datefmt=‘%Y-%m-%d%H:%M:%S‘,
    filename=host+‘.log‘,
    filemode=‘a‘)
aping=os.popen(‘ping‘+host)
whileTrue:
    logging.info(aping.readline().rstrip())

启动直接 nohup python filename > /dev/null & 就可以了,kill的时候注意要kill两个进程,一个python 一个ping

python ping监控

原文:https://www.cnblogs.com/toops/p/8525900.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!