zoukankan      html  css  js  c++  java
  • python ping监控

    #!/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

  • 相关阅读:
    ARC 080
    CodeForces
    [Lydsy1806月赛] 路径统计
    AGC 022 C
    AGC 022 B
    AGC 020 B
    UVA
    AGC 018 A
    python
    python
  • 原文地址:https://www.cnblogs.com/toops/p/8525900.html
Copyright © 2011-2022 走看看