mirror of
https://github.com/newnius/YAO-agent.git
synced 2025-06-06 05:21:55 +00:00
remove docker files
This commit is contained in:
parent
d606f5989b
commit
660fe82449
24
agent.py
24
agent.py
@ -286,8 +286,7 @@ def report():
|
|||||||
print("execute failed, ", msg_gpu)
|
print("execute failed, ", msg_gpu)
|
||||||
stats = get_gpu_status()
|
stats = get_gpu_status()
|
||||||
report_msg(stats)
|
report_msg(stats)
|
||||||
t = Thread(target=launch_tasks, name='launch_tasks', args=(stats,))
|
Thread(target=launch_tasks, name='launch_tasks', args=(stats,)).start()
|
||||||
t.start()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
@ -385,19 +384,12 @@ if __name__ == '__main__':
|
|||||||
os.environ["TZ"] = 'Asia/Shanghai'
|
os.environ["TZ"] = 'Asia/Shanghai'
|
||||||
if hasattr(time, 'tzset'):
|
if hasattr(time, 'tzset'):
|
||||||
time.tzset()
|
time.tzset()
|
||||||
threads = []
|
|
||||||
t1 = Thread(target=reporter)
|
Thread(target=reporter).start()
|
||||||
threads.append(t1)
|
Thread(target=listener).start()
|
||||||
t2 = Thread(target=listener)
|
|
||||||
threads.append(t2)
|
|
||||||
if EnableEventTrigger == 'true':
|
if EnableEventTrigger == 'true':
|
||||||
t3 = Thread(target=event_trigger)
|
print('start event trigger')
|
||||||
threads.append(t3)
|
Thread(target=event_trigger).start()
|
||||||
|
|
||||||
# Start all threads
|
while True:
|
||||||
for t in threads:
|
time.sleep(5)
|
||||||
t.start()
|
|
||||||
|
|
||||||
# Wait for all of them to finish
|
|
||||||
for t in threads:
|
|
||||||
t.join()
|
|
||||||
|
26
monitor.py
26
monitor.py
@ -1,32 +1,29 @@
|
|||||||
import os
|
import os
|
||||||
import threading
|
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
from kafka import KafkaProducer
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import psutil
|
import psutil
|
||||||
import math
|
import math
|
||||||
from executor import launch_tasks
|
import datetime
|
||||||
|
|
||||||
ClientID = os.getenv('ClientID', 1)
|
|
||||||
ClientHost = os.getenv('ClientHost', "localhost")
|
|
||||||
KafkaBrokers = os.getenv('KafkaBrokers', 'localhost:9092').split(',')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
interval = 5
|
interval = 1
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
status, msg_gpu = execute(['nvidia-smi', '-q', '-x', '-f', 'status.xml'])
|
status, msg_gpu = execute(['nvidia-smi', '-q', '-x', '-f', 'status.xml'])
|
||||||
if not status:
|
if not status:
|
||||||
print("execute failed, ", msg_gpu)
|
print("execute failed, ", msg_gpu)
|
||||||
stats = get_gpu_status()
|
stats = get_gpu_status()
|
||||||
report_msg(stats)
|
utils = []
|
||||||
t = threading.Thread(target=launch_tasks, name='launch_tasks',args=(stats,))
|
for stat in stats:
|
||||||
t.start()
|
utils.append(str(stat['utilization_gpu']))
|
||||||
|
# report_msg(stats)
|
||||||
|
t = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
print(str(t) + ',' + ','.join(utils))
|
||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
@ -85,8 +82,6 @@ def report_msg(stats):
|
|||||||
mem = psutil.virtual_memory()
|
mem = psutil.virtual_memory()
|
||||||
|
|
||||||
post_fields = {
|
post_fields = {
|
||||||
'id': ClientID,
|
|
||||||
'host': ClientHost,
|
|
||||||
'status': stats,
|
'status': stats,
|
||||||
'cpu_num': multiprocessing.cpu_count(),
|
'cpu_num': multiprocessing.cpu_count(),
|
||||||
'cpu_load': os.getloadavg()[0],
|
'cpu_load': os.getloadavg()[0],
|
||||||
@ -95,11 +90,6 @@ def report_msg(stats):
|
|||||||
}
|
}
|
||||||
data = json.dumps(post_fields)
|
data = json.dumps(post_fields)
|
||||||
|
|
||||||
producer = KafkaProducer(bootstrap_servers=KafkaBrokers)
|
|
||||||
future = producer.send('yao', value=data.encode(), partition=0)
|
|
||||||
result = future.get(timeout=10)
|
|
||||||
print(result)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
os.environ["TZ"] = 'Asia/Shanghai'
|
os.environ["TZ"] = 'Asia/Shanghai'
|
||||||
|
Loading…
Reference in New Issue
Block a user