Compare commits

...

5 Commits
master ... cmdb

Author SHA1 Message Date
p53209761 6d08d81197 dddd
dddddd
2022-10-19 17:03:44 +08:00
p53209761 89b8edb140 Add uuuu.py 2022-10-19 17:03:19 +08:00
p53209761 30418dcdcc Update test.py 2022-10-19 17:02:16 +08:00
p53209761 f2f95a22a7 Update test.py 2022-10-19 16:51:03 +08:00
p53209761 120982df55 Add test.py 2022-10-19 16:49:16 +08:00
2 changed files with 43 additions and 0 deletions

42
test.py Normal file
View File

@ -0,0 +1,42 @@
import datetime
from faker import Faker
import time
fake = Faker(locale="zh_CN")
def write_log(path, aaa):
with open(file=path, mode="a", encoding="utf-8") as f:
if isinstance(aaa, str):
f.write(aaa)
if isinstance(aaa, list):
for line in aaa:
f.write(line)
for i in range(2):
time.sleep(1)
current_time = datetime.datetime.now()
nginx_log = f'{current_time.strftime("%Y/%m/%d %H:%M:%S")} [error] 32#32: ngnix:{fake.address()}, client: 127.0.0.1, server: n9e.example.com, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1", referrer: "http://127.0.0.1/api/mon/bi/configs"\n'
nginx_path = r"C:\logstash-7.16.2-windows-x86_64\logstash-7.16.2\error-log-example\nginx.log"
minio_log = 'API: SYSTEM()\n' \
f'Time: {current_time.strftime("%H:%M:%S CST %m/%d/%Y")}\n' \
f'DeploymentID: {fake.md5(raw_output=False)}\n' \
f'Error:{fake.address()}\r'
minio_path = r"C:\logstash-7.16.2-windows-x86_64\logstash-7.16.2\error-log-example\minio.log"
elasticsearch_log = f"[{current_time.strftime('%Y-%m-%dT%H:%M:%S')},687][ERROR]es: {fake.address()}\n"
elasticsearch_path = r"C:\logstash-7.16.2-windows-x86_64\logstash-7.16.2\error-log-example\elasticsearch.log"
cassandra_log = f"WARN [main] {current_time.strftime('%Y-%m-%d %H:%M:%S')},656 cassandra: {fake.address()} \n"
cassandra_path = r"C:\logstash-7.16.2-windows-x86_64\logstash-7.16.2\error-log-example\cassandra_error.log"
# write_log(nginx_path, nginx_log)
write_log(minio_path, minio_log)
# write_log(elasticsearch_path, elasticsearch_log)
# write_log(cassandra_path, cassandra_log)

1
uuuu.py Normal file
View File

@ -0,0 +1 @@
print("ok")