node_manager_fkie: determine processes with high load
@@ -69,7 +69,19 @@ class CpuLoad(SensorInterface):
if count_warn_cpu > 1:
diag_level = DiagnosticStatus.WARN
diag_msg = 'CPU load of %d cores is >%.0f%%)' % (count_warn_cpu, self._cpu_load_warn * 100)
-
+ try:
+ # determine processes with high load
+ processes = {}
+ for pi in sorted(psutil.process_iter(attrs=['name', 'cpu_percent']), key=lambda pi: pi.info['cpu_percent'], reverse=True):
+ if pi.info['cpu_percent'] / 100.0 >= warn_level:
+ phlmsg = '%.2f%% %s[%d] %s' % (pi.info['cpu_percent'], pi.info['name'], pi.pid, ' '.join(pi.cmdline()[:1]))
+ processes[pi.info['cpu_percent']] = phlmsg
+ else:
+ break
+ for _pp, msg in processes.items():
+ diag_vals.append(KeyValue(key='Process high load', value=msg))
+ except Exception:
+ pass
# Update status
with self.mutex:
self._ts_last = time.time()
