commit 436016d1babd304e6159c63c80bebc15a3302cd4 Author: Damian Johnson atagar@torproject.org Date: Mon Oct 30 10:15:43 2017 -0700
Fix tor cpu usage metric
Why did we divide by that? Weird. Because of it we always showed tor's cpu usage as 0%. --- nyx/tracker.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/nyx/tracker.py b/nyx/tracker.py index 83159f5..ad033d5 100644 --- a/nyx/tracker.py +++ b/nyx/tracker.py @@ -661,9 +661,10 @@ class ResourceTracker(Daemon): try: resolver = _resources_via_proc if self._use_proc else _resources_via_ps total_cpu_time, uptime, memory_in_bytes, memory_in_percent = resolver(process_pid) + now = time.time()
if self._resources: - cpu_sample = (total_cpu_time - self._resources.cpu_total) / self._resources.cpu_total + cpu_sample = (total_cpu_time - self._resources.cpu_total) / (now - self._resources.timestamp) else: cpu_sample = 0.0 # we need a prior datapoint to give a sampling
@@ -673,7 +674,7 @@ class ResourceTracker(Daemon): cpu_total = total_cpu_time, memory_bytes = memory_in_bytes, memory_percent = memory_in_percent, - timestamp = time.time(), + timestamp = now, )
self._failure_count = 0
tor-commits@lists.torproject.org