使用python调用ping命令,然后在日志中记录ping的结果,用来监测网络连通情况。
代码:
[python]
from time import *
from subprocess import *
webf= open("webs.txt","r")
webs=[]
for w in webf:
webs.append(w.strip())
def logAppend(log,info):
inttime = time()
structtime = localtime(inttime)
strtime = strftime("%Y-%m-%d,%H:%M:%S",structtime)
print "at ",strtime
log.write("================== "+strtime+" ==================n")
log.write(info)
log.write("nn")
print "append info to file :",log.name
print info
def netCheck():
while True:
for url in webs: