2020-12-10 12:50:22 +00:00
|
|
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
|
|
|
|
|
|
class ComponentsStateSerializer(serializers.Serializer):
|
|
|
|
# system
|
|
|
|
system_cpu_load_1 = serializers.FloatField(
|
2020-12-15 11:38:20 +00:00
|
|
|
required=False, label=_("System cpu load (1 minutes)")
|
2020-12-10 12:50:22 +00:00
|
|
|
)
|
|
|
|
system_memory_used_percent = serializers.FloatField(
|
2020-12-15 11:38:20 +00:00
|
|
|
required=False, label=_('System memory used percent')
|
2020-12-10 12:50:22 +00:00
|
|
|
)
|
|
|
|
system_disk_used_percent = serializers.FloatField(
|
2020-12-15 11:38:20 +00:00
|
|
|
required=False, label=_('System disk used percent')
|
2020-12-10 12:50:22 +00:00
|
|
|
)
|
|
|
|
# sessions
|
|
|
|
session_active_count = serializers.IntegerField(
|
2020-12-15 11:38:20 +00:00
|
|
|
required=False, label=_("Session active count")
|
2020-12-10 12:50:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def save(self, **kwargs):
|
|
|
|
request = self.context['request']
|
|
|
|
terminal = request.user.terminal
|
|
|
|
terminal.state = self.validated_data
|