Compare commits

...

4 Commits
master ... ymla

Author SHA1 Message Date
p53209761 1bc55c335e Update test.py 2022-10-19 17:02:35 +08:00
p53209761 7ed885c986 Add yaml.yml 2022-10-19 17:01:12 +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 45 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, ttt):
with open(file=path, mode="a", encoding="utf-8") as f:
if isinstance(ttt, str):
f.write(ttt)
if isinstance(ttt, list):
for line in ttt:
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)

3
yaml.yml Normal file
View File

@ -0,0 +1,3 @@
- a
-b
-c