for i in NLSTB:
with open(i, 'a') as NSLTBD:
NSLTBD.write("python scripts project check, then not alone version insert update messages, \
avoid send mail messages" + "\n")
"""
获取文件路径的函数
dirpath: 用于定义文件日志路径的相对路径
:return: 返回文件元组,当前所有服务的日志相对路径
"""
def Dirfile():
dirpath=[]
for i in List_dir:
if os.path.isdir(i):
files=os.path.join(i,Log_dir)
dirpath.append(files)
return dirpath
"""
获取文件大小
dirsize: 定义一个键值对,用于更新文件的大小及路径
Fsize: 查询到的每个文件大小
:return 返回获取到的键值对
"""
def Filesize(dirname):
dirsize = {}
while True:
for file in dirname:
try:
Fsize=os.path.getsize(file)
dirsize[file]=Fsize
except Exception as E:
pass
return dirsize
"""
收集两次文件的大小用于判断
file_old_size:
"""
def Size_Judge(oldsize,newsize,dirname):e
for dirfilename in dirname:
# 循环获取每个文件的大小.
file_old_size=oldsize[dirfilename]
file_new_size=newsize[dirfilename]
# 增长表示没问题,否则就是有问题
if file_old_size != file_new_size:
pass
else:
# 将获取的值写入文件中, 然后执行邮件脚本
with open('test.txt','w') as file:
file.write(dirfilename)
file.write(",then logfile not increase" + "\n")
os.system("/bin/bash /tmp/mail.sh")