mirror of https://github.com/jumpserver/jumpserver
parent
d4721e90d5
commit
d4e53be7ce
|
@ -19,6 +19,7 @@ logger = get_logger(__file__)
|
||||||
|
|
||||||
class TerminalStatusMixin:
|
class TerminalStatusMixin:
|
||||||
id: str
|
id: str
|
||||||
|
type: str
|
||||||
ALIVE_KEY = 'TERMINAL_ALIVE_{}'
|
ALIVE_KEY = 'TERMINAL_ALIVE_{}'
|
||||||
status_set: models.Manager
|
status_set: models.Manager
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ class TerminalStatusMixin:
|
||||||
@lazyproperty
|
@lazyproperty
|
||||||
def load(self):
|
def load(self):
|
||||||
from ...utils import ComputeLoadUtil
|
from ...utils import ComputeLoadUtil
|
||||||
return ComputeLoadUtil.compute_load(self.last_stat)
|
return ComputeLoadUtil.compute_load(self.last_stat, self.type)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from terminal.const import ComponentLoad
|
from terminal.const import ComponentLoad, TerminalType
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -38,9 +38,13 @@ class ComputeLoadUtil:
|
||||||
return system_status
|
return system_status
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def compute_load(cls, stat):
|
def compute_load(cls, stat, terminal_type=None):
|
||||||
if not stat:
|
if not stat:
|
||||||
return ComponentLoad.offline
|
# TODO The core component and celery component will return true for the time being.
|
||||||
|
if terminal_type in [TerminalType.core, TerminalType.celery]:
|
||||||
|
return ComponentLoad.normal
|
||||||
|
else:
|
||||||
|
return ComponentLoad.offline
|
||||||
system_status_values = cls._compute_system_stat_status(stat).values()
|
system_status_values = cls._compute_system_stat_status(stat).values()
|
||||||
if ComponentLoad.critical in system_status_values:
|
if ComponentLoad.critical in system_status_values:
|
||||||
return ComponentLoad.critical
|
return ComponentLoad.critical
|
||||||
|
|
Loading…
Reference in New Issue