Merge branch 'dev' of gitlab.com:crafty-controller/crafty-4 into dev

This commit is contained in:
Zedifus 2022-06-18 22:52:07 +01:00
commit 53c622e928
2 changed files with 15 additions and 12 deletions

View File

@ -130,16 +130,19 @@ class Stats:
}
@staticmethod
def _try_get_process_stats(process):
try:
return Stats._get_process_stats(process)
except Exception as e:
logger.debug(
f"getting process stats for pid {process.pid} "
"failed due to the following error:",
exc_info=e,
)
return {"cpu_usage": -1, "memory_usage": -1, "mem_percentage": -1}
def _try_get_process_stats(process, running):
if running:
try:
return Stats._get_process_stats(process)
except Exception as e:
logger.debug(
f"getting process stats for pid {process.pid} "
"failed due to the following error:",
exc_info=e,
)
return {"cpu_usage": -1, "memory_usage": -1, "mem_percentage": -1}
else:
return {"cpu_usage": 0, "memory_usage": 0, "mem_percentage": 0}
@staticmethod
def _get_process_stats(process):

View File

@ -1255,7 +1255,7 @@ class ServerInstance:
server_path = server["path"]
# process stats
p_stats = Stats._try_get_process_stats(self.process)
p_stats = Stats._try_get_process_stats(self.process, self.check_running())
# TODO: search server properties file for possible override of 127.0.0.1
internal_ip = server["server_ip"]
@ -1388,7 +1388,7 @@ class ServerInstance:
server_path = server_dt["path"]
# process stats
p_stats = Stats._try_get_process_stats(self.process)
p_stats = Stats._try_get_process_stats(self.process, self.check_running())
# TODO: search server properties file for possible override of 127.0.0.1
# internal_ip = server['server_ip']