first commit

This commit is contained in:
이수준 2023-09-06 14:49:19 +09:00
commit d36b2a0183
4 changed files with 49 additions and 0 deletions

10
awx-perfermance.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=awx-perfermance
[Service]
ExecStart=/home/sdt/miniconda3/bin/python3 /usr/local/sdt/app/awx-perfermance/main.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

1
config.yaml Normal file
View File

@ -0,0 +1 @@
topic: perfermance

5
install.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
sudo cp /usr/local/sdt/app/awx-perfermance/awx-perfermance.service /etc/systemd/system/
sudo systemctl start awx-perfermance
sudo systemctl enable awx-perfermance

33
main.py Normal file
View File

@ -0,0 +1,33 @@
import paho.mqtt.client as mqtt
import json
from datetime import datetime
import time
import yaml
with open('/usr/local/sdt/app/awx-perfermance/config.yaml', encoding='UTF-8') as f:
yamlData = yaml.load(f, Loader=yaml.FullLoader)
mqttc = mqtt.Client() # puclisher 이름
mqttc.username_pw_set("sdt", "251327")
mqttc.connect("13.209.39.139", 32259)
while True:
dataList = []
for n in range(10):
data = {
"timestamp": datetime.now().timestamp(),
"data": [1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 4, 5, 6, 1],
}
dataList.append(data)
time.sleep(0.1)
datas = json.dumps({
"assetCode":"",
"timestamp":0,
"dataType":"",
"data": dataList
})
mqttc.publish(f"/device-data/{yamlData['topic']}", datas) # topic, message