python.d/gearmand: handle func prefixes in `status\n` response (#9610)
Ilya Mashchenko committed
Jul 27, 2020 at 15:28 UTC
7377887f361fa08ad0101e2af2a8af41a7d29187
1 file changed
+17
-5
collectors/python.d.plugin/gearman/gearman.chart.py
+17
-5
@@ -121,6 +121,7 @@ class Service(SocketService):
121
122
Example output returned from
123
_get_raw_data():
124
+ prefix generic_worker4 78 78 500
125
generic_worker2 78 78 500
126
generic_worker3 0 0 760
127
generic_worker1 0 0 500
@@ -137,13 +138,24 @@ class Service(SocketService):
138
self.debug("Gearman returned no data")
139
raise GearmanReadException()
140
140
- job_lines = raw.splitlines()[:-1]
141
- job_lines = [job.split() for job in sorted(job_lines)]
141
+ workers = list()
142
143
- for line in job_lines:
144
- line[1:] = map(int, line[1:])
143
+ for line in raw.splitlines()[:-1]:
144
+ parts = line.split()
145
+ if not parts:
146
+ continue
147
+
148
+ name = '_'.join(parts[:-3])
149
+ try:
150
+ values = [int(w) for w in parts[-3:]]
151
+ except ValueError:
152
+ continue
153
+
154
+ w = [name]
155
+ w.extend(values)
156
+ workers.append(w)
157
146
- return job_lines
158
+ return workers
159
160
def process_jobs(self, active_jobs):
161