예제 #1
0
 def cpu_times(self):
     try:
         ret = cext.proc_cpu_times(self.pid)
     except OSError as err:
         if err.errno in ACCESS_DENIED_SET:
             ret = cext.proc_cpu_times_2(self.pid)
         else:
             raise
     return _common.pcputimes(*ret)
예제 #2
0
 def cpu_times(self):
     with open("/proc/%s/stat" % self.pid, 'rb') as f:
         st = f.read().strip()
     # ignore the first two values ("pid (exe)")
     st = st[st.find(b')') + 2:]
     values = st.split(b' ')
     utime = float(values[11]) / CLOCK_TICKS
     stime = float(values[12]) / CLOCK_TICKS
     return _common.pcputimes(utime, stime)
예제 #3
0
 def cpu_times(self):
     with open("/proc/%s/stat" % self.pid, 'rb') as f:
         st = f.read().strip()
     # ignore the first two values ("pid (exe)")
     st = st[st.find(b')') + 2:]
     values = st.split(b' ')
     utime = float(values[11]) / CLOCK_TICKS
     stime = float(values[12]) / CLOCK_TICKS
     return _common.pcputimes(utime, stime)
예제 #4
0
 def cpu_times(self):
     try:
         ret = cext.proc_cpu_times(self.pid)
     except OSError as err:
         if err.errno in ACCESS_DENIED_SET:
             ret = cext.proc_cpu_times_2(self.pid)
         else:
             raise
     return _common.pcputimes(*ret)
예제 #5
0
파일: _pslinux.py 프로젝트: ztop/psutil
 def cpu_times(self):
     f = open("/proc/%s/stat" % self.pid)
     try:
         st = f.read().strip()
     finally:
         f.close()
     # ignore the first two values ("pid (exe)")
     st = st[st.find(')') + 2:]
     values = st.split(' ')
     utime = float(values[11]) / CLOCK_TICKS
     stime = float(values[12]) / CLOCK_TICKS
     return _common.pcputimes(utime, stime)
예제 #6
0
def test_run_negative_last_cpu_times(caplog):
    cpu = Cpu()
    cpu.last_cpu_times = pcputimes(user=1e12,
                                   system=1e12,
                                   children_user=0.0,
                                   children_system=0.0)

    result = cpu.run()

    assert result is None
    record_tuples = [
        r for r in caplog.record_tuples
        if r[0] == "scout_apm.core.samplers.cpu"
    ]
    assert len(record_tuples) == 1
    _, level, message = record_tuples[0]
    assert level == logging.DEBUG
    assert message.startswith(
        "Process CPU: Negative process time elapsed. utime: ")
    assert message.endswith(
        "This is normal to see when starting a forking web server.")
예제 #7
0
파일: _pssunos.py 프로젝트: ztop/psutil
 def cpu_times(self):
     user, system = cext.proc_cpu_times(self.pid)
     return _common.pcputimes(user, system)
예제 #8
0
 def cpu_times(self):
     user, system = cext.proc_cpu_times(self.pid)
     return _common.pcputimes(user, system)
예제 #9
0
파일: _psbsd.py 프로젝트: ztop/psutil
 def cpu_times(self):
     """return a tuple containing process user/kernel time."""
     user, system = cext.proc_cpu_times(self.pid)
     return _common.pcputimes(user, system)