-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab-ce.py
53 lines (43 loc) · 1.69 KB
/
gitlab-ce.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# gitlab Omnibus
import re
ADJUST_REGEXES = (
(r'^ruby /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby [0-9]+ '
r'/var/opt/gitlab/gitaly/internal_sockets/ruby.[0-9]+'),
r'puma: cluster worker 0: [0-9]+ \[gitlab-puma-worker\]',
r'puma: cluster worker 1: [0-9]+ \[gitlab-puma-worker\]',
r'puma: cluster worker 2: [0-9]+ \[gitlab-puma-worker\]',
r'puma: cluster worker 3: [0-9]+ \[gitlab-puma-worker\]',
)
ADJUST_CREGEXES = tuple(re.compile(i) for i in ADJUST_REGEXES)
NOCHILDREN_MATCHES = (
r'/opt/gitlab/embedded/bin/postgres -D /var/opt/gitlab/postgresql/data',
r'/bin/sh /opt/gitlab/embedded/bin/gitlab-logrotate-wrapper',
)
EXCLUDE_REGEXES = (
(r'^/opt/gitlab/embedded/bin/git --git-dir [^ ]+ '
r'cat-file --batch(-check)?$'),
)
EXCLUDE_CREGEXES = tuple(re.compile(i) for i in EXCLUDE_REGEXES)
class ProcessFormatterMixin(object):
def adjust(self, process):
super(ProcessFormatterMixin, self).adjust(process)
for idx, regex in enumerate(ADJUST_CREGEXES):
s = process.cmdline
m = regex.search(s)
if m:
process.cmdline = (
s[:m.start()] +
ADJUST_REGEXES[idx].replace('\\', '') +
s[m.end():])
break
def include(self, process):
ret = super(ProcessFormatterMixin, self).include(process)
if not ret:
return False
if process.has_parent(
include_self=False, cmdline__startswith=NOCHILDREN_MATCHES):
return False
for idx, regex in enumerate(EXCLUDE_CREGEXES):
if regex.search(process.cmdline):
return False
return True