A prog2-höz tartozó friss repo anyagok itt elérhetőek: https://git.iit.bme.hu/prog2

Commit d53a5983 by Chif Gergő

Added default value to CPU usage and memory usage

If the monitor info can't get the values, the values get default 0.
parent aa92a44d
...@@ -366,12 +366,18 @@ class Node(OperatedMixin, TimeStampedModel): ...@@ -366,12 +366,18 @@ class Node(OperatedMixin, TimeStampedModel):
@property @property
@node_available @node_available
def cpu_usage(self): def cpu_usage(self):
if self.monitor_info.get('cpu.percent') is not None:
return self.monitor_info.get('cpu.percent') / 100 return self.monitor_info.get('cpu.percent') / 100
else:
return 0
@property @property
@node_available @node_available
def ram_usage(self): def ram_usage(self):
if self.monitor_info.get('memory.usage') is not None:
return self.monitor_info.get('memory.usage') / 100 return self.monitor_info.get('memory.usage') / 100
else:
return 0
@property @property
@node_available @node_available
......
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