-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.py
30 lines (24 loc) · 881 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time
import logging
from rabbitmq.RabbitMq import RabbitMqConfig,ServerMq
from monitor.stream import get_system_data
logger = logging.getLogger(__name__)
sysconfig = RabbitMqConfig(queue="entry",host="localhost",routing_key="entry")
SystemServer = ServerMq(config=sysconfig)
while True:
try:
data = get_system_data()
logger.info("Data Received")
print("Data Received")
except Exception as e:
logger.error(f"Data not received error : {e}")
print(f"Data not received error : {e}")
break
try:
SystemServer.publish(data)
time.sleep(2)
logger.info("Data Transmitted , sleeping for two seconds")
print("Data Transmitted , sleeping for two seconds")
except Exception as e:
logger.error(f"Unable to transmit data : {e}")
print(f"Unable to transmit data : {e}")