AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 18.220.110.45


Current Path : /usr/lib/python3/dist-packages/landscape/sysinfo/
Upload File :
Current File : //usr/lib/python3/dist-packages/landscape/sysinfo/processes.py

from twisted.internet.defer import succeed

from landscape.lib.process import ProcessInformation


class Processes(object):

    def __init__(self, proc_dir="/proc"):
        self._proc_dir = proc_dir

    def register(self, sysinfo):
        self._sysinfo = sysinfo

    def run(self):
        num_processes = 0
        num_zombies = 0
        info = ProcessInformation(proc_dir=self._proc_dir)
        for process_info in info.get_all_process_info():
            num_processes += 1
            if process_info["state"] == b"Z":
                num_zombies += 1
        if num_zombies:
            if num_zombies == 1:
                msg = "There is 1 zombie process."
            else:
                msg = "There are %d zombie processes." % (num_zombies,)
            self._sysinfo.add_note(msg)
        self._sysinfo.add_header("Processes", str(num_processes))
        return succeed(None)