-
Notifications
You must be signed in to change notification settings - Fork 0
/
haproxy.py
33 lines (29 loc) · 1.11 KB
/
haproxy.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
# haproxy: Remove -x/-sf arguments which may fluctuate
class ProcessFormatterMixin(object):
def adjust(self, process):
super(ProcessFormatterMixin, self).adjust(process)
# /usr/sbin/haproxy ... [-x ...sock] [-sf 12345 4444]
if process.cmdline.startswith('/usr/sbin/haproxy '):
p = process.cmdline.split()
idx = 0
new_p = []
arg1 = None
try:
while idx < len(p):
arg1 = p[idx]
# [-x ...sock]
if arg1 == '-x' and p[idx + 1].endswith('.sock'):
idx += 2
# [-sf PID1 PID2 PID3...]
elif arg1 == '-sf':
arg1 = None
idx += 1
while p[idx].isdigit():
idx += 1
else:
new_p.append(arg1)
idx += 1
except IndexError:
if arg1 is not None:
new_p.append(arg1)
process.cmdline = ' '.join(new_p)