Commit 1709803c by Gregory Nagy

Added get_node_metrics function to collect metrics from the node

parent 9673bb0e
...@@ -7,7 +7,7 @@ import socket ...@@ -7,7 +7,7 @@ import socket
import json import json
from decorator import decorator from decorator import decorator
from psutil import NUM_CPUS, virtual_memory from psutil import NUM_CPUS, virtual_memory, virtmem_usage, cpu_percent
from vm import VMInstance from vm import VMInstance
...@@ -521,3 +521,11 @@ def get_core_num(): ...@@ -521,3 +521,11 @@ def get_core_num():
@celery.task @celery.task
def get_ram_size(): def get_ram_size():
return virtual_memory().total return virtual_memory().total
@celery.task
def get_node_metrics():
result = {}
result['cpu.usage'] = cpu_percent(0)
result['memory.usage'] = virtmem_usage.percent()
return result
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment