summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2022-10-15 16:20:30 +0200
committernicolargo <nicolas@nicolargo.com>2022-10-15 16:20:30 +0200
commit1aa5596cc25fbd74cac65c5e4d6b16bd90091138 (patch)
tree5e1372dba335da8655967d100dc19f1c7ed67304
parent6ac163536da536fc496323948e67c4028e9f1e09 (diff)
AMP: regex with special chars #2152
-rw-r--r--conf/glances.conf6
-rw-r--r--glances/amps_list.py17
2 files changed, 11 insertions, 12 deletions
diff --git a/conf/glances.conf b/conf/glances.conf
index 86c2b92a..937a3e07 100644
--- a/conf/glances.conf
+++ b/conf/glances.conf
@@ -712,3 +712,9 @@ regex=\/sbin\/init
refresh=30
one_line=true
service_cmd=/usr/bin/service --status-all
+
+[amp_issue2139]
+enable=true
+#regex=.*sshd:[ a-zA-Z0-9]+@.*
+regex=.*dbus-daemon[ ][-session]+[ ].*
+refresh=30
diff --git a/glances/amps_list.py b/glances/amps_list.py
index b2a4fee0..1622dd32 100644
--- a/glances/amps_list.py
+++ b/glances/amps_list.py
@@ -139,18 +139,11 @@ class AmpsList(object):
try:
# Search in both cmdline and name (for kernel thread, see #1261)
for p in processlist:
- add_it = False
- if re.search(amp_value.regex(), p['name']) is not None:
- add_it = True
- else:
- if p['cmdline'] is None:
- # See issue #1689 (thanks to @darylkell)
- continue
- for c in p['cmdline']:
- if re.search(amp_value.regex(), c) is not None:
- add_it = True
- break
- if add_it:
+ if (re.search(amp_value.regex(), p['name']) is not None) or (
+ p['cmdline'] is not None
+ and p['cmdline'] != []
+ and re.search(amp_value.regex(), ' '.join(p['cmdline'])) is not None
+ ):
ret.append(
{'pid': p['pid'], 'cpu_percent': p['cpu_percent'], 'memory_percent': p['memory_percent']}
)