average calculation removed
diff --git a/sensors/pscpu_sensors.py b/sensors/pscpu_sensors.py
index 24f252b..f7c2d20 100644
--- a/sensors/pscpu_sensors.py
+++ b/sensors/pscpu_sensors.py
@@ -17,9 +17,9 @@
pid_stat1 = pid_stat(pid)
sensor_name = "{0}.{1}".format(dev_name, pid)
- results[sensor_name] = SensorInfo(pid_stat1, False)
+ results[sensor_name] = SensorInfo(pid_stat1, True)
except IOError:
- # may be, proc has already terminated
+ # may be, proc has already terminated, skip it
continue
return results
diff --git a/sensors/psram_sensors.py b/sensors/psram_sensors.py
index 6517520..c82819a 100644
--- a/sensors/psram_sensors.py
+++ b/sensors/psram_sensors.py
@@ -34,4 +34,4 @@
""" Return RAM size in Kb"""
with open("/proc/meminfo") as proc:
mem_total = proc.readline().split()
- return mem_total[1]
+ return mem_total[1]
diff --git a/sensors/syscpu_sensors.py b/sensors/syscpu_sensors.py
index e2f53b7..4e49495 100644
--- a/sensors/syscpu_sensors.py
+++ b/sensors/syscpu_sensors.py
@@ -1,5 +1,3 @@
-import time
-
from discover import provides
from utils import SensorInfo, is_dev_accepted
@@ -13,9 +11,9 @@
# 7 - softirq: servicing softirqs
io_values_pos = [
- (1, 'user_processes', False),
- (2, 'nice_processes', False),
- (3, 'system_processes', False),
+ (1, 'user_processes', True),
+ (2, 'nice_processes', True),
+ (3, 'system_processes', True),
(4, 'idle_time', True),
]
@@ -25,21 +23,6 @@
'procs_running', 'procs_blocked', 'softirq'),
allowed_prefixes=None):
results = {}
- usage_sum = {}
- usage_with_idle = {}
- for line in open('/proc/stat'):
- vals = line.split()
- dev_name = vals[0]
-
- dev_ok = is_dev_accepted(dev_name,
- disallowed_prefixes,
- allowed_prefixes)
-
- if dev_ok:
- usage_sum[dev_name] = float(int(vals[1]) + int(vals[2]) + int(vals[3]))
- usage_with_idle[dev_name] = usage_sum[dev_name] + int(vals[4])
- # wait for average CPU utilization calc
- time.sleep(1)
for line in open('/proc/stat'):
vals = line.split()
@@ -53,15 +36,5 @@
for pos, name, accum_val in io_values_pos:
sensor_name = "{0}.{1}".format(dev_name, name)
results[sensor_name] = SensorInfo(int(vals[pos]), accum_val)
- # utilization calc
- sensor_name = "{0}.{1}".format(dev_name, "usage_percent")
-
- usage_sum_last = float(int(vals[1]) + int(vals[2]) + int(vals[3]))
- usage_with_idle_last = usage_sum_last + int(vals[4])
- proc = usage_sum_last - usage_sum[dev_name]
- idle = usage_with_idle_last - usage_with_idle[dev_name]
- usage = proc / idle
-
- results[sensor_name] = SensorInfo(usage*100, False)
return results
diff --git a/sensors/utils.py b/sensors/utils.py
index fee0198..ad08676 100644
--- a/sensors/utils.py
+++ b/sensors/utils.py
@@ -52,6 +52,7 @@
# no cmd returned
return "<NO NAME>"
except IOError:
+ # upstream wait any string, no matter if we couldn't read proc
return "no_such_process"