Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

edgify / rook   python

Repository URL to install this package:

/ processor / namespaces / process_state_namespace.py

from .namespace import Namespace
from .container_namespace import ContainerNamespace
from .python_object_namespace import PythonObjectNamespace
from ...services.monitor.monitor_service import MonitorService

class ProcessStateNamespace(Namespace):
    def __init__(self):
        super(ProcessStateNamespace, self).__init__(self.METHODS)

    def dump(self, args):
        usage = MonitorService.get_last_usage()
        if not usage:
            return ContainerNamespace({})

        return ContainerNamespace(
            {
                "CPU": PythonObjectNamespace(usage.cpu),
                "GlobalCPU": PythonObjectNamespace(usage.global_cpu),
                "VirtualMemorySize": PythonObjectNamespace(usage.virtual_memory),
                "ProcessStartTime": PythonObjectNamespace(usage.start_time),
                "SystemUpTime": PythonObjectNamespace(usage.uptime),
            }
        )

    METHODS = (dump, )