|
6 | 6 | # mypy: disable-error-code="possibly-undefined" |
7 | 7 |
|
8 | 8 | import argparse |
| 9 | +import json |
9 | 10 | import sys |
10 | 11 | from collections.abc import Mapping, Sequence |
11 | 12 |
|
|
14 | 15 |
|
15 | 16 | from cmk.password_store.v1_unstable import parser_add_secret_option, resolve_secret_option |
16 | 17 | from cmk.server_side_programs.v1_unstable import report_agent_crashes, vcrtrace |
17 | | -from cmk.special_agents.v0_unstable.agent_common import SectionWriter |
18 | 18 |
|
19 | 19 | __version__ = "2.5.0b1" |
20 | 20 |
|
@@ -139,9 +139,9 @@ def parse_arguments(argv: Sequence[str]) -> argparse.Namespace: |
139 | 139 |
|
140 | 140 |
|
141 | 141 | def handle_cluster_health(response: Mapping[str, object]) -> None: |
142 | | - with SectionWriter("elasticsearch_cluster_health", separator=" ") as writer: |
143 | | - for item, value in response.items(): |
144 | | - writer.append(f"{item} {value}") |
| 142 | + sys.stdout.write("<<<elasticsearch_cluster_health:sep(32)>>>\n") |
| 143 | + for item, value in response.items(): |
| 144 | + sys.stdout.write(f"{item} {value}\n") |
145 | 145 |
|
146 | 146 |
|
147 | 147 | class _CPUResponse(pydantic.BaseModel, frozen=True): |
@@ -170,26 +170,25 @@ class _NodesReponse(pydantic.BaseModel, frozen=True): |
170 | 170 |
|
171 | 171 |
|
172 | 172 | def handle_nodes(response: Mapping[str, object]) -> None: |
173 | | - with SectionWriter("elasticsearch_nodes", separator=" ") as writer: |
174 | | - for node_response in _NodesReponse.model_validate(response).nodes.values(): |
175 | | - writer.append( |
176 | | - f"{node_response.name} open_file_descriptors {node_response.process.open_file_descriptors}" |
177 | | - ) |
178 | | - writer.append( |
179 | | - f"{node_response.name} max_file_descriptors {node_response.process.max_file_descriptors}" |
180 | | - ) |
181 | | - writer.append(f"{node_response.name} cpu_percent {node_response.process.cpu.percent}") |
182 | | - writer.append( |
183 | | - f"{node_response.name} cpu_total_in_millis {node_response.process.cpu.total_in_millis}" |
184 | | - ) |
185 | | - writer.append( |
186 | | - f"{node_response.name} mem_total_virtual_in_bytes {node_response.process.mem.total_virtual_in_bytes}" |
187 | | - ) |
| 173 | + sys.stdout.write("<<<elasticsearch_nodes:sep(32)>>>\n") |
| 174 | + for node_response in _NodesReponse.model_validate(response).nodes.values(): |
| 175 | + sys.stdout.write( |
| 176 | + f"{node_response.name} open_file_descriptors {node_response.process.open_file_descriptors}\n" |
| 177 | + ) |
| 178 | + sys.stdout.write( |
| 179 | + f"{node_response.name} max_file_descriptors {node_response.process.max_file_descriptors}\n" |
| 180 | + ) |
| 181 | + sys.stdout.write(f"{node_response.name} cpu_percent {node_response.process.cpu.percent}\n") |
| 182 | + sys.stdout.write( |
| 183 | + f"{node_response.name} cpu_total_in_millis {node_response.process.cpu.total_in_millis}\n" |
| 184 | + ) |
| 185 | + sys.stdout.write( |
| 186 | + f"{node_response.name} mem_total_virtual_in_bytes {node_response.process.mem.total_virtual_in_bytes}\n" |
| 187 | + ) |
188 | 188 |
|
189 | 189 |
|
190 | 190 | def handle_stats(response: Mapping[str, object]) -> None: |
191 | | - with SectionWriter("elasticsearch_indices") as writer: |
192 | | - writer.append_json(response["indices"]) |
| 191 | + sys.stdout.write(f"<<<elasticsearch_indices:sep(0)>>>\n{json.dumps(response['indices'])}\n") |
193 | 192 |
|
194 | 193 |
|
195 | 194 | @report_agent_crashes(AGENT, __version__) |
|
0 commit comments