python 生成测试日志脚本
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import datetime
import json
import random
import time
import os
def core_mail():
nowtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
print('----调度-邮件----')
datas = {"head":{"ip":"172.30.154.46","time":nowtime,"business_type":"HJHY","msg_type":"TUPLE5"},
"content":{"tx_byte": random.randint(100000, 10000000)}}
with open('THREE_LOGS/MIAL/MIAL.log', 'a+') as screen_log:
screen_log.writelines(json.dumps(datas))
print(json.dumps(datas))
screen_log.writelines("\n")
screen_log.close()
def core_dns():
nowtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
print('----调度-dns----')
datas = {"head":{"ip":"172.30.154.46","time":nowtime,"business_type":"HJHY","msg_type":"TUPLE5"},
"content":{"tx_byte":random.randint(100000, 10000000)}}
with open('THREE_LOGS/DNS/core-dns.log', 'a+') as screen_log:
screen_log.writelines(json.dumps(datas))
print(json.dumps(datas))
screen_log.writelines("\n")
screen_log.close()
# count=0
while True:
core_mail()
core_dns()
# count += 1
count = len(open('time_core_log.txt', 'r').readlines())
with open('number_core.txt', 'w') as number:
number.write(str(count))
number.close()
time.sleep(180)

浙公网安备 33010602011771号